Search in sources :

Example 21 with Pool

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

the class WalkJ9PoolCommand method walkJ9Pool.

/**
 * This method walks through each element in the pool and prints each elements' address.
 * Elements can be in the same puddle or different, and this method do not print puddle information.
 *
 * @param address address of the pool
 * @param out print stream
 * @throws DDRInteractiveCommandException
 */
private void walkJ9Pool(long address, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9PoolPointer j9pool = J9PoolPointer.cast(address);
        Pool pool = Pool.fromJ9Pool(j9pool, VoidPointer.class);
        SlotIterator<VoidPointer> poolIterator = pool.iterator();
        VoidPointer currentElement;
        int i = 0;
        while (poolIterator.hasNext()) {
            currentElement = poolIterator.next();
            out.println(String.format("\t[%d]\t=\t%s", i++, currentElement.getHexAddress()));
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException("Either address is not a valid pool address or pool itself is corrupted.");
    }
}
Also used : J9PoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) Pool(com.ibm.j9ddr.vm29.j9.Pool) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 22 with Pool

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

the class DeadlockDetector method findDeadlocks.

/**
 * @param out
 * @throws DDRInteractiveCommandException
 */
public static void findDeadlocks(PrintStream out) throws DDRInteractiveCommandException {
    // Based on JavaCoreDumpWriter::writeDeadLocks()
    // Modified to work for both J9VMThreads and J9Threads.
    HashMap<Integer, NativeDeadlockGraphNode> map = new HashMap<Integer, NativeDeadlockGraphNode>();
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        HashMap<J9ObjectPointer, Object> objectMonitorsMap = DeadlockUtils.readObjectMonitors(vm);
        J9ThreadLibraryPointer lib = vm.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();
            DeadlockUtils.findThreadCycle(osThreadPtr, map, objectMonitorsMap);
            // Is there an associated J9VMThread?
            J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(osThreadPtr);
            if ((null != vmThread) && (vmThread.notNull()) && vmThread.publicFlags().allBitsIn(J9Consts.J9_PUBLIC_FLAGS_HALT_THREAD_INSPECTION)) {
                break;
            }
        }
        // Identifier for each (independent) cycle.
        int cycle = 0;
        Iterator<Map.Entry<Integer, NativeDeadlockGraphNode>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            NativeDeadlockGraphNode node = iterator.next().getValue();
            cycle++;
            while (null != node) {
                if (node.cycle > 0) {
                    // it means we've looped around!
                    if (node.cycle == cycle) {
                        // Output header for each deadlock:
                        out.println("Deadlock Detected !!!");
                        out.println("---------------------");
                        out.println();
                        NativeDeadlockGraphNode head = node;
                        boolean isCycleRoot = true;
                        do {
                            DeadlockUtils.writeDeadlockNode(node, isCycleRoot, objectMonitorsMap, out);
                            node = node.next;
                            isCycleRoot = false;
                        } while (node != head);
                        out.println(node.toString());
                    }
                    // Skip already visited nodes
                    break;
                } else {
                    node.cycle = cycle;
                }
                node = node.next;
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9ThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadPointer) HashMap(java.util.HashMap) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) J9PoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ThreadLibraryPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadLibraryPointer)

Example 23 with Pool

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

the class DTFJConstantPoolIterator method next.

public Object next() {
    if (hasNext()) {
        Object retval = null;
        if (!EOIObjects) {
            // if there are some more items to retrieve from the pool
            try {
                // register this class for notifications
                register(this);
                // get the next item
                retval = new DTFJJavaObject(poolObjects.next());
                // see if there are any more
                EOIObjects = !poolObjects.hasNext();
            } finally {
                // remove notifier registration
                unregister(this);
            }
            return retval;
        }
        if (!EOIClasses) {
            // if there are some more items to retrieve from the pool
            try {
                // register this class for notifications
                register(this);
                try {
                    // DTFJ returns the java.lang.Class object associated with this class
                    // get the next item
                    retval = new DTFJJavaObject(poolClasses.next().classObject());
                } catch (CorruptDataException e) {
                    // return the corrupt data
                    retval = J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), e);
                }
                // see if there are any more
                EOIClasses = !poolClasses.hasNext();
            } finally {
                // remove notifier registration
                unregister(this);
            }
            return retval;
        }
        if (cdata != null) {
            // there are no more items in the pool
            // but there may be corrupt data items to return
            retval = cdata;
            cdata = null;
        }
        return retval;
    }
    throw new NoSuchElementException("There are no more elements in this iterator");
}
Also used : DTFJJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaObject) DTFJJavaObject(com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaObject) CorruptDataException(com.ibm.j9ddr.CorruptDataException) NoSuchElementException(java.util.NoSuchElementException)

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