Search in sources :

Example 11 with U16

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

use of com.ibm.j9ddr.vm29.types.U16 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)

Aggregations

U16 (com.ibm.j9ddr.vm29.types.U16)8 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)3 U16Pointer (com.ibm.j9ddr.vm29.pointer.U16Pointer)2 U32 (com.ibm.j9ddr.vm29.types.U32)2 U8 (com.ibm.j9ddr.vm29.types.U8)2 CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 LocalVariableTable (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTable)1 LocalVariableTableIterator (com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator)1 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 J9LineNumberPointer (com.ibm.j9ddr.vm29.pointer.generated.J9LineNumberPointer)1 J9MethodDebugInfoPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodDebugInfoPointer)1 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)1 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)1 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)1 J9ROMStringRefPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer)1 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)1