Search in sources :

Example 11 with J9ROMClassPointer

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

the class DumpAllRomClassLinearCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long nestingThreashold;
    if (args.length > 1) {
        throw new DDRInteractiveCommandException("This debug extension accepts none or one argument!");
    } else if (args.length == 1) {
        nestingThreashold = Long.valueOf(args[0]);
    } else {
        nestingThreashold = 1;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (null != vm) {
            out.println();
            out.println("!j9javavm " + vm.getHexAddress());
        } else {
            throw new DDRInteractiveCommandException("Unable to find the VM in core dump!");
        }
        out.println();
        ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
        while (iterator.hasNext()) {
            J9ROMClassPointer classPointer = iterator.next();
            out.println("!dumpromclasslinear " + classPointer.getHexAddress());
            // ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
            out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(classPointer.className()), classPointer.getHexAddress()));
            out.println();
            ClassWalker classWalker = new RomClassWalker(classPointer, context);
            new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
            out.println();
        }
    } catch (CorruptDataException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}
Also used : ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) 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 12 with J9ROMClassPointer

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

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

the class ITableSizeCommand method iTableExtendedSize.

public long iTableExtendedSize(J9ITablePointer startTable, J9ITablePointer superTable) throws CorruptDataException {
    long size = 0;
    J9ITablePointer iTable = startTable;
    while (!iTable.eq(superTable)) {
        size += J9ITable.SIZEOF;
        J9ClassPointer interfaceClass = iTable.interfaceClass();
        J9ROMClassPointer romClass = interfaceClass.romClass();
        J9ITablePointer allInterfaces = J9ITablePointer.cast(interfaceClass.iTable());
        do {
            size += (UDATA.SIZEOF * allInterfaces.interfaceClass().romClass().romMethodCount().intValue());
            allInterfaces = allInterfaces.next();
        } while (!allInterfaces.eq(J9ITablePointer.NULL));
        iTable = iTable.next();
    }
    return size;
}
Also used : J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)

Example 14 with J9ROMClassPointer

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

the class J9BCUtil method dumpCallSiteData.

/**
 * This method is Java implementation of rdump.c#dumpCallSiteData function.
 * This method is called when dumping a ROMClass.
 * This method has only affect for invokedDynamic stuff,
 * for other ROMClasses, there wont be anything to print since their callsite and bsm count are zero.
 *
 * @param out PrintStream to print the user info to the console
 * @param romClass ROMClass address in the dump file.
 *
 * @throws CorruptDataException
 */
private static void dumpCallSiteData(PrintStream out, J9ROMClassPointer romClass) throws CorruptDataException {
    int HEX_RADIX = 16;
    long callSiteCount = romClass.callSiteCount().longValue();
    long bsmCount = romClass.bsmCount().longValue();
    SelfRelativePointer callSiteData = SelfRelativePointer.cast(romClass.callSiteData());
    U16Pointer bsmIndices = U16Pointer.cast(callSiteData.addOffset(4 * callSiteCount));
    if (0 != callSiteCount) {
        out.println(String.format("  Call Sites (%d):\n", callSiteCount));
        for (int i = 0; i < callSiteCount; i++) {
            J9ROMNameAndSignaturePointer nameAndSig = J9ROMNameAndSignaturePointer.cast(callSiteData.add(i).get());
            out.println("    Name: " + J9UTF8Helper.stringValue(nameAndSig.name()));
            out.println("    Signature: " + J9UTF8Helper.stringValue(nameAndSig.signature()));
            out.println("    Bootstrap Method Index: " + bsmIndices.at(i).longValue());
            out.println();
        }
    }
    if (0 != bsmCount) {
        J9ROMConstantPoolItemPointer constantPool = ConstantPoolHelpers.J9_ROM_CP_FROM_ROM_CLASS(romClass);
        U32Pointer cpShapeDescription = romClass.cpShapeDescription();
        U16Pointer bsmDataCursor = bsmIndices.add(callSiteCount);
        out.println(String.format("  Bootstrap Methods (%d):", bsmCount));
        for (int i = 0; i < bsmCount; i++) {
            J9ROMMethodHandleRefPointer methodHandleRef = J9ROMMethodHandleRefPointer.cast(constantPool.add(bsmDataCursor.at(0).longValue()));
            bsmDataCursor = bsmDataCursor.add(1);
            /* methodRef will be either a field or a method ref - they both have the same shape so we can pretend it is always a methodref */
            J9ROMMethodRefPointer methodRef = J9ROMMethodRefPointer.cast(constantPool.add(methodHandleRef.methodOrFieldRefIndex().longValue()));
            J9ROMClassRefPointer classRef = J9ROMClassRefPointer.cast(constantPool.add(methodRef.classRefCPIndex().longValue()));
            J9ROMNameAndSignaturePointer nameAndSig = methodRef.nameAndSignature();
            long bsmArgumentCount = bsmDataCursor.at(0).longValue();
            bsmDataCursor = bsmDataCursor.add(1);
            out.println("    Name: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()));
            out.println("    Signature: " + J9UTF8Helper.stringValue(nameAndSig.signature()));
            out.println(String.format("    Bootstrap Method Arguments (%d):", bsmArgumentCount));
            for (; 0 != bsmArgumentCount; bsmArgumentCount--) {
                long argCPIndex = bsmDataCursor.at(0).longValue();
                bsmDataCursor = bsmDataCursor.add(1);
                J9ROMConstantPoolItemPointer item = constantPool.add(argCPIndex);
                long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(cpShapeDescription, (int) argCPIndex);
                if (shapeDesc == J9CPTYPE_CLASS) {
                    J9ROMClassRefPointer romClassRef = J9ROMClassRefPointer.cast(item);
                    out.println("      Class: " + J9UTF8Helper.stringValue(romClassRef.name()));
                } else if (shapeDesc == J9CPTYPE_STRING) {
                    J9ROMStringRefPointer romStringRef = J9ROMStringRefPointer.cast(item);
                    out.println("      String: " + J9UTF8Helper.stringValue(romStringRef.utf8Data()));
                } else if (shapeDesc == J9CPTYPE_INT) {
                    J9ROMSingleSlotConstantRefPointer singleSlotConstantRef = J9ROMSingleSlotConstantRefPointer.cast(item);
                    out.println("      Int: " + singleSlotConstantRef.data().getHexValue());
                } else if (shapeDesc == J9CPTYPE_FLOAT) {
                    J9ROMSingleSlotConstantRefPointer singleSlotConstantRef = J9ROMSingleSlotConstantRefPointer.cast(item);
                    FloatPointer floatPtr = FloatPointer.cast(singleSlotConstantRef.dataEA());
                    out.println("      Float: " + floatPtr.getHexValue() + " (" + floatPtr.floatAt(0) + ")");
                } else if (shapeDesc == J9CPTYPE_LONG) {
                    String hexValue = "";
                    if (J9BuildFlags.env_littleEndian) {
                        hexValue += item.slot2().getHexValue();
                        hexValue += item.slot1().getHexValue().substring(2);
                    } else {
                        hexValue += item.slot1().getHexValue();
                        hexValue += item.slot2().getHexValue().substring(2);
                    }
                    long longValue = Long.parseLong(hexValue.substring(2), HEX_RADIX);
                    out.println("      Long: " + hexValue + "(" + longValue + ")");
                } else if (shapeDesc == J9CPTYPE_DOUBLE) {
                    String hexValue = "";
                    if (J9BuildFlags.env_littleEndian) {
                        hexValue += item.slot2().getHexValue();
                        hexValue += item.slot1().getHexValue().substring(2);
                    } else {
                        hexValue += item.slot1().getHexValue();
                        hexValue += item.slot2().getHexValue().substring(2);
                    }
                    long longValue = Long.parseLong(hexValue.substring(2), HEX_RADIX);
                    double doubleValue = Double.longBitsToDouble(longValue);
                    out.println("      Double: " + hexValue + "(" + Double.toString(doubleValue) + ")");
                } else if (shapeDesc == J9CPTYPE_FIELD) {
                    J9ROMFieldRefPointer romFieldRef = J9ROMFieldRefPointer.cast(item);
                    classRef = J9ROMClassRefPointer.cast(constantPool.add(romFieldRef.classRefCPIndex()));
                    nameAndSig = romFieldRef.nameAndSignature();
                    out.println("      Field: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()) + " " + J9UTF8Helper.stringValue(nameAndSig.signature()));
                } else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD)) {
                    J9ROMMethodRefPointer romMethodRef = J9ROMMethodRefPointer.cast(item);
                    classRef = J9ROMClassRefPointer.cast(constantPool.add(romMethodRef.classRefCPIndex()));
                    nameAndSig = romMethodRef.nameAndSignature();
                    out.println("      Method: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()) + " " + J9UTF8Helper.stringValue(nameAndSig.signature()));
                } else if (shapeDesc == J9CPTYPE_METHOD_TYPE) {
                    J9ROMMethodTypeRefPointer romMethodTypeRef = J9ROMMethodTypeRefPointer.cast(item);
                    out.println("      Method Type: " + J9UTF8Helper.stringValue(J9UTF8Pointer.cast(romMethodTypeRef.signature())));
                } else if (shapeDesc == J9CPTYPE_METHODHANDLE) {
                    methodHandleRef = J9ROMMethodHandleRefPointer.cast(item);
                    methodRef = J9ROMMethodRefPointer.cast(constantPool.add(methodHandleRef.methodOrFieldRefIndex()));
                    classRef = J9ROMClassRefPointer.cast(constantPool.add(methodRef.classRefCPIndex()));
                    nameAndSig = methodRef.nameAndSignature();
                    out.print("      Method Handle: " + J9UTF8Helper.stringValue(classRef.name()) + "." + J9UTF8Helper.stringValue(nameAndSig.name()));
                    long methodType = methodHandleRef.handleTypeAndCpType().rightShift((int) J9DescriptionCpTypeShift).longValue();
                    if ((methodType == MH_REF_GETFIELD) || (methodType == MH_REF_PUTFIELD) || (methodType == MH_REF_GETSTATIC) || (methodType == MH_REF_PUTSTATIC)) {
                        out.print(" ");
                    }
                    out.println(J9UTF8Helper.stringValue(nameAndSig.signature()));
                } else {
                    out.println("      <unknown type>");
                }
            }
        }
    }
}
Also used : J9ROMMethodRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodRefPointer) J9ROMFieldRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldRefPointer) J9ROMClassRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassRefPointer) J9ROMMethodHandleRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodHandleRefPointer) J9ROMSingleSlotConstantRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMSingleSlotConstantRefPointer) SelfRelativePointer(com.ibm.j9ddr.vm29.pointer.SelfRelativePointer) J9ROMStringRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer) J9ROMMethodTypeRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodTypeRefPointer) U16Pointer(com.ibm.j9ddr.vm29.pointer.U16Pointer) J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) J9ROMConstantPoolItemPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer) FloatPointer(com.ibm.j9ddr.vm29.pointer.FloatPointer) U32Pointer(com.ibm.j9ddr.vm29.pointer.U32Pointer)

Example 15 with J9ROMClassPointer

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

the class J9BCUtil method dumpSourceDebugExtension.

private static void dumpSourceDebugExtension(PrintStream out, J9ROMClassPointer romClass, long flags) throws CorruptDataException {
    if (J9BuildFlags.opt_debugInfoServer) {
        U8Pointer current;
        U32 temp;
        if ((flags & J9BCTranslationData.BCT_StripDebugAttributes) == 0) {
            J9SourceDebugExtensionPointer sde = OptInfo.getSourceDebugExtensionForROMClass(romClass);
            if (!sde.isNull()) {
                temp = sde.size();
                if (!temp.eq(0)) {
                    current = U8Pointer.cast(sde.add(1));
                    out.append(String.format("  Source debug extension (%d bytes):    ", temp.longValue()));
                    out.append(nl);
                    while (!temp.eq(0)) {
                        temp = temp.sub(1);
                        U8 c = current.at(0);
                        current = current.add(1);
                        if (c.eq('\015')) {
                            if (!temp.eq(0)) {
                                if (current.at(0).eq('\012')) {
                                    current = current.add(1);
                                }
                                out.append(nl + "    ");
                            }
                        } else if (c.eq('\012')) {
                            out.append(nl + "    ");
                        } else {
                            out.append((char) c.intValue());
                        }
                    }
                }
            }
        }
    }
}
Also used : J9SourceDebugExtensionPointer(com.ibm.j9ddr.vm29.pointer.generated.J9SourceDebugExtensionPointer) U8(com.ibm.j9ddr.vm29.types.U8) U32(com.ibm.j9ddr.vm29.types.U32) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

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