Search in sources :

Example 31 with J9ROMMethodPointer

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

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

the class CheckVMThreadStacks method dumpStackTrace.

/* TODO : this is an implementation of the internal VM function dumpStackTrace
	 * and really should be somewhere global and public */
private void dumpStackTrace(J9VMThreadPointer walkThread) {
    WalkState walkState = new WalkState();
    walkState.walkThread = walkThread;
    walkState.flags = J9_STACKWALK_VISIBLE_ONLY | J9_STACKWALK_INCLUDE_NATIVES | J9_STACKWALK_ITERATE_FRAMES;
    walkState.callBacks = new BaseStackWalkerCallbacks() {

        public FrameCallbackResult frameWalkFunction(J9VMThreadPointer walkThread, WalkState walkState) {
            String className = "(unknown class)";
            if (walkState.constantPool.notNull()) {
                try {
                    className = J9ClassHelper.getName(walkState.constantPool.ramClass());
                } catch (CorruptDataException e) {
                // TODO Auto-generated catch block
                }
            }
            if (walkState.method.isNull()) {
                getReporter().println(String.format("0x%08X %s (unknown method)", walkState.pc.getAddress(), className));
            } else {
                if (walkState.jitInfo.isNull()) {
                    boolean isNative = false;
                    U8Pointer bytecodes = U8Pointer.NULL;
                    String name = "(corrupt)";
                    String sig = "(corrupt)";
                    try {
                        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(walkState.method);
                        isNative = romMethod.modifiers().allBitsIn(J9_JAVA_NATIVE);
                        if (!isNative) {
                            bytecodes = J9ROMMethodHelper.bytecodes(romMethod);
                        }
                        name = J9ROMMethodHelper.getName(romMethod);
                        sig = J9ROMMethodHelper.getSignature(romMethod);
                    } catch (CorruptDataException e) {
                    // This should never happen
                    }
                    if (isNative) {
                        getReporter().println(String.format(" NATIVE   %s.%s%s", className, name, sig));
                    } else {
                        getReporter().println(String.format(" %08X %s.%s%s", walkState.pc.sub(bytecodes).longValue(), className, name, sig));
                    }
                } else {
                    boolean isInlined = walkState.inlineDepth != 0;
                    U8Pointer jitPC = walkState.pc;
                    String name = "(corrupt)";
                    String sig = "(corrupt)";
                    try {
                        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(walkState.method);
                        name = J9UTF8Helper.stringValue(romMethod.nameAndSignature().name());
                        sig = J9UTF8Helper.stringValue(romMethod.nameAndSignature().signature());
                        if (!isInlined) {
                            jitPC = U8Pointer.cast(jitPC.sub(U8Pointer.cast(walkState.method.extra())).longValue());
                        }
                    } catch (CorruptDataException e) {
                    // This should never happen
                    }
                    if (isInlined) {
                        getReporter().println(String.format(" INLINED  %s.%s%s  (@%s)", className, name, sig, formatPointer(walkState.pc)));
                    } else {
                        getReporter().println(String.format(" %08X %s.%s%s  (@%s)", jitPC.getAddress(), className, name, sig, formatPointer(walkState.pc)));
                    }
                }
            }
            return FrameCallbackResult.KEEP_ITERATING;
        }
    };
    StackWalker.walkStackFrames(walkState);
}
Also used : BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException) FrameCallbackResult(com.ibm.j9ddr.vm29.j9.stackwalker.FrameCallbackResult)

Example 33 with J9ROMMethodPointer

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

the class J9ROMMethodStructureFormatter method postFormat.

@Override
public FormatWalkResult postFormat(String type, long address, PrintStream out, Context context, List<IFieldFormatter> fieldFormatters, String[] extraArgs) {
    if (type.equalsIgnoreCase("j9rommethod")) {
        J9ROMMethodPointer method = J9ROMMethodPointer.cast(address);
        if (!method.isNull()) {
            writeMethodName(method, out);
            writeNextROMMethodAddress(method, out);
        }
    }
    return FormatWalkResult.KEEP_WALKING;
}
Also used : J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)

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