Search in sources :

Example 11 with U8Pointer

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

the class J9BCUtil method dumpStackMapTable.

private static void dumpStackMapTable(PrintStream out, J9ROMClassPointer romclass, J9ROMMethodPointer romMethod, long flags) throws CorruptDataException {
    U32Pointer stackMapMethod = ROMHelp.getStackMapFromROMMethod(romMethod);
    U16 stackMapCount;
    U8Pointer stackMapData;
    long mapPC = -1;
    long mapType;
    if (stackMapMethod.notNull()) {
        stackMapData = U8Pointer.cast(stackMapMethod.add(1));
        stackMapCount = new U16(stackMapData.at(0)).leftShift(8).bitOr(stackMapData.at(1));
        stackMapData = stackMapData.add(2);
        out.println("\n  StackMapTable\n    Stackmaps(" + stackMapCount.intValue() + "):");
        for (int i = 0; i < stackMapCount.intValue(); i++) {
            mapPC++;
            mapType = stackMapData.at(0).longValue();
            stackMapData = stackMapData.add(1);
            if (mapType < 64) {
                mapPC += mapType;
                out.println("      pc: " + mapPC + " same");
            } else if (mapType < 128) {
                mapPC += (mapType - 64);
                out.print("      pc: " + mapPC + " same_locals_1_stack_item: ");
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, 1);
                out.println();
            } else if (mapType < 247) {
                out.println("      UNKNOWN FRAME TAG: (" + mapType + ")\n");
            } else if (mapType == 247) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.print("      pc: " + mapPC + " same_locals_1_stack_item_extended: ");
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, 1);
                out.println();
            } else if (mapType < 251) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.println("      pc: " + mapPC + " chop " + (251 - mapType));
            } else if (mapType == 251) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.println("      pc: " + mapPC + " same_extended\n");
            } else if (mapType < 255) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.print("      pc: " + mapPC + " append: ");
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, (mapType - 251));
                out.println();
            } else if (mapType == 255) {
                long offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                mapPC += offset;
                out.print("      pc: " + mapPC + " full, local(s): ");
                offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, offset);
                out.print(", stack: ");
                offset = new U16(stackMapData.at(0)).leftShift(8).add(stackMapData.at(1)).longValue();
                stackMapData = stackMapData.add(2);
                stackMapData = dumpStackMapSlots(out, romclass, stackMapData, offset);
                out.println();
            }
        }
    }
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) U16(com.ibm.j9ddr.vm29.types.U16) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 12 with U8Pointer

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

the class VmCheckCommand method verifyUTF8.

private boolean verifyUTF8(J9UTF8Pointer utf8) throws CorruptDataException {
    if (utf8.isNull()) {
        return false;
    }
    UDATA length = new UDATA(utf8.length());
    U8Pointer utf8Data = utf8.dataEA();
    while (length.longValue() > 0) {
        // not used
        U16 temp = new U16(0);
        U32 lengthRead = decodeUTF8CharN(utf8Data, temp, length);
        if (lengthRead.eq(0)) {
            return false;
        }
        length = length.sub(lengthRead);
        utf8Data = utf8Data.addOffset(lengthRead);
    }
    return true;
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) U32(com.ibm.j9ddr.vm29.types.U32) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) U16(com.ibm.j9ddr.vm29.types.U16)

Example 13 with U8Pointer

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

the class TraceConfigCommand method printActiveTracePoints.

private void printActiveTracePoints(UtModuleInfoPointer modInfo, PrintStream out) throws CorruptDataException {
    int count = modInfo.count().intValue();
    U8Pointer active = modInfo.active();
    String moduleName = moduleName(modInfo);
    for (int i = 0; i < count; i++) {
        long state = active.at(i).longValue();
        if (state != RastraceInternalConstants.UT_NONE || verbose) {
            String stateStr = decodeTraceActivationState(state);
            out.println(moduleName + "." + i + " =" + stateStr);
        }
    }
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 14 with U8Pointer

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

the class StackmapCommand method run.

/**
 *  Java representation of j9dbgext.c#dbgext_stackmap function.
 *
 *  @param  command DDR extension command of stackmap.
 *                  It is supposed to be "stackmap" if this method is being called.
 *  @param  args    Arguments passed to !stackmap DDR extension.
 *                  Only one argument is expected since !stackmap expects only the address.
 *  @param  context Current context that DDR is running on.
 *  @param  out     Print stream to write the output.
 *
 *  @return void
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (null == vm) {
            out.println("vm can not be found.");
        }
        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 remoteMethod = J9JavaVMHelper.getMethodFromPC(vm, pc);
        if (remoteMethod.notNull()) {
            int[] stackMap = new int[MAX_STACKSLOTS_COUNT / INT_SIZE_IN_BITS];
            int leftMostBitIntMask = 1 << (INT_SIZE_IN_BITS - 1);
            CommandUtils.dbgPrint(out, "Found method %s !j9method %s\n", J9MethodHelper.getName(remoteMethod), remoteMethod.getHexAddress());
            UDATA offsetPC = new UDATA(pc.sub(U8Pointer.cast(remoteMethod.bytecodes())));
            CommandUtils.dbgPrint(out, "Relative PC = %d\n", offsetPC.longValue());
            J9ClassPointer localClass = J9_CLASS_FROM_CP(remoteMethod.constantPool());
            long methodIndex = new UDATA(remoteMethod.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());
            /*
				 * This call will return the depth of the stack or errorcode in case of a failure.
				 */
            int errorCode = StackMap.j9stackmap_StackBitsForPC(offsetPC, localClass.romClass(), localROMMethod, null, 0);
            if (0 > errorCode) {
                CommandUtils.dbgPrint(out, "Stack map failed, error code = %d\n", errorCode);
            } else {
                int stackMapIndex = 0;
                if (0 != errorCode) {
                    /* This call to j9stackmap_StackBitsForPC will fill the stackMap */
                    errorCode = StackMap.j9stackmap_StackBitsForPC(offsetPC, localClass.romClass(), localROMMethod, stackMap, errorCode);
                    int currentDescription = stackMap[stackMapIndex];
                    int descriptionInt = 0;
                    CommandUtils.dbgPrint(out, "Stack map (%d slots mapped): ", errorCode);
                    long bitsRemaining = errorCode % INT_SIZE_IN_BITS;
                    if (bitsRemaining != 0) {
                        descriptionInt = currentDescription << (INT_SIZE_IN_BITS - bitsRemaining);
                        currentDescription++;
                    }
                    while (errorCode != 0) {
                        if (bitsRemaining == 0) {
                            descriptionInt = currentDescription;
                            currentDescription = stackMap[++stackMapIndex];
                            bitsRemaining = INT_SIZE_IN_BITS;
                        }
                        CommandUtils.dbgPrint(out, "%d", (descriptionInt & (leftMostBitIntMask)) != 0 ? 1 : 0);
                        descriptionInt = descriptionInt << 1;
                        --bitsRemaining;
                        --errorCode;
                    }
                    CommandUtils.dbgPrint(out, "\n");
                } else {
                    CommandUtils.dbgPrint(out, "Stack is empty\n");
                }
            }
        } else {
            CommandUtils.dbgPrint(out, "Not found\n");
        }
    } catch (CorruptDataException e) {
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 15 with U8Pointer

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

the class VmCheckCommand method decodeUTF8CharN.

/**
 * Decode the UTF8 character.
 *
 * Decode the input UTF8 character and stores it into result.
 *
 * @param[in] input The UTF8 character
 * @param[out] result buffer for unicode characters
 * @param[in] bytesRemaining number of bytes remaining in input
 *
 * @return The number of UTF8 characters consumed (1,2,3) on success, 0 on
 *         failure
 * @throws CorruptDataException
 * @note Don't read more than bytesRemaining characters.
 * @note If morecharacters are required to fully decode the character,
 *       return failure
 */
U32 decodeUTF8CharN(U8Pointer input, /**
 * not used *
 */
U16 result, UDATA bytesRemaining) throws CorruptDataException {
    U8 c;
    U8Pointer cursor = input;
    if (bytesRemaining.longValue() < 1) {
        return new U32(0);
    }
    c = cursor.at(0);
    cursor = cursor.add(1);
    if (c.eq(0x0)) {
        /* illegal NUL encoding */
        return new U32(0);
    } else if ((c.bitAnd(0x80)).eq(0x0)) {
        // *result = (U_16)c;
        return new U32(1);
    } else if (c.bitAnd(0xE0).eq(0xC0)) {
        /* two byte encoding */
        U16 unicodeC;
        if (bytesRemaining.lt(2)) {
            return new U32(0);
        }
        unicodeC = new U16(c.bitAnd(0x1F).leftShift(6));
        c = cursor.at(0);
        cursor = cursor.add(1);
        unicodeC = unicodeC.add(new U16(unicodeC.add(c.bitAnd(0x3F))));
        if (!c.bitAnd(0xC0).eq(0x80)) {
            return new U32(0);
        }
        // *result = unicodeC;
        return new U32(2);
    } else if (c.bitAnd(0xF0).eq(0xE0)) {
        /* three byte encoding */
        U16 unicodeC;
        if (bytesRemaining.lt(3)) {
            return new U32(0);
        }
        unicodeC = new U16(c.bitAnd(0x0F).leftShift(12));
        c = cursor.at(0);
        cursor = cursor.add(1);
        unicodeC = unicodeC.add(new U16(c.bitAnd(0x3F).leftShift(6)));
        if (!c.bitAnd(0xC0).eq(0x80)) {
            return new U32(0);
        }
        c = cursor.at(0);
        cursor = cursor.add(1);
        unicodeC = unicodeC.add(new U16(c.bitAnd(0x3F)));
        if (!c.bitAnd(0xC0).eq(0x80)) {
            return new U32(0);
        }
        // *result = unicodeC;
        return new U32(3);
    } else {
        return new U32(0);
    }
}
Also used : U8(com.ibm.j9ddr.vm29.types.U8) U32(com.ibm.j9ddr.vm29.types.U32) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) U16(com.ibm.j9ddr.vm29.types.U16)

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