use of com.ibm.j9ddr.corereaders.osthread.IOSStackFrame in project openj9 by eclipse.
the class BaseAIXOSThread method walkStack.
private void walkStack() {
frames = new LinkedList<IOSStackFrame>();
long stackPointer = getStackPointer();
long instructionPointer = getInstructionPointer();
if (0 == instructionPointer || !isValidAddress(instructionPointer)) {
instructionPointer = getBasePointer();
}
try {
if (0 != instructionPointer && 0 != stackPointer && isValidAddress(instructionPointer) && isValidAddress(stackPointer)) {
frames.add(new OSStackFrame(stackPointer, instructionPointer));
long previousStackPointer = -1;
final long stepping = process.bytesPerPointer();
int loops = 0;
// maximum 256 frames, for protection against excessive or infinite loops in corrupt dumps
while (previousStackPointer != stackPointer && loops++ < 256) {
previousStackPointer = stackPointer;
stackPointer = process.getPointerAt(stackPointer);
long addressToRead = stackPointer + stepping;
// readAddress(); // Ignore conditionRegister
addressToRead += stepping;
instructionPointer = process.getPointerAt(addressToRead);
frames.add(new OSStackFrame(stackPointer, instructionPointer));
}
} else {
// This is a temporary hack until we can understand signal handler stacks
// better
logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.aix.BaseAIXOSThread", "walkStack", "MISSED");
// TODO handle this case sensibly
}
} catch (CorruptDataException e) {
// TODO handle
}
}
use of com.ibm.j9ddr.corereaders.osthread.IOSStackFrame in project openj9 by eclipse.
the class NativeStacksCommand method run.
public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
Set<Long> threadIds = null;
for (String arg : args) {
if (threadIds == null) {
threadIds = new HashSet<Long>();
}
Long tid = CommandUtils.parseNumber(arg).longValue();
threadIds.add(tid);
}
try {
Collection<? extends IOSThread> threads = ctx.process.getThreads();
for (IOSThread t : threads) {
if (threadIds == null || threadIds.contains(t.getThreadId())) {
try {
out.printf("Thread id: %d (0x%X)\n", t.getThreadId(), t.getThreadId());
int frameId = 0;
if (threadIds != null) {
threadIds.remove(t.getThreadId());
}
for (IOSStackFrame f : t.getStackFrames()) {
String symbol = ctx.process.getProcedureNameForAddress(f.getInstructionPointer());
if (ctx.process.bytesPerPointer() == 8) {
out.printf("#%d bp:0x%016X ip:0x%016X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
} else {
out.printf("#%d bp:0x%08X ip:0x%08X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
}
}
} catch (DataUnavailableException e) {
out.printf("DataUnavailableException reading stack for thread %d\n", t.getThreadId());
} catch (CorruptDataException e) {
out.printf("CorruptDataException reading stack for thread %d\n", t.getThreadId());
}
out.println("----------");
}
}
if (threadIds != null && !threadIds.isEmpty()) {
out.print("Unable to find native thread for id(s): ");
for (long tid : threadIds) {
out.print(tid);
}
out.println();
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.corereaders.osthread.IOSStackFrame in project openj9 by eclipse.
the class J9DDRImageThread method getStackFrames.
/* (non-Javadoc)
* @see com.ibm.dtfj.image.ImageThread#getStackFrames()
*/
public Iterator<?> getStackFrames() throws DataUnavailable {
List<? extends IOSStackFrame> frames = thread.getStackFrames();
List<ImageStackFrame> dtfjFrames = new ArrayList<ImageStackFrame>(frames.size());
for (IOSStackFrame thisFrame : frames) {
dtfjFrames.add(new J9DDRImageStackFrame(process, thisFrame, this));
}
return dtfjFrames.iterator();
}
Aggregations