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);
}
}
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");
}
}
}
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());
}
}
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));
}
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;
}
Aggregations