Search in sources :

Example 41 with J9ROMClassPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer 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 42 with J9ROMClassPointer

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

the class J9BCUtil method dumpCPShapeDescription.

private static void dumpCPShapeDescription(PrintStream out, J9ROMClassPointer romClass, long flags) throws CorruptDataException {
    U32Pointer cpDescription = romClass.cpShapeDescription();
    long descriptionLong;
    long i, j, k, numberOfLongs;
    char[] symbols = new char[] { '.', 'C', 'S', 'I', 'F', 'J', 'D', 'i', 's', 'v', 'x', 'y', 'z', 'T', 'H', 'A', 'x', 'v' };
    symbols[(int) J9CPTYPE_UNUSED8] = '.';
    numberOfLongs = (romClass.romConstantPoolCount().longValue() + J9ConstantPool.J9_CP_DESCRIPTIONS_PER_U32 - 1) / J9ConstantPool.J9_CP_DESCRIPTIONS_PER_U32;
    out.append("CP Shape Description:" + nl);
    k = romClass.romConstantPoolCount().longValue();
    for (i = 0; i < numberOfLongs; i++) {
        out.append("  ");
        descriptionLong = cpDescription.at(i).longValue();
        for (j = 0; j < J9ConstantPool.J9_CP_DESCRIPTIONS_PER_U32; j++, k--) {
            if (k == 0)
                break;
            out.append(String.format("%c ", symbols[(int) (descriptionLong & J9ConstantPool.J9_CP_DESCRIPTION_MASK)]));
            descriptionLong >>= J9ConstantPool.J9_CP_BITS_PER_DESCRIPTION;
        }
        out.append(nl);
    }
    out.append(nl);
}
Also used : U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 43 with J9ROMClassPointer

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

the class QueryRomClassCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printUsage(out);
        return;
    }
    try {
        String[] queries = args[0].split(",");
        long address = CommandUtils.parsePointer(queries[0], J9BuildFlags.env_data64);
        J9ROMClassPointer romClass = J9ROMClassPointer.cast(address);
        queries[0] = "";
        ClassWalker classWalker = new RomClassWalker(romClass, context);
        LinearDumper linearDumper = new LinearDumper();
        J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
        for (String query : queries) {
            if (query.length() != 0) {
                queryROMClass(out, romClass, query, allRegionsNode);
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9ClassRegionNode(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 44 with J9ROMClassPointer

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

the class VmCheckCommand method verifyClassMethods.

private int verifyClassMethods(J9JavaVMPointer vm, PrintStream out, J9ClassPointer clazz) throws CorruptDataException {
    int count = 0;
    J9ROMClassPointer romClass = clazz.romClass();
    int methodCount = romClass.romMethodCount().intValue();
    J9MethodPointer methods = clazz.ramMethods();
    boolean isInterfaceClass = J9ROMClassHelper.isInterface(romClass);
    J9ConstantPoolPointer ramConstantPool = J9ConstantPoolPointer.cast(clazz.ramConstantPool());
    for (int i = 0; i < methodCount; i++) {
        J9MethodPointer method = methods.add(i);
        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(method);
        boolean methodInVTable = J9ROMMethodHelper.hasVTable(romMethod);
        if (!findROMMethodInClass(vm, romClass, romMethod, methodCount)) {
            reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in romClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(romClass.getAddress()));
        }
        if (!isInterfaceClass && methodInVTable) {
            if (!findMethodInVTable(method, clazz)) {
                reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in vTable of ramClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(clazz.getAddress()));
            }
        }
        if (!ramConstantPool.eq(ConstantPoolHelpers.J9_CP_FROM_METHOD(method))) {
            reportError(out, "ramConstantPool=0x%s on ramMethod=0x%s not equal to ramConstantPool=0x%s on ramClass=0x%s", Long.toHexString(ConstantPoolHelpers.J9_CP_FROM_METHOD(method).getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(ramConstantPool.getAddress()), Long.toHexString(clazz.getAddress()));
        }
        count++;
    }
    return count;
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)

Example 45 with J9ROMClassPointer

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

the class VMConstantPoolCommand method run.

/**
 * Run method for !vmconstantpool extension.
 *
 * @param command  !vmconstantpool
 * @param args	args passed by !vmconstantpool extension.
 * @param context Context
 * @param out PrintStream
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer javaVM;
        javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (args.length == 1) {
            long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            if (vmaddress != javaVM.getAddress()) {
                out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
                return;
            }
        } else if (args.length > 1) {
            printUsage(out);
        }
        J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
        J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
        int index;
        U32Pointer cpShapeDescription;
        int constPoolCount;
        cpShapeDescription = romClass.cpShapeDescription();
        long cpDescription = cpShapeDescription.at(0).longValue();
        constPoolCount = romClass.romConstantPoolCount().intValue();
        PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
        long cpDescriptionIndex = 0;
        for (index = 0; index < constPoolCount; index++) {
            if (0 == cpDescriptionIndex) {
                // Load a new description word
                cpDescription = cpShapeDescription.at(0).longValue();
                cpShapeDescription = cpShapeDescription.add(1);
                cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
            }
            long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
            AbstractPointer ref = PointerPointer.NULL;
            if (shapeDesc == J9CPTYPE_CLASS) {
                ref = J9ROMClassRefPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_STRING) {
                ref = J9ROMStringRefPointer.cast(cpEntry);
            } else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
                ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
            } else if (shapeDesc == J9CPTYPE_LONG) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
            } else if (shapeDesc == J9CPTYPE_DOUBLE) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
                long classRefCPIndex;
                if (shapeDesc == J9CPTYPE_FIELD) {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    /* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
                    classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
                } else {
                    ref = J9ROMFieldRefPointer.cast(cpEntry);
                    classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
                }
                PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
                /* gets the DDR output of the item */
                String outString = ref.formatFullInteractive();
                String[] parts = outString.split(nl);
                /* add a debug extension(!j9romclassref) on the second line of the output */
                parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
                out.print(join(nl, parts));
            } else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
                U64Pointer longPointer = U64Pointer.cast(cpEntry);
                out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
            } else if (ref.notNull()) {
                out.println(ref.formatFullInteractive());
            }
            cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
            cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
            cpDescriptionIndex -= 1;
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) U64Pointer(com.ibm.j9ddr.vm29.pointer.U64Pointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Aggregations

J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)27 CorruptDataException (com.ibm.j9ddr.CorruptDataException)16 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)11 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)8 U32 (com.ibm.j9ddr.vm29.types.U32)8 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)7 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)7 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)6 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)6 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)5 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)5 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)5 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)5 PatternString (com.ibm.j9ddr.util.PatternString)4 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)4 U16Pointer (com.ibm.j9ddr.vm29.pointer.U16Pointer)4 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)4 J9ClassRegionNode (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode)4