Search in sources :

Example 1 with WalkState

use of com.ibm.j9ddr.vm29.j9.stackwalker.WalkState in project openj9 by eclipse.

the class GCVMThreadStackSlotIterator method scanSlots.

static void scanSlots(J9VMThreadPointer walkThread, IStackWalkerCallbacks stackWalkerCallbacks, boolean includeStackFrameClassReferences, boolean trackVisibleFrameDepth) {
    WalkState walkState = new WalkState();
    walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK;
    walkState.walkThread = walkThread;
    walkState.callBacks = stackWalkerCallbacks;
    if (trackVisibleFrameDepth) {
        walkState.skipCount = 0;
        walkState.flags |= J9_STACKWALK_VISIBLE_ONLY;
    } else {
        walkState.flags |= J9_STACKWALK_SKIP_INLINES;
    }
    if (includeStackFrameClassReferences) {
        walkState.flags |= J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS;
    }
    StackWalkResult result = StackWalkResult.STACK_CORRUPT;
    result = StackWalker.walkStackFrames(walkState);
    if (StackWalkResult.NONE != result) {
        /* Explicitly raising a corrupt data event here since returning StackWalkResult.STACK_CORRUPT is fairly common if a core is not taken at a safe gc point */
        CorruptDataException corruptDataException = new CorruptDataException("Stack walk returned: " + result + " for vmThread: " + walkThread.getHexAddress());
        EventManager.raiseCorruptDataEvent("", corruptDataException, false);
    }
}
Also used : WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException) StackWalkResult(com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)

Example 2 with WalkState

use of com.ibm.j9ddr.vm29.j9.stackwalker.WalkState in project openj9 by eclipse.

the class StackRoots method walkStacks.

private void walkStacks() throws CorruptDataException {
    GCVMThreadListIterator threadIterator = GCVMThreadListIterator.from();
    while (threadIterator.hasNext()) {
        J9VMThreadPointer next = threadIterator.next();
        WalkState walkState = new WalkState();
        walkState.walkThread = next;
        walkState.flags = J9_STACKWALK_SKIP_INLINES | J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS;
        walkState.callBacks = new StackWalkerCallbacks();
        StackWalkResult result = StackWalkResult.STACK_CORRUPT;
        result = StackWalker.walkStackFrames(walkState);
        if (StackWalkResult.NONE != result) {
            throw new UnsupportedOperationException("Failed to walk stack");
        }
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) IStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.IStackWalkerCallbacks) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) StackWalkResult(com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)

Example 3 with WalkState

use of com.ibm.j9ddr.vm29.j9.stackwalker.WalkState in project openj9 by eclipse.

the class StackWalkerUtils method swPrintMethod.

public static void swPrintMethod(WalkState walkState, J9MethodPointer method) throws CorruptDataException {
    if (method.notNull()) {
        J9UTF8Pointer className = UNTAGGED_METHOD_CP(method).ramClass().romClass().className();
        J9ROMMethodPointer romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(method);
        J9UTF8Pointer name = romMethod.nameAndSignature().name();
        J9UTF8Pointer sig = romMethod.nameAndSignature().signature();
        swPrintf(walkState, 2, "\tMethod: {0}.{1}{2} !j9method {3}", J9UTF8Helper.stringValue(className), J9UTF8Helper.stringValue(name), J9UTF8Helper.stringValue(sig), method.getHexAddress());
    }
}
Also used : J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)

Example 4 with WalkState

use of com.ibm.j9ddr.vm29.j9.stackwalker.WalkState in project openj9 by eclipse.

the class StackWalkerUtils method WALK_NAMED_INDIRECT_O_SLOT.

public static void WALK_NAMED_INDIRECT_O_SLOT(WalkState walkState, PointerPointer objectSlot, VoidPointer indirectSlot, String tag) throws CorruptDataException {
    UDATA value;
    value = UDATAPointer.cast(objectSlot).at(0);
    if (indirectSlot.notNull()) {
        swPrintf(walkState, 4, "\t\t{0}[{1} -> {2}] = {3}", (tag != null ? tag : "O-Slot"), indirectSlot.getHexAddress(), objectSlot.getHexAddress(), value.getHexValue());
    } else {
        swPrintf(walkState, 4, "\t\t{0}[{1}] = {2}", (tag != null ? tag : "O-Slot"), objectSlot.getHexAddress(), value.getHexValue());
    }
    walkState.callBacks.objectSlotWalkFunction(walkState.walkThread, walkState, objectSlot, VoidPointer.cast(objectSlot));
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA)

Example 5 with WalkState

use of com.ibm.j9ddr.vm29.j9.stackwalker.WalkState in project openj9 by eclipse.

the class TerseStackWalkerCallbacks method frameWalkFunction.

public FrameCallbackResult frameWalkFunction(J9VMThreadPointer walkThread, WalkState walkState) {
    try {
        if (walkState.method.notNull()) {
            J9MethodPointer method = walkState.method;
            J9UTF8Pointer className = StackWalkerUtils.UNTAGGED_METHOD_CP(method).ramClass().romClass().className();
            J9ROMMethodPointer romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(method);
            J9UTF8Pointer name = romMethod.nameAndSignature().name();
            J9UTF8Pointer sig = romMethod.nameAndSignature().signature();
            StackWalkerUtils.swPrintf(walkState, 0, "\t!j9method {3}   {0}.{1}{2}", J9UTF8Helper.stringValue(className), J9UTF8Helper.stringValue(name), J9UTF8Helper.stringValue(sig), walkState.method.getHexAddress());
            return FrameCallbackResult.KEEP_ITERATING;
        }
        if (walkState.pc.getAddress() == J9SF_FRAME_TYPE_JNI_NATIVE_METHOD) {
            StackWalkerUtils.swPrintf(walkState, 0, "\t                        Native method frame");
        } else if (walkState.pc.getAddress() == J9SF_FRAME_TYPE_GENERIC_SPECIAL) {
            StackWalkerUtils.swPrintf(walkState, 0, "\t                        Generic special frame");
        } else if (walkState.pc.getAddress() == J9SF_FRAME_TYPE_METHODTYPE) {
            StackWalkerUtils.swPrintf(walkState, 0, "\t                        MethodType frame");
        } else {
            if (walkState.pc.getAddress() > J9SF_MAX_SPECIAL_FRAME_TYPE) {
                if (walkState.pc.getAddress() == walkState.walkThread.javaVM().callInReturnPC().getAddress() || walkState.pc.getAddress() == (walkState.walkThread.javaVM().callInReturnPC().getAddress() + 3)) {
                    StackWalkerUtils.swPrintf(walkState, 0, "\t                        JNI call-in frame");
                } else {
                    StackWalkerUtils.swPrintf(walkState, 0, "\t                        unknown frame type {0} *{1}", walkState.pc, walkState.pc.getHexAddress());
                }
            } else {
                StackWalkerUtils.swPrintf(walkState, 0, "\t                        known but unhandled frame type {0}", walkState.pc);
            }
        }
    } catch (CorruptDataException e) {
        e.printStackTrace();
    }
    return FrameCallbackResult.KEEP_ITERATING;
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

WalkState (com.ibm.j9ddr.vm29.j9.stackwalker.WalkState)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)7 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)6 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)6 StackWalkResult (com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)5 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)4 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)4 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)3 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)2 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)2 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)2 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)2 J9VMEntryLocalStoragePointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMEntryLocalStoragePointer)2 UDATA (com.ibm.j9ddr.vm29.types.UDATA)2 JavaObject (com.ibm.dtfj.java.JavaObject)1 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)1 FrameCallbackResult (com.ibm.j9ddr.vm29.j9.stackwalker.FrameCallbackResult)1 IStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.IStackWalkerCallbacks)1