use of com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult 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.StackWalkResult 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.StackWalkResult in project openj9 by eclipse.
the class DTFJJavaThread method walkStack.
// this function is the entry point for the stack walking and provides the top level catch for Exceptions and NoSuchFieldErrors
private void walkStack() {
frames = new LinkedList<Object>();
WalkState walkState = new WalkState();
walkState.walkThread = thread;
walkState.flags = J9_STACKWALK_VISIBLE_ONLY | J9_STACKWALK_INCLUDE_NATIVES | J9_STACKWALK_ITERATE_FRAMES | J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET | J9_STACKWALK_ITERATE_O_SLOTS;
walkState.callBacks = new StackWalkerCallbacks();
register((IEventListener) walkState.callBacks);
StackWalkResult result = StackWalkResult.STACK_CORRUPT;
try {
result = StackWalker.walkStackFrames(walkState);
} catch (Throwable t) {
J9DDRDTFJUtils.handleAsCorruptDataException(DTFJContext.getProcess(), t);
result = StackWalkResult.STACK_CORRUPT;
}
unregister((IEventListener) walkState.callBacks);
if (result != StackWalkResult.NONE) {
frames.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Bad return from stack walker walking thread 0x" + Long.toHexString(walkState.walkThread.getAddress()) + ". Some stack frames may be missing. Final state = " + result));
}
}
use of com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult in project openj9 by eclipse.
the class JitstackCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (!J9BuildFlags.interp_nativeSupport) {
CommandUtils.dbgPrint(out, "No JIT in this build\n");
return;
}
try {
String[] realArgs = null;
if (args.length != 0) {
realArgs = args[0].split(",");
}
if (args.length == 0 || !((realArgs.length == 3) || (realArgs.length == 4))) {
CommandUtils.dbgPrint(out, "Usage:\n");
CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc\n");
CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc,els\n");
CommandUtils.dbgPrint(out, "\tUse !jitstackslots instead of !jitstack to see slot values\n");
return;
}
long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
StackWalkerUtils.enableVerboseLogging(2, out);
WalkState walkState = new WalkState();
address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
UDATAPointer sp = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
U8Pointer pc = U8Pointer.cast(address);
UDATAPointer arg0EA = UDATAPointer.NULL;
J9MethodPointer literals = J9MethodPointer.NULL;
J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
if (realArgs.length == 4) {
address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
} else {
entryLocalStorage = thread.entryLocalStorage();
}
walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
walkState.flags |= J9_STACKWALK_START_AT_JIT_FRAME;
if (command.equalsIgnoreCase("!jitstackslots")) {
walkState.flags |= J9_STACKWALK_ITERATE_O_SLOTS;
// 100 is highly arbitrary but basically means "print everything".
// It is used in jextract where the message levels have been copied
// from to begin with, so it should mean we get the same output.
StackWalkerUtils.enableVerboseLogging(100, out);
}
walkState.walkThread = thread;
walkState.callBacks = new BaseStackWalkerCallbacks();
walkState.frameFlags = new UDATA(0);
StackWalkResult result = StackWalker.walkStackFrames(walkState, sp, arg0EA, pc, literals, entryLocalStorage);
if (result != StackWalkResult.NONE) {
out.println("Stack walk result: " + result);
}
StackWalkerUtils.disableVerboseLogging();
out.flush();
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult in project openj9 by eclipse.
the class StackWalkCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
UDATAPointer sp = UDATAPointer.NULL;
UDATAPointer arg0EA = UDATAPointer.NULL;
U8Pointer pc = U8Pointer.NULL;
J9MethodPointer literals = J9MethodPointer.NULL;
J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
String[] realArgs = null;
if (args.length != 0) {
realArgs = args[0].split(",");
}
if (args.length == 0 || !((realArgs.length == 1) || (realArgs.length == 5) || (realArgs.length == 6))) {
CommandUtils.dbgPrint(out, "Usage:\n");
CommandUtils.dbgPrint(out, "\t!stack thread\n");
CommandUtils.dbgPrint(out, "\t!stack thread,sp,a0,pc,literals\n");
CommandUtils.dbgPrint(out, "\t!stack thread,sp,a0,pc,literals,els\n");
CommandUtils.dbgPrint(out, "\tUse !stackslots instead of !stack to see slot values\n");
if (J9BuildFlags.interp_nativeSupport) {
CommandUtils.dbgPrint(out, "\tUse !jitstack or !jitstackslots to start the walk at a JIT frame\n");
}
// dbgPrintRegisters(1);
return;
}
long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
if (0 == address) {
/* Parse error is captured in CommandUtils.parsePointer method and message is printed */
return;
}
J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
StackWalkerUtils.enableVerboseLogging(3, out);
WalkState walkState = new WalkState();
walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
if (realArgs.length >= 5) {
address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
sp = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
arg0EA = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
pc = U8Pointer.cast(address);
address = CommandUtils.parsePointer(realArgs[4], J9BuildFlags.env_data64);
literals = J9MethodPointer.cast(address);
} else {
sp = thread.sp();
arg0EA = thread.arg0EA();
pc = thread.pc();
literals = thread.literals();
}
if (realArgs.length >= 6) {
address = CommandUtils.parsePointer(realArgs[5], J9BuildFlags.env_data64);
entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
} else {
if (J9BuildFlags.interp_nativeSupport) {
entryLocalStorage = thread.entryLocalStorage();
}
}
if (command.equalsIgnoreCase("!stackslots")) {
walkState.flags |= J9_STACKWALK_ITERATE_O_SLOTS;
// 100 is highly arbitrary but basically means "print everything".
// It is used in jextract where the message levels have been copied
// from to begin with, so it should mean we get the same output.
StackWalkerUtils.enableVerboseLogging(100, out);
walkState.callBacks = new BaseStackWalkerCallbacks();
} else {
StackWalkerUtils.enableVerboseLogging(0, out);
walkState.callBacks = new TerseStackWalkerCallbacks();
walkState.flags |= J9_STACKWALK_ITERATE_FRAMES;
}
walkState.walkThread = thread;
StackWalkResult result = StackWalker.walkStackFrames(walkState, sp, arg0EA, pc, literals, entryLocalStorage);
if (result != StackWalkResult.NONE) {
out.println("Stack walk result: " + result);
}
StackWalkerUtils.disableVerboseLogging();
out.flush();
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations