Search in sources :

Example 56 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class DumpAllClassloadersCommand method run.

/**
 * Run method for !dumpallclassloaders extension.
 *
 * @param command  !dumpallclassloaders
 * @param args	!dumpallclassloaders extension accepts no args
 * @param context Context
 * @param out PrintStream
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 0) {
        printUsage(out);
        return;
    }
    try {
        if (J9BuildFlags.env_data64) {
            out.append("+------------------------------------------------------------------------- \n");
            out.append("|    ClassLoader    | SharedLibraries | ClassHashTable  |   jniIDs Pool   |\n");
            out.append("|                   |      Pool       |                 |                 |\n");
            out.append("|                   |-----------------+-----------------+-----------------| \n");
            out.append("|      Address      | used | capacity | used | capacity | used | capacity |\n");
            out.append("+-------------------+-----------------+-----------------+----------------- \n");
        } else {
            out.append("+----------------------------------------------------------------- \n");
            out.append("|ClassLoader| SharedLibraries | ClassHashTable  |   jniIDs Pool   |\n");
            out.append("|           |      Pool       |                 |                 |\n");
            out.append("|           |-----------------+-----------------+-----------------| \n");
            out.append("| Address   | used | capacity | used | capacity | used | capacity |\n");
            out.append("+-----------+-----------------+-----------------+----------------- \n");
        }
        GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
        J9ClassLoaderPointer classLoaderPointer;
        String classLoaderAddress;
        long sharedLibPoolNumOfelements;
        long sharedLibPoolCapacity;
        long classHashTableNumOfelements;
        long classHashTableCapacity;
        long jniIDsPoolNumOfelements;
        long jniIDsPoolCapacity;
        while (iterator.hasNext()) {
            classLoaderPointer = iterator.next();
            classLoaderAddress = classLoaderPointer.getHexAddress();
            J9PoolPointer sharedLibraries = classLoaderPointer.sharedLibraries();
            if (!sharedLibraries.isNull()) {
                Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(sharedLibraries, J9PoolPuddlePointer.class);
                sharedLibPoolNumOfelements = pool.numElements();
                sharedLibPoolCapacity = pool.capacity();
            } else {
                sharedLibPoolNumOfelements = 0;
                sharedLibPoolCapacity = 0;
            }
            J9HashTablePointer classHashTable = classLoaderPointer.classHashTable();
            if (!classHashTable.isNull()) {
                if (!classHashTable.listNodePool().isNull()) {
                    J9PoolPointer listNodePool = classHashTable.listNodePool();
                    Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(listNodePool, J9PoolPuddlePointer.class);
                    classHashTableNumOfelements = pool.numElements();
                    classHashTableCapacity = pool.capacity();
                } else {
                    classHashTableNumOfelements = classHashTable.numberOfNodes().longValue();
                    classHashTableCapacity = classHashTable.tableSize().longValue();
                }
            } else {
                classHashTableNumOfelements = 0;
                classHashTableCapacity = 0;
            }
            J9PoolPointer jniIDs = classLoaderPointer.jniIDs();
            if (!jniIDs.isNull()) {
                Pool<J9PoolPuddlePointer> pool = Pool.fromJ9Pool(jniIDs, J9PoolPuddlePointer.class);
                jniIDsPoolNumOfelements = pool.numElements();
                jniIDsPoolCapacity = pool.capacity();
            } else {
                jniIDsPoolNumOfelements = 0;
                jniIDsPoolCapacity = 0;
            }
            String output = format(classLoaderAddress, sharedLibPoolNumOfelements, sharedLibPoolCapacity, classHashTableNumOfelements, classHashTableCapacity, jniIDsPoolNumOfelements, jniIDsPoolCapacity);
            out.println(output);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9PoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer) GCClassLoaderIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9HashTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer) J9PoolPuddlePointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPuddlePointer)

Example 57 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class FindStackValueCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (0 == args.length) {
        out.println("Usage error: Missing stackvalue to search for. See usage.");
        printUsage(out);
        return;
    } else if (1 < args.length) {
        out.println("Usage error: Too many stackvalues to search for. See usage.");
        printUsage(out);
        return;
    }
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        UDATAPointer value = UDATAPointer.cast(address);
        GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
        while (gcvmThreadListIterator.hasNext()) {
            J9VMThreadPointer vmThreadPointer = gcvmThreadListIterator.next();
            J9JavaStackPointer javaStackPointer = vmThreadPointer.stackObject();
            J9JavaStackIterator javaStackIterator = J9JavaStackIterator.fromJ9JavaStack(javaStackPointer);
            boolean found = false;
            UDATA relativeSP = new UDATA(javaStackPointer.end().sub(vmThreadPointer.sp()));
            while (javaStackIterator.hasNext()) {
                J9JavaStackPointer stack = javaStackIterator.next();
                UDATAPointer localEnd = stack.end().sub(1).add(1);
                UDATAPointer search = localEnd.sub(relativeSP);
                while (!search.eq(localEnd)) {
                    if (search.at(0).longValue() == value.longValue()) {
                        if (!found) {
                            out.append(String.format("!j9vmthread %s\n", Long.toHexString(vmThreadPointer.getAddress())));
                            found = true;
                        }
                        out.append(String.format("\tFound at %s\n", Long.toHexString(search.getAddress())));
                    }
                    search = search.add(1);
                }
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) J9JavaStackIterator(com.ibm.j9ddr.vm29.j9.J9JavaStackIterator) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 58 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class ClassForNameCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
        int hitCount = 0;
        String searchClassName = args[0];
        PatternString pattern = new PatternString(searchClassName);
        out.println(String.format("Searching for classes named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
        while (iterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
            String javaName = J9ClassHelper.getJavaName(classPointer);
            if (pattern.isMatch(javaName)) {
                hitCount++;
                String hexString = classPointer.getHexAddress();
                out.println(String.format("!j9class %1$s named %2$s", hexString, javaName));
            }
        }
        out.println(String.format("Found %1$d class(es) named %2$s", hitCount, searchClassName));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 59 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class HashCodeCommand method run.

public void run(String command, String[] args, Context context, final PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        throw new DDRInteractiveCommandException("This debug extension needs a single address argument: !hashcode <object addr>");
    }
    long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
    final J9ObjectPointer objectPointer = J9ObjectPointer.cast(address);
    try {
        J9ClassPointer clazz = J9ObjectHelper.clazz(objectPointer);
        if (!J9ClassHelper.hasValidEyeCatcher(clazz)) {
            throw new DDRInteractiveCommandException("object class is not valid (eyecatcher is not 0x99669966)");
        }
    } catch (CorruptDataException cde) {
        throw new DDRInteractiveCommandException("memory fault de-referencing address argument", cde);
    }
    try {
        out.println(ObjectModel.getObjectHashCode(objectPointer).getHexValue());
    } catch (CorruptDataException cde) {
        throw new DDRInteractiveCommandException("error calculating hashcode", cde);
    }
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 60 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class DumpRamClassLinearCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0)
        throw new DDRInteractiveCommandException("This debug extension needs an address argument !dumpramclasslinear <addr>[,n]");
    String[] arguments = args[0].split(",");
    long addr = Long.decode(arguments[0]);
    long nestingThreshold;
    if (arguments.length > 1) {
        nestingThreshold = Long.decode(arguments[1]);
    } else {
        nestingThreshold = 1;
    }
    J9ClassPointer clazz = J9ClassPointer.cast(addr);
    try {
        out.println(String.format("RAM Class '%s' at %s", J9UTF8Helper.stringValue(clazz.romClass().className()), clazz.getHexAddress()));
        ClassWalker classWalker = new RamClassWalker(clazz, context);
        new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreshold);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RamClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker) RamClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)86 CorruptDataException (com.ibm.j9ddr.CorruptDataException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)38 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)16 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)16 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)16 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)11 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)6 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)6 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)6 PatternString (com.ibm.j9ddr.util.PatternString)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)5 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)5 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)4 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)4