Search in sources :

Example 36 with U8Pointer

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

the class J9BCUtil method dumpNative.

private static void dumpNative(PrintStream out, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    U8Pointer bytecodes = J9ROMMethodHelper.bytecodes(romMethod);
    long argCount = bytecodes.at(0).longValue();
    U8 returnType = bytecodes.at(1);
    U8Pointer currentDescription = bytecodes.add(2);
    String[] descriptions = new String[] { "void", "boolean", "byte", "char", "short", "float", "int", "double", "long", "object" };
    out.append(String.format("  Argument Count: %d", romMethod.argCount().longValue()));
    out.append(nl);
    out.append(String.format("  Temp Count: %d", romMethod.tempCount().longValue()));
    out.append(nl);
    out.append(String.format("  Native Argument Count: %d, types: (", argCount));
    for (long i = argCount; i > 0; i--) {
        out.append(descriptions[currentDescription.at(0).intValue()]);
        currentDescription = currentDescription.add(1);
        if (i != 1) {
            out.append(",");
        }
    }
    out.append(String.format(") %s ", descriptions[returnType.intValue()]));
    out.append(nl);
}
Also used : U8(com.ibm.j9ddr.vm29.types.U8) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 37 with U8Pointer

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

the class J9BCUtil method dumpMethodDebugInfo.

private static void dumpMethodDebugInfo(PrintStream out, J9ROMClassPointer romClass, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    J9MethodDebugInfoPointer methodInfo;
    if ((flags & J9BCTranslationData.BCT_StripDebugAttributes) == 0) {
        methodInfo = getMethodDebugInfoFromROMMethod(romMethod);
        if (!methodInfo.isNull()) {
            out.append(nl);
            out.append("  Debug Info:");
            out.append(nl);
            out.append(String.format("    Line Number Table (%d):", J9MethodDebugInfoHelper.getLineNumberCount(methodInfo).intValue()));
            out.append(nl);
            LineNumberIterator lineNumberIterator = LineNumberIterator.lineNumberIteratorFor(methodInfo);
            while (lineNumberIterator.hasNext()) {
                LineNumber lineNumber = lineNumberIterator.next();
                if (null == lineNumber) {
                    out.append("      Bad compressed data \n");
                    U8Pointer currentLineNumberPtr = lineNumberIterator.getLineNumberTablePtr();
                    int sizeLeft = J9MethodDebugInfoHelper.getLineNumberCompressedSize(methodInfo).sub((currentLineNumberPtr.sub(J9MethodDebugInfoHelper.getLineNumberTableForROMClass(methodInfo)))).intValue();
                    while (0 < sizeLeft--) {
                        out.append("      " + currentLineNumberPtr.at(0));
                        out.append(nl);
                        currentLineNumberPtr = currentLineNumberPtr.add(1);
                    }
                    break;
                } else {
                    out.append(String.format("      Line: %5d PC: %5d", lineNumber.getLineNumber().longValue(), lineNumber.getLocation().longValue()));
                    out.append(nl);
                }
            }
            out.append(nl);
            out.append(String.format("    Variables (%d):", methodInfo.varInfoCount().longValue()));
            out.append(nl);
            LocalVariableTableIterator variableInfoValuesIterator = LocalVariableTableIterator.localVariableTableIteratorFor(methodInfo);
            while (variableInfoValuesIterator.hasNext()) {
                LocalVariableTable values = variableInfoValuesIterator.next();
                out.append(String.format("      Slot: %d", values.getSlotNumber().intValue()));
                out.append(nl);
                out.append(String.format("      Visibility Start: %d", values.getStartVisibility().intValue()));
                out.append(nl);
                out.append(String.format("      Visibility End: %d", values.getStartVisibility().intValue() + values.getVisibilityLength().intValue()));
                out.append(nl);
                out.append(String.format("      Visibility Length: %d", values.getVisibilityLength().intValue()));
                out.append(nl);
                out.append("      Name: ");
                if ((null != values.getName()) && (!values.getName().isNull())) {
                    out.append(String.format("%s", J9UTF8Helper.stringValue(values.getName())));
                } else {
                    out.append("None");
                }
                out.append(nl);
                out.append("      Signature: ");
                if ((null != values.getSignature()) && (!values.getSignature().isNull())) {
                    out.append(String.format("%s", J9UTF8Helper.stringValue(values.getSignature())));
                } else {
                    out.append("None");
                }
                out.append(nl);
                out.append("      Generic Signature: ");
                if ((null != values.getGenericSignature()) && (!values.getGenericSignature().isNull())) {
                    out.append(String.format("%s", J9UTF8Helper.stringValue(values.getGenericSignature())));
                } else {
                    out.append("None");
                }
                out.append(nl);
            }
        }
    }
}
Also used : LocalVariableTable(com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTable) J9MethodDebugInfoPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodDebugInfoPointer) LineNumberIterator(com.ibm.j9ddr.vm29.j9.walkers.LineNumberIterator) LocalVariableTableIterator(com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) LineNumber(com.ibm.j9ddr.vm29.j9.walkers.LineNumber)

Example 38 with U8Pointer

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

the class J9BCUtil method dumpStackMapSlots.

static U8Pointer dumpStackMapSlots(PrintStream out, J9ROMClassPointer classfile, U8Pointer slotData, long slotCount) throws CorruptDataException {
    int slotType;
    String[] slotTypes = { "top", "int", "float", "double", "long", "null", "uninitialized_this" };
    String[] primitiveArrayTypes = { "I", "F", "D", "J", "S", "B", "C", "Z" };
    out.print("(");
    for (int i = 0; i < slotCount; i++) {
        slotType = slotData.at(0).intValue();
        slotData = slotData.add(1);
        if (slotType <= 0x06) /*FR_STACKMAP_TYPE_INIT_OBJECT*/
        {
            out.print(slotTypes[slotType]);
        } else if (slotType == 0x07) /* CFR_STACKMAP_TYPE_OBJECT */
        {
            long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
            J9ROMConstantPoolItemPointer constantPool = ConstantPoolHelpers.J9_ROM_CP_FROM_ROM_CLASS(classfile);
            J9ROMStringRefPointer item = J9ROMStringRefPointer.cast(constantPool.add(index));
            J9UTF8Pointer data = item.utf8Data();
            String s = J9UTF8Helper.stringValue(data);
            if (s.charAt(0) != '[') {
                out.print("L");
            }
            out.print(s);
            slotData = slotData.add(2);
        } else if (slotType == 0x08) /* CFR_STACKMAP_TYPE_NEW_OBJECT */
        {
            long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
            out.print("this pc:" + index);
            slotData = slotData.add(2);
        } else {
            /* J9-ism: primitive array types start at slotType 9 and arity is really NEXT_U16()+1*/
            StringBuffer primitiveType = new StringBuffer("[");
            long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
            while (index-- > 0) {
                primitiveType.append("[");
            }
            primitiveType.append(primitiveArrayTypes[slotType - 9]);
            out.print(primitiveType.toString());
            slotData = slotData.add(2);
        }
        if (i != (slotCount - 1)) {
            out.print(", ");
        }
    }
    out.print(")");
    return slotData;
}
Also used : J9ROMConstantPoolItemPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer) J9ROMStringRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer) U16(com.ibm.j9ddr.vm29.types.U16) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)

Example 39 with U8Pointer

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

the class StackWalkCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        UDATAPointer sp = UDATAPointer.NULL;
        UDATAPointer arg0EA = UDATAPointer.NULL;
        U8Pointer pc = U8Pointer.NULL;
        J9MethodPointer literals = J9MethodPointer.NULL;
        J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
        String[] realArgs = null;
        if (args.length != 0) {
            realArgs = args[0].split(",");
        }
        if (args.length == 0 || !((realArgs.length == 1) || (realArgs.length == 5) || (realArgs.length == 6))) {
            CommandUtils.dbgPrint(out, "Usage:\n");
            CommandUtils.dbgPrint(out, "\t!stack thread\n");
            CommandUtils.dbgPrint(out, "\t!stack thread,sp,a0,pc,literals\n");
            CommandUtils.dbgPrint(out, "\t!stack thread,sp,a0,pc,literals,els\n");
            CommandUtils.dbgPrint(out, "\tUse !stackslots instead of !stack to see slot values\n");
            if (J9BuildFlags.interp_nativeSupport) {
                CommandUtils.dbgPrint(out, "\tUse !jitstack or !jitstackslots to start the walk at a JIT frame\n");
            }
            // dbgPrintRegisters(1);
            return;
        }
        long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
        if (0 == address) {
            /* Parse error is captured in CommandUtils.parsePointer method and message is printed */
            return;
        }
        J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
        StackWalkerUtils.enableVerboseLogging(3, out);
        WalkState walkState = new WalkState();
        walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
        if (realArgs.length >= 5) {
            address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
            sp = UDATAPointer.cast(address);
            address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
            arg0EA = UDATAPointer.cast(address);
            address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
            pc = U8Pointer.cast(address);
            address = CommandUtils.parsePointer(realArgs[4], J9BuildFlags.env_data64);
            literals = J9MethodPointer.cast(address);
        } else {
            sp = thread.sp();
            arg0EA = thread.arg0EA();
            pc = thread.pc();
            literals = thread.literals();
        }
        if (realArgs.length >= 6) {
            address = CommandUtils.parsePointer(realArgs[5], J9BuildFlags.env_data64);
            entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
        } else {
            if (J9BuildFlags.interp_nativeSupport) {
                entryLocalStorage = thread.entryLocalStorage();
            }
        }
        if (command.equalsIgnoreCase("!stackslots")) {
            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.callBacks = new BaseStackWalkerCallbacks();
        } else {
            StackWalkerUtils.enableVerboseLogging(0, out);
            walkState.callBacks = new TerseStackWalkerCallbacks();
            walkState.flags |= J9_STACKWALK_ITERATE_FRAMES;
        }
        walkState.walkThread = thread;
        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) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) TerseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.TerseStackWalkerCallbacks) J9VMEntryLocalStoragePointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMEntryLocalStoragePointer)

Example 40 with U8Pointer

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

the class VmCheckCommand method verifyAddressInSegment.

private void verifyAddressInSegment(PrintStream out, J9JavaVMPointer vm, J9MemorySegmentPointer segment, long address, String description) throws CorruptDataException {
    U8Pointer heapBase = segment.heapBase();
    U8Pointer heapAlloc = segment.heapAlloc();
    if (address < heapBase.getAddress() || (address >= heapAlloc.getAddress())) {
        reportError(out, "address 0x%s (%s) not in segment [heapBase=0x%s, heapAlloc=0x%s]", address, description, Long.toHexString(heapBase.getAddress()), Long.toHexString(heapAlloc.getAddress()));
    }
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Aggregations

U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)37 CorruptDataException (com.ibm.j9ddr.CorruptDataException)11 UDATA (com.ibm.j9ddr.vm29.types.UDATA)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)8 U32 (com.ibm.j9ddr.vm29.types.U32)8 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)7 U8 (com.ibm.j9ddr.vm29.types.U8)7 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)5 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)5 U16 (com.ibm.j9ddr.vm29.types.U16)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)4 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)4 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)3 WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)3 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)3 CorruptData (com.ibm.dtfj.image.CorruptData)2 StackWalkResult (com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)2 LocalVariableTable (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTable)2 LocalVariableTableIterator (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator)2 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)2