Search in sources :

Example 76 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class DumpSegregatedStatsCommand method getFreeCellCount.

/**
 * Count the number of free cells in the MM_HeapRegionDescriptorSegregatedPointer freelist
 * @throws CorruptDataException
 */
public long getFreeCellCount(MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptor) throws CorruptDataException {
    /* TODO assumes a small region */
    MM_MemoryPoolAggregatedCellListPointer memoryPoolACL = heapRegionDescriptor._memoryPoolACL();
    GCHeapLinkedFreeHeader heapLinkedFreeHeader = GCHeapLinkedFreeHeader.fromLinkedFreeHeaderPointer(memoryPoolACL._freeListHead());
    /* Get the size classes */
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    J9VMGCSizeClassesPointer sizeClasses = vm.realtimeSizeClasses();
    UDATA sizeClassIndex = heapRegionDescriptor._sizeClass();
    long cellSize = sizeClasses.smallCellSizesEA().at(sizeClassIndex).longValue();
    long freeCellCount = 0;
    while (heapLinkedFreeHeader.getHeader().notNull()) {
        freeCellCount += heapLinkedFreeHeader.getSize().longValue() / cellSize;
        heapLinkedFreeHeader = heapLinkedFreeHeader.getNext();
    }
    return freeCellCount;
}
Also used : MM_MemoryPoolAggregatedCellListPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_MemoryPoolAggregatedCellListPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9VMGCSizeClassesPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMGCSizeClassesPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) GCHeapLinkedFreeHeader(com.ibm.j9ddr.vm29.j9.gc.GCHeapLinkedFreeHeader)

Example 77 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA 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 78 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA 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 79 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA 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 80 with UDATA

use of com.ibm.j9ddr.vm29.types.UDATA in project openj9 by eclipse.

the class JitMetadataFromPcCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        UDATA searchValue = new UDATA(Long.decode(args[0]));
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9JITExceptionTablePointer metaData = JITLook.jit_artifact_search(vm.jitConfig().translationArtifacts(), searchValue);
        if (!metaData.isNull()) {
            dbgext_j9jitexceptiontable(out, metaData);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9JITExceptionTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9JITExceptionTablePointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

UDATA (com.ibm.j9ddr.vm29.types.UDATA)86 CorruptDataException (com.ibm.j9ddr.CorruptDataException)22 U32 (com.ibm.j9ddr.vm29.types.U32)16 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)14 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)10 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)10 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)9 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)8 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)8 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)7 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)6 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)5 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)4 U16 (com.ibm.j9ddr.vm29.types.U16)4 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)3 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)3 J9ArrayClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer)3 J9JITExceptionTablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9JITExceptionTablePointer)3 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)3 IDATA (com.ibm.j9ddr.vm29.types.IDATA)3