Search in sources :

Example 6 with Pool

use of com.ibm.j9ddr.vm29.j9.Pool 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 7 with Pool

use of com.ibm.j9ddr.vm29.j9.Pool 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)

Example 8 with Pool

use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.

the class MonitorsCommand method threadCommand.

/**
 * Dumps all monitors that are active for the specified J9Thread/J9VMThread/java.lang.Thread
 * @param args
 * @param out
 * @throws DDRInteractiveCommandException
 */
private void threadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length < 2) {
        out.println("This command takes one address argument: \"!monitors thread <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();
        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()) {
            osThreadPtr = poolIterator.next();
            // Is there an associated J9VMThread?
            J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(osThreadPtr);
            J9ObjectPointer jlThread = null;
            if (vmThread.notNull()) {
                jlThread = vmThread.threadObject();
                if ((null != jlThread) && jlThread.equals(ptr)) {
                    out.println("Found java/lang/Thread @ " + ptr.getHexAddress());
                    printMonitorsForJ9VMThread(out, vm, vmThread);
                    return;
                } else if (vmThread.equals(ptr)) {
                    out.println("Found j9vmthread @ " + ptr.getHexAddress());
                    printMonitorsForJ9VMThread(out, vm, vmThread);
                    return;
                }
            }
            if (osThreadPtr.equals(ptr)) {
                out.println("Found j9thread @ " + ptr.getHexAddress());
                if (vmThread.notNull()) {
                    printMonitorsForJ9VMThread(out, vm, vmThread);
                }
                printMonitorsForJ9Thread(out, vm, osThreadPtr);
                return;
            }
        }
    } 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) J9ThreadLibraryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadLibraryPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 9 with Pool

use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.

the class VmCheckCommand method checkJ9MethodSanity.

/*
	 *  Based on vmchk/checkmethods.c r1.5
	 * 
	 *	J9Method sanity:
	 *		Bytecode check:
	 *			Ensure (bytecodes - sizeof(J9ROMMethod) is in the right "area" to be a ROM Method.
	 *			Use ROMClass to determine where ROM methods for that class begin.
	 *		Constant pool check:
	 *			Ensure method's constant pool is the same as that of its J9Class.
	 *			Useful to validate that HCR doesn't violate this invariant.
	 *		VTable check:
	 *			If method of a non-interface class has modifier J9AccMethodVTable,
	 *			ensure it exists in the VTable of its J9Class.
	 *			Useful to validate that HCR doesn't violate this invariant.
	 */
private void checkJ9MethodSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
    reportMessage(out, "Checking methods");
    // Stolen from RootScaner.scanClasses()
    // GCClassLoaderIterator gcClassLoaderIterator =
    // GCClassLoaderIterator.from();
    GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    int count = 0;
    while (segmentIterator.hasNext()) {
        J9MemorySegmentPointer segment = segmentIterator.next();
        GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
        while (classHeapIterator.hasNext()) {
            J9ClassPointer clazz = classHeapIterator.next();
            if (!J9ClassHelper.isObsolete(clazz)) {
                count += verifyClassMethods(vm, out, clazz);
            }
        }
    }
    reportMessage(out, "Checking %d methods done", count);
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) GCClassHeapIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator) GCSegmentIterator(com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)

Example 10 with Pool

use of com.ibm.j9ddr.vm29.j9.Pool in project openj9 by eclipse.

the class DTFJJavaClass method addConstantPoolReferences.

@SuppressWarnings("rawtypes")
private JavaReference addConstantPoolReferences(List<Object> references) {
    // get the Constant Pool references from this class.
    JavaReference jRef = null;
    Iterator constantPoolIt = getConstantPoolReferences();
    try {
        while (constantPoolIt.hasNext()) {
            // get each reference in turn, note that the iterator can return JavaClass
            // JavaObject and CorruptData. The CorruptData objects are ignored.
            Object cpObject = constantPoolIt.next();
            if (cpObject instanceof JavaObject) {
                // add the reference to the container.
                jRef = new DTFJJavaReference(this, cpObject, "Constant Pool Object", JavaReference.REFERENCE_CONSTANT_POOL, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
            } else if (cpObject instanceof JavaClass) {
                // add the reference to the container.
                jRef = new DTFJJavaReference(this, cpObject, "Constant Pool Class", JavaReference.REFERENCE_CONSTANT_POOL, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
            }
            if (null != jRef) {
                references.add(jRef);
            }
        }
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        references.add(cd);
    }
    return jRef;
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) J9ObjectFieldOffsetIterator(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffsetIterator) DTFJConstantPoolIterator(com.ibm.j9ddr.vm29.view.dtfj.java.j9.DTFJConstantPoolIterator) J9DDRDTFJUtils.corruptIterator(com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) J9Object(com.ibm.j9ddr.vm29.structure.J9Object) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)13 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)6 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)6 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)5 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)5 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)5 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)4 J9ThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer)4 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)3 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)3 J9ThreadLibraryPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ThreadLibraryPointer)3 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)2 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)2 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)2 J9HashTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer)2 U32 (com.ibm.j9ddr.vm29.types.U32)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 CorruptData (com.ibm.dtfj.image.CorruptData)1 JavaClass (com.ibm.dtfj.java.JavaClass)1 JavaObject (com.ibm.dtfj.java.JavaObject)1