Search in sources :

Example 61 with DDRInteractiveCommandException

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

the class DumpSegmentsInListCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        J9MemorySegmentListPointer list = J9MemorySegmentListPointer.cast(address);
        SegmentsUtil.dbgDumpSegmentList(out, list);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9MemorySegmentListPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentListPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 62 with DDRInteractiveCommandException

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

the class JitstackCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (!J9BuildFlags.interp_nativeSupport) {
        CommandUtils.dbgPrint(out, "No JIT in this build\n");
        return;
    }
    try {
        String[] realArgs = null;
        if (args.length != 0) {
            realArgs = args[0].split(",");
        }
        if (args.length == 0 || !((realArgs.length == 3) || (realArgs.length == 4))) {
            CommandUtils.dbgPrint(out, "Usage:\n");
            CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc\n");
            CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc,els\n");
            CommandUtils.dbgPrint(out, "\tUse !jitstackslots instead of !jitstack to see slot values\n");
            return;
        }
        long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
        J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
        StackWalkerUtils.enableVerboseLogging(2, out);
        WalkState walkState = new WalkState();
        address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
        UDATAPointer sp = UDATAPointer.cast(address);
        address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
        U8Pointer pc = U8Pointer.cast(address);
        UDATAPointer arg0EA = UDATAPointer.NULL;
        J9MethodPointer literals = J9MethodPointer.NULL;
        J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
        if (realArgs.length == 4) {
            address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
            entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
        } else {
            entryLocalStorage = thread.entryLocalStorage();
        }
        walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
        walkState.flags |= J9_STACKWALK_START_AT_JIT_FRAME;
        if (command.equalsIgnoreCase("!jitstackslots")) {
            walkState.flags |= J9_STACKWALK_ITERATE_O_SLOTS;
            // 100 is highly arbitrary but basically means "print everything".
            // It is used in jextract where the message levels have been copied
            // from to begin with, so it should mean we get the same output.
            StackWalkerUtils.enableVerboseLogging(100, out);
        }
        walkState.walkThread = thread;
        walkState.callBacks = new BaseStackWalkerCallbacks();
        walkState.frameFlags = new UDATA(0);
        StackWalkResult result = StackWalker.walkStackFrames(walkState, sp, arg0EA, pc, literals, entryLocalStorage);
        if (result != StackWalkResult.NONE) {
            out.println("Stack walk result: " + result);
        }
        StackWalkerUtils.disableVerboseLogging();
        out.flush();
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) StackWalkResult(com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) J9VMEntryLocalStoragePointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMEntryLocalStoragePointer)

Example 63 with DDRInteractiveCommandException

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

the class LocalMapCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        if (args.length != 1) {
            CommandUtils.dbgPrint(out, "bad or missing PC\n");
            return;
        }
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        U8Pointer pc = U8Pointer.cast(address);
        CommandUtils.dbgPrint(out, "Searching for PC=%d in VM=%s...\n", pc.longValue(), vm.getHexAddress());
        J9MethodPointer localMethod = J9JavaVMHelper.getMethodFromPC(vm, pc);
        if (localMethod.notNull()) {
            int[] localMap = new int[65536 / 32];
            CommandUtils.dbgPrint(out, "Found method %s !j9method %s\n", J9MethodHelper.getName(localMethod), localMethod.getHexAddress());
            UDATA offsetPC = new UDATA(pc.sub(U8Pointer.cast(localMethod.bytecodes())));
            CommandUtils.dbgPrint(out, "Relative PC = %d\n", offsetPC.longValue());
            J9ClassPointer localClass = J9_CLASS_FROM_CP(localMethod.constantPool());
            long methodIndex = new UDATA(localMethod.sub(localClass.ramMethods())).longValue();
            CommandUtils.dbgPrint(out, "Method index is %d\n", methodIndex);
            J9ROMMethodPointer localROMMethod = J9ROMCLASS_ROMMETHODS(localClass.romClass());
            while (methodIndex != 0) {
                localROMMethod = ROMHelp.nextROMMethod(localROMMethod);
                --methodIndex;
            }
            CommandUtils.dbgPrint(out, "Using ROM method %s\n", localROMMethod.getHexAddress());
            U16 tempCount = localROMMethod.tempCount();
            U8 argCount = localROMMethod.argCount();
            long localCount = tempCount.add(argCount).longValue();
            if (localCount > 0) {
                int errorCode = LocalMap.j9localmap_LocalBitsForPC(localROMMethod, offsetPC, localMap);
                if (errorCode != 0) {
                    CommandUtils.dbgPrint(out, "Local map failed, error code = %d\n", errorCode);
                } else {
                    int currentDescription = localMap[(int) ((localCount + 31) / 32)];
                    long descriptionLong = 0;
                    CommandUtils.dbgPrint(out, "Local map (%d slots mapped): local %d --> ", localCount, localCount - 1);
                    long bitsRemaining = localCount % 32;
                    if (bitsRemaining != 0) {
                        descriptionLong = currentDescription << (32 - bitsRemaining);
                        currentDescription--;
                    }
                    while (localCount != 0) {
                        if (bitsRemaining == 0) {
                            descriptionLong = currentDescription;
                            currentDescription--;
                            bitsRemaining = 32;
                        }
                        CommandUtils.dbgPrint(out, "%d", (descriptionLong & (1 << 32)) != 0 ? 1 : 0);
                        descriptionLong = descriptionLong << 1;
                        --bitsRemaining;
                        --localCount;
                    }
                    CommandUtils.dbgPrint(out, " <-- local 0\n");
                }
            } else {
                CommandUtils.dbgPrint(out, "No locals to map\n");
            }
        } else {
            CommandUtils.dbgPrint(out, "Not found\n");
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : U8(com.ibm.j9ddr.vm29.types.U8) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) U16(com.ibm.j9ddr.vm29.types.U16)

Example 64 with DDRInteractiveCommandException

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

the class ITableSizeCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long currentSize = 0;
    long duplicatedSize = 0;
    long extendedSize = 0;
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer clazz = (J9ClassPointer) classSegmentIterator.next();
            int classDepth = clazz.classDepthAndFlags().bitAnd(J9_JAVA_CLASS_DEPTH_MASK).intValue();
            J9ITablePointer superITable = J9ITablePointer.NULL;
            J9ITablePointer startITable = J9ITablePointer.cast(clazz.iTable());
            if (0 != classDepth) {
                PointerPointer superclasses = clazz.superclasses();
                J9ClassPointer superclazz = J9ClassPointer.cast(superclasses.at(classDepth - 1));
                superITable = J9ITablePointer.cast(superclazz.iTable());
            }
            currentSize += iTableChainSize(startITable, superITable);
            duplicatedSize += iTableChainSize(superITable, J9ITablePointer.NULL);
            extendedSize += iTableExtendedSize(startITable, superITable);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    long totalSize = duplicatedSize + currentSize;
    double percent = (double) totalSize / (double) currentSize;
    out.append("iTable duplication" + nl);
    out.append("------------------" + nl);
    out.append("current    iTable size : " + currentSize + nl);
    out.append("additional iTable size : " + duplicatedSize + nl);
    out.append("total      iTable size : " + totalSize + nl);
    out.append("growth factor          : " + percent + nl);
    out.append(nl);
    percent = (double) extendedSize / (double) currentSize;
    out.append("iTable contains extends" + nl);
    out.append("-----------------------" + nl);
    out.append("current    iTable size : " + currentSize + nl);
    out.append("new        iTable size : " + extendedSize + nl);
    out.append("growth factor          : " + percent + nl);
    out.append(nl);
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 65 with DDRInteractiveCommandException

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

the class J9ClassShapeCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        CommandUtils.dbgPrint(out, "Usage: !j9classshape <classAddress>\n");
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9ClassPointer instanceClass = J9ClassPointer.NULL;
        String classSelector = args[0];
        if (classSelector.matches("\\p{Digit}.*")) {
            /* addresses start with a decimal digit, possibly the '0' in "0x" */
            instanceClass = J9ClassPointer.cast(CommandUtils.parsePointer(classSelector, J9BuildFlags.env_data64));
        } else {
            J9ClassPointer[] candidates = findClassByName(vm, classSelector);
            if (candidates.length == 0) {
                CommandUtils.dbgPrint(out, "No classes matching \"" + classSelector + "\" found\n");
                return;
            } else if (candidates.length > 1) {
                CommandUtils.dbgPrint(out, "Multiple classes matching \"" + classSelector + "\" found\n");
                return;
            } else {
                instanceClass = candidates[0];
                String javaName = J9ClassHelper.getJavaName(instanceClass);
                String hexString = instanceClass.getHexAddress();
                CommandUtils.dbgPrint(out, String.format("!j9class %1$s\n", hexString));
            }
        }
        J9ClassPointer previousSuperclass = J9ClassPointer.NULL;
        String className = J9ClassHelper.getName(instanceClass);
        J9VMThreadPointer mainThread = vm.mainThread();
        boolean lockwordPrinted = true;
        if (J9BuildFlags.thr_lockNursery) {
            lockwordPrinted = false;
        }
        CommandUtils.dbgPrint(out, "Instance fields in %s:\n", className);
        CommandUtils.dbgPrint(out, "\noffset     name\tsignature\t(declaring class)\n");
        if (mainThread.isNull()) {
            /* we cannot print the instance fields without this */
            return;
        }
        long depth = J9ClassHelper.classDepth(instanceClass).longValue();
        for (long superclassIndex = 0; superclassIndex <= depth; superclassIndex++) {
            J9ClassPointer superclass;
            if (superclassIndex == depth) {
                superclass = instanceClass;
            } else {
                superclass = J9ClassPointer.cast(instanceClass.superclasses().at(superclassIndex));
            }
            U32 flags = new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_INCLUDE_HIDDEN);
            Iterator<J9ObjectFieldOffset> iterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(superclass.romClass(), instanceClass, previousSuperclass, flags);
            while (iterator.hasNext()) {
                J9ObjectFieldOffset result = (J9ObjectFieldOffset) iterator.next();
                boolean printField = true;
                boolean isHiddenField = result.isHidden();
                if (J9BuildFlags.thr_lockNursery) {
                    boolean isLockword = (isHiddenField && (result.getOffsetOrAddress().add(J9Object.SIZEOF).eq(superclass.lockOffset())));
                    if (isLockword) {
                        /*
							 * Print the lockword field if it is indeed the
							 * lockword for this instanceClass and we haven't
							 * printed it yet.
							 */
                        printField = !lockwordPrinted && instanceClass.lockOffset().eq(superclass.lockOffset());
                        if (printField) {
                            lockwordPrinted = true;
                        }
                    }
                }
                if (printField) {
                    printShapeField(out, superclass, result.getField(), result.getOffsetOrAddress(), isHiddenField);
                }
            }
            previousSuperclass = superclass;
        }
        CommandUtils.dbgPrint(out, "\nTotal instance size: %d\n", instanceClass.totalInstanceSize().longValue());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) PatternString(com.ibm.j9ddr.util.PatternString) 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