Search in sources :

Example 1 with J9ThreadPointer

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

the class ObjectMonitor_V1 method initializeWaitingThreads.

private void initializeWaitingThreads() throws CorruptDataException {
    waitingThreads = new ArrayList<J9VMThreadPointer>();
    if (!isInflated) {
        return;
    }
    J9ThreadPointer thread = monitor.waiting();
    while (thread.notNull()) {
        J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(thread);
        if (vmThread.notNull()) {
            waitingThreads.add(vmThread);
        }
        thread = thread.next();
    }
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)

Example 2 with J9ThreadPointer

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

the class ObjectMonitor_V1 method initializeBlockedThreads.

private void initializeBlockedThreads() throws CorruptDataException {
    blockedThreads = new ArrayList<J9VMThreadPointer>();
    if (isInflated) {
        if (OmrBuildFlags.OMR_THR_THREE_TIER_LOCKING) {
            J9ThreadPointer thread = monitor.blocking();
            while (thread.notNull()) {
                J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(thread);
                if (vmThread.notNull()) {
                    blockedThreads.add(vmThread);
                }
                thread = thread.next();
            }
        } else {
            List<J9VMThreadPointer> list = getBlockedThreads(object);
            if (list != null) {
                blockedThreads.addAll(list);
            }
        }
    } else {
        // For consistency we walk the thread list and check for blocking objects
        // rather than do lockword.allBitsIn(OBJECT_HEADER_LOCK_FLC); as the lockword
        // is set slightly later (the thread may spin first). See: CMVC 201473
        List<J9VMThreadPointer> list = getBlockedThreads(object);
        if (list != null) {
            blockedThreads.addAll(list);
        }
    }
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)

Example 3 with J9ThreadPointer

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

the class J9ThreadHelper method getVMThread.

public static J9VMThreadPointer getVMThread(J9ThreadPointer threadPointer) throws CorruptDataException {
    J9VMThreadPointer vmThread = null;
    OMR_VMThreadPointer omrVmThread = OMR_VMThreadPointer.cast(getTLS(threadPointer, J9RASHelper.getVM(DataType.getJ9RASPointer()).omrVM()._vmThreadKey()));
    if (omrVmThread.isNull()) {
        vmThread = J9VMThreadPointer.NULL;
    } else {
        vmThread = J9VMThreadPointer.cast(omrVmThread._language_vmthread());
    }
    return vmThread;
}
Also used : OMR_VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.OMR_VMThreadPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)

Example 4 with J9ThreadPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer 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 5 with J9ThreadPointer

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

the class MonitorsCommand method j9threadCommand.

/**
 * See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
 * function documentation
 *
 * @param args
 *            command args
 * @param out
 *            the output stream
 * @throws DDRInteractiveCommandException
 */
private void j9threadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length < 2) {
        out.println("This command takes one address argument: \"!monitors j9thread <address>\"");
        return;
    }
    try {
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        VoidPointer ptr = VoidPointer.cast(address);
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9VMThreadPointer mainThread = vm.mainThread();
        if (mainThread.isNull() || mainThread.osThread().isNull() || mainThread.osThread().library().isNull()) {
            throw new CorruptDataException("Cannot locate thread library");
        }
        J9ThreadLibraryPointer lib = mainThread.osThread().library();
        J9PoolPointer pool = lib.thread_pool();
        Pool<J9ThreadPointer> threadPool = Pool.fromJ9Pool(pool, J9ThreadPointer.class);
        SlotIterator<J9ThreadPointer> poolIterator = threadPool.iterator();
        J9ThreadPointer osThreadPtr = null;
        while (poolIterator.hasNext()) {
            if (ptr.equals(poolIterator.next())) {
                osThreadPtr = J9ThreadPointer.cast(ptr);
            }
        }
        if (null == osThreadPtr) {
            throw new DDRInteractiveCommandException(String.format("Could not find any j9thread at address %s\n", ptr.getHexAddress()));
        }
        // Is there an associated J9VMThread?
        J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(osThreadPtr);
        // Step 1: Print the general info for the VM and native threads:
        out.println(String.format("%s\t%s\t// %s", osThreadPtr.formatShortInteractive(), vmThread.notNull() ? vmThread.formatShortInteractive() : "<none>", vmThread.notNull() ? J9VMThreadHelper.getName(vmThread) : "[osthread]"));
        printMonitorsForJ9Thread(out, vm, osThreadPtr);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) J9PoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ThreadLibraryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadLibraryPointer)

Aggregations

J9ThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer)13 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)9 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)4 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)4 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)4 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)3 J9ThreadLibraryPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadLibraryPointer)3 J9ThreadMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer)3 SystemMonitor (com.ibm.j9ddr.vm29.j9.SystemMonitor)2 MonitorIterator (com.ibm.j9ddr.vm29.j9.walkers.MonitorIterator)2 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)2 OMR_VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.OMR_VMThreadPointer)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 JavaThread (com.ibm.dtfj.java.JavaThread)1 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)1 J9ContendedLoadTableEntryPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ContendedLoadTableEntryPointer)1 J9HashTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer)1 J9ThreadAbstractMonitorPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)1 HashMap (java.util.HashMap)1