Search in sources :

Example 1 with J9ThreadMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.

the class DumpContendedLoadTable method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (0 != args.length) {
        String argument = args[0];
        if (argument.equalsIgnoreCase("help")) {
            help(out);
            return;
        }
    }
    try {
        J9JavaVMPointer javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9HashTablePointer contTable = javaVM.contendedLoadTable();
        J9PoolPointer poolPtr = contTable.listNodePool();
        Pool<J9ContendedLoadTableEntryPointer> pool = Pool.fromJ9Pool(poolPtr, J9ContendedLoadTableEntryPointer.class);
        SlotIterator<J9ContendedLoadTableEntryPointer> poolIterator = pool.iterator();
        if (poolIterator.hasNext()) {
            out.println("Active class loads:");
            while (poolIterator.hasNext()) {
                J9ContendedLoadTableEntryPointer entryPointer = poolIterator.next();
                String ldStatus = loadingStatusValues.get(entryPointer.status().longValue());
                if (null == ldStatus) {
                    ldStatus = "ILLEGAL VALUE: " + entryPointer.status();
                }
                J9VMThreadPointer loadingThread = entryPointer.thread();
                out.print(String.format("\tClassname: %s;\n\t\tLoader:  %s; Loading thread: %s %s\n\t\tStatus: %s; Table entry hash 0x%X\n", entryPointer.className().getCStringAtOffset(0, entryPointer.classNameLength().longValue()), entryPointer.classLoader().formatShortInteractive(), J9VMThreadHelper.getName(loadingThread), loadingThread.formatShortInteractive(), ldStatus, entryPointer.hashValue().longValue()));
            }
            MonitorIterator iterator = new MonitorIterator(javaVM);
            while (iterator.hasNext()) {
                Object current = iterator.next();
                if (current instanceof J9ThreadMonitorPointer) {
                    // System Monitor
                    SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
                    final String monitorName = monitor.getName();
                    if (monitorName.matches(".*VM class table.*")) {
                        List<J9ThreadPointer> waitingThreads = monitor.getWaitingThreads();
                        if (!waitingThreads.isEmpty()) {
                            out.print("Waiting threads:\n");
                            for (J9ThreadPointer tp : waitingThreads) {
                                J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(tp);
                                if (vmThread.notNull()) {
                                    out.print(String.format("\t%s\t%s\n", vmThread.formatShortInteractive(), J9VMThreadHelper.getName(vmThread)));
                                } else {
                                    out.print(String.format("\t%s\t%s\n", tp.formatShortInteractive(), "[osthread]"));
                                }
                            }
                        }
                        break;
                    }
                }
            }
        } else {
            out.println("No active class loads");
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9HashTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer) J9PoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer) MonitorIterator(com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator) SystemMonitor(com.ibm.j9ddr.vm29.j9.SystemMonitor) J9ContendedLoadTableEntryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ContendedLoadTableEntryPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)

Example 2 with J9ThreadMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.

the class MonitorsCommand method tablePrintHelper.

/**
 * Helper to print monitor tables.
 *
 * @param filter
 * @param builder
 * @param objectMonitorPointer
 * @return
 * @throws DDRInteractiveCommandException
 */
private ObjectMonitor tablePrintHelper(FilterOptions filter, StringBuilder builder, J9ObjectMonitorPointer objectMonitorPointer) throws DDRInteractiveCommandException {
    try {
        J9ThreadMonitorPointer threadMonitorPointer = objectMonitorPointer.monitor();
        J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(threadMonitorPointer);
        if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
            if (!lock.userData().eq(0)) {
                // this is an object monitor in the system monitor table
                J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
                ObjectMonitor objMon = ObjectAccessBarrier.getMonitor(obj);
                if (null != objMon) {
                    writeObjectMonitorToBuffer(filter, objMon, builder);
                    return objMon;
                }
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    return null;
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Example 3 with J9ThreadMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.

the class MonitorsCommand method printMonitorsForJ9Thread.

private void printMonitorsForJ9Thread(PrintStream out, J9JavaVMPointer vm, J9ThreadPointer osThreadPtr) throws CorruptDataException {
    FilterOptions defaultFilter = FilterOptions.defaultOption();
    MonitorIterator iterator = new MonitorIterator(vm);
    while (iterator.hasNext()) {
        Object current = iterator.next();
        if (current instanceof J9ThreadMonitorPointer) {
            // System Monitor
            SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
            List<J9ThreadPointer> threadList = null;
            // Step 2: Print any monitors that the thread is the owner of:
            J9ThreadPointer ownerPtr = monitor.getOwner();
            if (ownerPtr.notNull() && ownerPtr.equals(osThreadPtr)) {
                out.print("Owns System Monitor:\n\t");
                writeSystemMonitor(defaultFilter, monitor, out);
            }
            // Step 3: Print any monitors that the thread is blocking on:
            threadList = monitor.getBlockedThreads();
            for (J9ThreadPointer thread : threadList) {
                if (osThreadPtr.equals(thread)) {
                    out.print("Blocking on System Monitor (Enter Waiter):\n\t");
                    writeSystemMonitor(defaultFilter, monitor, out);
                }
            }
            // Step 4: Print any monitors that the thread is waiting on:
            threadList = monitor.getWaitingThreads();
            for (J9ThreadPointer thread : threadList) {
                if (osThreadPtr.equals(thread)) {
                    out.print("Waiting on System Monitor (Notify Waiter):\n\t");
                    writeSystemMonitor(defaultFilter, monitor, out);
                }
            }
        }
    }
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) MonitorIterator(com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator) SystemMonitor(com.ibm.j9ddr.vm29.j9.SystemMonitor) J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)

Example 4 with J9ThreadMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.

the class MonitorIterator method threadPoolHasNext.

private boolean threadPoolHasNext() throws CorruptDataException {
    while ((current == null) && pool.notNull()) {
        while (index < poolSize) {
            J9ThreadMonitorPointer monitor = J9ThreadMonitorPointer.cast(poolEntries.add(index));
            index++;
            if (freeTag != monitor.count().longValue()) {
                J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(monitor);
                if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
                    if (!lock.userData().eq(0)) {
                        // this is an object monitor in the system monitor table
                        J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
                        ObjectMonitor objmon = ObjectAccessBarrier.getMonitor(obj);
                        // This check is to exclude flat object monitors. Flat object monitors are accounted for during the heap walk
                        if ((objmon == null) || !objmon.isInflated()) {
                            continue;
                        }
                        // return an object monitor
                        current = objmon;
                    }
                } else {
                    // return a system monitor
                    current = monitor;
                }
                if (log.isLoggable(Level.FINE)) {
                    log.fine(String.format("Found monitor @ 0x%016x : %s", monitor.getAddress(), monitor.name().getCStringAtOffset(0)));
                }
                return true;
            }
        }
        pool = pool.next();
        if (pool.notNull()) {
            index = 0;
            poolEntries = pool.entriesEA();
        }
    }
    return pool.notNull();
}
Also used : J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Example 5 with J9ThreadMonitorPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer in project openj9 by eclipse.

the class MonitorsCommand method systemCommand.

private void systemCommand(FilterOptions filter, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        MonitorIterator iterator = new MonitorIterator(vm);
        while (iterator.hasNext()) {
            Object current = iterator.next();
            if (current instanceof J9ThreadMonitorPointer) {
                // System Monitor
                SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
                writeSystemMonitor(filter, monitor, out);
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : MonitorIterator(com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator) SystemMonitor(com.ibm.j9ddr.vm29.j9.SystemMonitor) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)7 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)4 MonitorIterator (com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator)4 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)4 J9ThreadAbstractMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)4 CorruptDataException (com.ibm.j9ddr.CorruptDataException)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)3 SystemMonitor (com.ibm.j9ddr.vm29.j9.SystemMonitor)3 J9ThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer)3 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)2 J9ContendedLoadTableEntryPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ContendedLoadTableEntryPointer)1 J9HashTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer)1 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)1 HashMap (java.util.HashMap)1