Search in sources :

Example 6 with J9ROMMethodPointer

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

the class DumpRomMethodCommand method romMethodIteratorFromRamMethod.

private Iterable<J9ROMClassAndMethod> romMethodIteratorFromRamMethod(J9MethodPointer ramMethod) throws CorruptDataException {
    Iterable<J9ROMClassAndMethod> methodIterator;
    J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
    J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
    J9ROMClassPointer romClass = ramClass.romClass();
    Vector<J9ROMClassAndMethod> methodInfoVector = new Vector<J9ROMClassAndMethod>(1);
    methodInfoVector.add(new J9ROMClassAndMethod(romMethod, romClass));
    methodIterator = methodInfoVector;
    return methodIterator;
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) Vector(java.util.Vector) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Example 7 with J9ROMMethodPointer

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

the class DumpRomMethodCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        Iterable<J9ROMClassAndMethod> methodIterator = null;
        if (args.length < 1) {
            printUsage(out);
            return;
        }
        String selector = args[0];
        if (selector.equals("-a")) {
            if (args.length != 2) {
                printUsage(out);
                return;
            }
            /* decimal or hexadecimal */
            long methodAddress = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
            J9MethodPointer ramMethod = J9MethodPointer.cast(methodAddress);
            if (ramMethod.isNull()) {
                CommandUtils.dbgPrint(out, "bad ram method addr\n");
                return;
            }
            methodIterator = romMethodIteratorFromRamMethod(ramMethod);
        } else if (selector.equals("-o")) {
            if (args.length != 2) {
                printUsage(out);
                return;
            }
            long methodAddress = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
            J9ROMMethodPointer romMethod = J9ROMMethodPointer.cast(methodAddress);
            if (romMethod.isNull()) {
                CommandUtils.dbgPrint(out, "bad rom method addr\n");
                return;
            }
            J9ROMMethodPointer bytecodesStart = romMethod.add(1);
            /* bytecodes immediately follow the J9ROMMethod struct */
            U8Pointer pc = U8Pointer.cast(bytecodesStart.getAddress());
            J9MethodPointer ramMethod = J9JavaVMHelper.getMethodFromPC(J9RASHelper.getVM(DataType.getJ9RASPointer()), pc);
            methodIterator = romMethodIteratorFromRamMethod(ramMethod);
        } else {
            try {
                methodIterator = new FilteredROMMethodsIterator(out, context, selector);
            } catch (CorruptDataException e) {
                throw new DDRInteractiveCommandException(e);
            }
        }
        for (J9ROMClassAndMethod mi : methodIterator) {
            out.println(String.format("Class: %s", J9UTF8Helper.stringValue(mi.romClass.className())));
            J9BCUtil.j9bcutil_dumpRomMethod(out, mi.romMethod, mi.romClass, dumpFlags, J9BCUtil.BCUtil_DumpAnnotations);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw e;
    }
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) FilteredROMMethodsIterator(com.ibm.j9ddr.vm29.tools.ddrinteractive.FilteredROMMethodsIterator) 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) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Example 8 with J9ROMMethodPointer

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

the class J9BCUtil method j9bcutil_dumpRomClass.

public static void j9bcutil_dumpRomClass(PrintStream out, J9ROMClassPointer romClass, long flags) throws CorruptDataException {
    out.append((String.format("ROM Size: 0x%s (%d)", Long.toHexString(romClass.romSize().longValue()), romClass.romSize().longValue())));
    out.append(nl);
    out.append(String.format("Class Name: %s", J9UTF8Helper.stringValue(romClass.className())));
    out.append(nl);
    if (romClass.superclassName().isNull()) {
        out.append("Superclass Name: <none>");
    } else {
        out.append(String.format("Superclass Name: %s", J9UTF8Helper.stringValue(romClass.superclassName())));
    }
    out.append(nl);
    /* dump the source file name */
    dumpSourceFileName(out, romClass, flags);
    /* dump the simple name */
    dumpSimpleName(out, romClass, flags);
    /* dump the class generic signature */
    dumpGenericSignature(out, romClass, flags);
    /* dump the enclosing method */
    dumpEnclosingMethod(out, romClass, flags);
    out.append(String.format("Sun Access Flags (0x%s): ", Long.toHexString(romClass.modifiers().longValue())));
    dumpModifiers(out, romClass.modifiers().longValue(), MODIFIERSOURCE_CLASS, ONLY_SPEC_MODIFIERS);
    out.append(String.format("J9  Access Flags (0x%s): ", Long.toHexString(romClass.extraModifiers().longValue())));
    dumpClassJ9ExtraModifiers(out, romClass.extraModifiers().longValue());
    out.append(nl);
    out.append(String.format("Class file version: %d.%d", romClass.majorVersion().longValue(), romClass.minorVersion().longValue()));
    out.append(nl);
    out.append(String.format("Instance Shape: 0x%s", Long.toHexString(romClass.instanceShape().longValue())));
    out.append(nl);
    out.append(String.format("Intermediate Class Data (%d bytes): %s", romClass.intermediateClassDataLength().longValue(), Long.toHexString(romClass.intermediateClassData().longValue())));
    out.append(nl);
    out.append(String.format("Maximum Branch Count: %d", romClass.maxBranchCount().longValue()));
    out.append(nl);
    out.append(String.format("Interfaces (%d):" + nl, romClass.interfaceCount().longValue()));
    if (!romClass.interfaceCount().eq(0)) {
        SelfRelativePointer interfaces = romClass.interfaces();
        long interfaceCount = romClass.interfaceCount().longValue();
        for (int i = 0; i < interfaceCount; i++) {
            out.append("  ");
            J9UTF8Pointer interfaceName = J9UTF8Pointer.cast(interfaces.get());
            out.append(J9UTF8Helper.stringValue(interfaceName));
            out.append(nl);
            interfaces = interfaces.add(1);
        }
    }
    J9UTF8Pointer outerClassName = romClass.outerClassName();
    if (!outerClassName.isNull()) {
        out.append("Declaring Class: " + J9UTF8Helper.stringValue(romClass.outerClassName()));
        out.append(nl);
        out.append(String.format("Member Access Flags (0x%s): ", Long.toHexString(romClass.memberAccessFlags().longValue())));
        dumpModifiers(out, romClass.memberAccessFlags().longValue(), MODIFIERSOURCE_CLASS, ONLY_SPEC_MODIFIERS);
        out.append(nl);
        outerClassName = outerClassName.add(1);
    }
    long innerClassCount = romClass.innerClassCount().longValue();
    if (innerClassCount != 0) {
        SelfRelativePointer innerClasses = romClass.innerClasses();
        out.append(String.format("Declared Classes (%d):" + nl, innerClassCount));
        for (int i = 0; i < innerClassCount; i++) {
            J9UTF8Pointer innerClassName = J9UTF8Pointer.cast(innerClasses.get());
            out.append("   " + J9UTF8Helper.stringValue(innerClassName));
            innerClasses = innerClasses.add(1);
        }
    }
    U32 romFieldCount = romClass.romFieldCount();
    out.append(String.format("Fields (%d):" + nl, romFieldCount.longValue()));
    J9ROMFieldShapeIterator iterator = new J9ROMFieldShapeIterator(romClass.romFields(), romFieldCount);
    while (iterator.hasNext()) {
        J9ROMFieldShapePointer currentField = (J9ROMFieldShapePointer) iterator.next();
        if (!currentField.modifiers().bitAnd(J9JavaAccessFlags.J9AccStatic).eq(0)) {
            dumpRomStaticField(out, currentField, flags);
        } else {
            dumpRomField(out, currentField, flags);
        }
        out.append(nl);
    }
    dumpCPShapeDescription(out, romClass, flags);
    long romMethodsCount = romClass.romMethodCount().longValue();
    out.append(String.format("Methods (%d):" + nl, romMethodsCount));
    J9ROMMethodPointer romMethod = romClass.romMethods();
    for (int i = 0; i < romClass.romMethodCount().intValue(); i++) {
        J9BCUtil.j9bcutil_dumpRomMethod(out, romMethod, romClass, flags, 0);
        romMethod = ROMHelp.nextROMMethod(romMethod);
    }
    /* dump source debug extension */
    dumpSourceDebugExtension(out, romClass, flags);
    /* dump annotation info */
    dumpAnnotationInfo(out, romClass, flags);
    /* dump callsite data */
    dumpCallSiteData(out, romClass);
    /* dump split side tables */
    dumpStaticSplitSideTable(out, romClass);
    dumpSpecialSplitSideTable(out, romClass);
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMFieldShapeIterator(com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator) SelfRelativePointer(com.ibm.j9ddr.vm29.pointer.SelfRelativePointer) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)

Example 9 with J9ROMMethodPointer

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

the class J9BCUtil method dumpAnnotationInfo.

private static void dumpAnnotationInfo(PrintStream out, J9ROMClassPointer romClass, long flags) throws CorruptDataException {
    U32Pointer classAnnotationData = OptInfo.getClassAnnotationsDataForROMClass(romClass);
    U32Pointer classTypeAnnotationData = OptInfo.getClassTypeAnnotationsDataForROMClass(romClass);
    out.append("  Annotation Info:" + nl);
    if (!classAnnotationData.isNull()) {
        U32 length = classAnnotationData.at(0);
        U32Pointer data = classAnnotationData.add(1);
        out.append(String.format("    Class Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    if (!classTypeAnnotationData.isNull()) {
        U32 length = classTypeAnnotationData.at(0);
        U32Pointer data = classTypeAnnotationData.add(1);
        out.append(String.format("    Class Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
    }
    /* print field annotations */
    J9ROMFieldShapeIterator iterator = new J9ROMFieldShapeIterator(romClass.romFields(), romClass.romFieldCount());
    out.append("    Field Annotations:" + nl);
    while (iterator.hasNext()) {
        J9ROMFieldShapePointer currentField = (J9ROMFieldShapePointer) iterator.next();
        U32Pointer fieldAnnotationData = J9ROMFieldShapeHelper.getFieldAnnotationsDataFromROMField(currentField);
        U32Pointer fieldTypeAnnotationData = J9ROMFieldShapeHelper.getFieldTypeAnnotationsDataFromROMField(currentField);
        if (!fieldAnnotationData.isNull()) {
            U32 length = fieldAnnotationData.at(0);
            U32Pointer data = fieldAnnotationData.add(1);
            out.append("     Name: " + J9UTF8Helper.stringValue(currentField.nameAndSignature().name()) + nl);
            out.append("     Signature: " + J9UTF8Helper.stringValue(currentField.nameAndSignature().signature()) + nl);
            out.append(String.format("      Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
        }
        if (!fieldTypeAnnotationData.isNull()) {
            U32 length = fieldTypeAnnotationData.at(0);
            U32Pointer data = fieldTypeAnnotationData.add(1);
            out.append(String.format("      Type Annotations (%d bytes): %s" + nl, length.intValue(), data.getHexAddress()));
        }
    }
    out.append(nl);
    /* print method, parameter and default annotations */
    J9ROMMethodPointer romMethod = romClass.romMethods();
    out.append("    Method Annotations:" + nl);
    for (int i = 0; i < romClass.romMethodCount().intValue(); i++) {
        dumpMethodAnnotations(out, romMethod);
        romMethod = ROMHelp.nextROMMethod(romMethod);
    }
    out.append(nl);
}
Also used : U32(com.ibm.j9ddr.vm29.types.U32) J9ROMFieldShapeIterator(com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 10 with J9ROMMethodPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer 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)

Aggregations

J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)22 CorruptDataException (com.ibm.j9ddr.CorruptDataException)10 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)10 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)7 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)7 U32 (com.ibm.j9ddr.vm29.types.U32)6 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)5 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)5 UDATA (com.ibm.j9ddr.vm29.types.UDATA)5 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)4 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)4 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)3 J9ROMClassAndMethod (com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)3 U16 (com.ibm.j9ddr.vm29.types.U16)3 U8 (com.ibm.j9ddr.vm29.types.U8)3 J9ROMFieldShapeIterator (com.ibm.j9ddr.vm29.j9.J9ROMFieldShapeIterator)2 J9ExceptionInfoPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ExceptionInfoPointer)2 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)2