Search in sources :

Example 11 with UDATAPointer

use of com.ibm.j9ddr.vm29.pointer.UDATAPointer in project openj9 by eclipse.

the class LinearDumper method getRegionDetailString.

private static Object getRegionDetailString(J9ClassRegion region) throws CorruptDataException {
    VoidPointer srp;
    long slotAddress;
    String returnValue = "";
    switch(region.getType()) {
        case J9_SECTION_START:
            returnValue = String.format(" %5d bytes", region.getLength());
            break;
        case J9_RAM_UTF8:
            UDATAPointer slotPtr = UDATAPointer.cast(region.getSlotPtr());
            if (slotPtr.at(0).longValue() != 0) {
                returnValue = J9ObjectHelper.stringValue(J9ObjectPointer.cast(slotPtr.at(0)));
            }
            break;
        case J9_UTF8:
        case J9_ROM_UTF8:
            returnValue = J9UTF8Helper.stringValue(J9UTF8Pointer.cast(region.getSlotPtr()));
            break;
        case J9_iTableMethod:
            /*
			 * This case is special for the iTableMethod, because their pointers
			 * are related to the beginning of the class and are not absolute
			 */
            AbstractPointer classOffset = region.getSlotPtr().subOffset(region.offset);
            slotAddress = region.getSlotPtr().at(0).longValue();
            classOffset = classOffset.addOffset(slotAddress);
            returnValue = region.additionalInfo + " " + classOffset.getHexAddress();
            break;
        case J9_SRP:
            srp = SelfRelativePointer.cast(region.getSlotPtr()).get();
            if (srp.notNull()) {
                returnValue = " -> " + srp.getHexAddress();
            }
            break;
        case J9_WSRP:
            srp = WideSelfRelativePointer.cast(region.getSlotPtr()).get();
            if (srp.notNull()) {
                returnValue = " -> " + srp.getHexAddress();
            }
            break;
        case J9_SRP_TO_STRING:
            srp = SelfRelativePointer.cast(region.getSlotPtr()).get();
            if (srp.notNull()) {
                returnValue = " -> " + srp.getHexAddress();
                returnValue += " " + J9UTF8Helper.stringValue(J9UTF8Pointer.cast(srp));
            }
            break;
        case J9_Padding:
            returnValue = region.length + " byte(s)";
            break;
        case J9_IntermediateClassData:
            returnValue = region.length + " byte(s) " + region.additionalInfo;
            break;
        default:
            String detail = "";
            slotAddress = region.getSlotPtr().at(0).longValue();
            long slotAddressOriginal = slotAddress;
            if ((null != region.additionalInfo) && (region.additionalInfo.length() != 0)) {
                if ("classAndFlags".equals(region.name) && (UDATA.MASK != slotAddress)) {
                    slotAddress = slotAddress & ~J9JavaAccessFlags.J9StaticFieldRefFlagBits;
                }
                detail += region.additionalInfo + (String.format(" 0x%08X", slotAddress));
                /* For special debug extension, more information is shown */
                if ((0 != slotAddress) && (region.additionalInfo.equals("!j9class"))) {
                    try {
                        detail += " - " + J9UTF8Helper.stringValue(J9ClassPointer.cast(slotAddress).romClass().className());
                        if ("classAndFlags".equals(region.name)) {
                            String flags = "";
                            if (0 != (J9JavaAccessFlags.J9StaticFieldRefBaseType & slotAddressOriginal)) {
                                flags += "J9StaticFieldRefBaseType, ";
                            }
                            if (0 != (J9JavaAccessFlags.J9StaticFieldRefDouble & slotAddressOriginal)) {
                                flags += "J9StaticFieldRefDouble, ";
                            }
                            if (0 != (J9JavaAccessFlags.J9StaticFieldRefVolatile & slotAddressOriginal)) {
                                flags += "J9StaticFieldRefVolatile, ";
                            }
                            /* Check there is any flag or not */
                            if (0 < flags.length()) {
                                /*remove last two chars = ", " */
                                flags = flags.substring(0, flags.length() - 2);
                                detail += "\t Flag(s) = " + flags;
                            }
                        }
                    } catch (Exception e) {
                    /* This is only for information purpose, it is ok if an exception was thrown */
                    }
                }
            }
            returnValue = detail;
    }
    return returnValue;
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 12 with UDATAPointer

use of com.ibm.j9ddr.vm29.pointer.UDATAPointer 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 13 with UDATAPointer

use of com.ibm.j9ddr.vm29.pointer.UDATAPointer 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 14 with UDATAPointer

use of com.ibm.j9ddr.vm29.pointer.UDATAPointer in project openj9 by eclipse.

the class MarkMapCommand method fromBits.

protected void fromBits(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
    UDATAPointer markSlot = UDATAPointer.cast(address);
    UDATAPointer base = markMap.getHeapMapBits();
    UDATA maxOffset = markMap.getSlotIndexAndMask(J9ObjectPointer.cast(markMap.getHeapTop().subOffset(markMap.getObjectGrain())))[0];
    maxOffset = maxOffset.add(1);
    UDATAPointer top = base.add(maxOffset);
    if (markSlot.gte(base) && markSlot.lte(top)) {
        IDATA delta = markSlot.sub(base);
        int pageSize = markMap.getPageSize(null);
        // obviously not right for metronome
        delta = delta.mult(pageSize);
        J9ObjectPointer rangeBase = J9ObjectPointer.cast(markMap.getHeapBase().addOffset(delta));
        J9ObjectPointer rangeTop = rangeBase.addOffset(pageSize);
        out.format("Mark bits at %s corresponds to heap range %s -> %s\n", markSlot.getHexAddress(), rangeBase.getHexAddress(), rangeTop.getHexAddress());
    } else {
        out.format("Address %s is not in the mark map\n", markSlot.getHexAddress());
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) IDATA(com.ibm.j9ddr.vm29.types.IDATA) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 15 with UDATAPointer

use of com.ibm.j9ddr.vm29.pointer.UDATAPointer in project openj9 by eclipse.

the class MarkMapCommand method markBits.

protected void markBits(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        J9ObjectPointer object = J9ObjectPointer.cast(address);
        J9ObjectPointer base = J9ObjectPointer.cast(address).untag(markMap.getPageSize(object) - 1);
        J9ObjectPointer top = base.addOffset(markMap.getPageSize(object));
        MarkedObject[] result = markMap.queryRange(base, top);
        if (result.length > 0) {
            if (result[0].wasRelocated()) {
                out.format("Mark bits for the compacted range %s -> %s: !j9x %s\n", base.getHexAddress(), top.getHexAddress(), result[0].markBitsSlot.getHexAddress());
            } else {
                out.format("Mark bits for the range %s -> %s: !j9x %s\n", base.getHexAddress(), top.getHexAddress(), result[0].markBitsSlot.getHexAddress());
            }
        } else {
            /* Either outside the heap, or just nothing there */
            try {
                UDATA[] indexAndMask = markMap.getSlotIndexAndMask(base);
                UDATAPointer markBitsSlot = markMap.getHeapMapBits().add(indexAndMask[0]);
                out.format("Mark bits for the range %s -> %s: !j9x %s\n", base.getHexAddress(), top.getHexAddress(), markBitsSlot.getHexAddress());
            } catch (IllegalArgumentException ex) {
                out.format("Object %s is not in the heap\n", object.getHexAddress());
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) MarkedObject(com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)16 UDATA (com.ibm.j9ddr.vm29.types.UDATA)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)7 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)6 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)4 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)3 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)2 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)2 StackWalkResult (com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)2 WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)2 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)2 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)2 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)2 J9ROMFieldShapePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer)2 J9VMEntryLocalStoragePointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMEntryLocalStoragePointer)2 U32 (com.ibm.j9ddr.vm29.types.U32)2 ArrayList (java.util.ArrayList)2 J9JavaStackIterator (com.ibm.j9ddr.vm29.j9.J9JavaStackIterator)1 MarkedObject (com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject)1 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)1