use of com.ibm.j9ddr.corereaders.osthread.OSStackFrame in project openj9 by eclipse.
the class BaseWindowsOSThread method walkStack64.
/* Walking 64 bit stacks is not like 32 bit stacks.
* We have to apply the unwind info contained in the dll's.
*
* This is documented here:
* http://msdn.microsoft.com/en-us/library/8ydc79k6%28v=vs.110%29.aspx
*/
private void walkStack64() throws CorruptDataException {
// Get the module for the current instruction pointer.
long ip = getInstructionPointer();
long rsp = getStackPointer();
while (ip != 0x0) {
// Create a stack frame from that base pointer and instruction pointer.
// On x86-64 the there is no base pointer.
stackFrames.add(new OSStackFrame(rsp, ip));
// Get the unwind info in the right module, for the current instruction pointer. (Step 1)
UnwindModule module = getModuleForInstructionAddress(ip);
RuntimeFunction rf = null;
if (module != null) {
rf = module.getUnwindDataForAddress(ip - module.getLoadAddress());
} else {
break;
}
if (rf == null) {
// functions. (Windows 7 does.)
break;
} else {
// System.err.println("Found unwind data: " + rf + " for " + SymbolUtil.getProcedureNameForAddress(process, ip));
UnwindInfo info = new UnwindInfo(process.getAddressSpace(), module, rf.getUnwindInfoAddress());
// Uncomment to dump unwind information as we apply it.
// System.err.println("Applying UNWIND_INFO: " + info);
// Apply the unwind info to the stack and get the new
// base pointer and stack pointer.
rsp = info.apply(rsp);
// Get the instruction/base pointer for the next frame.
ip = process.getPointerAt(rsp);
// New stack pointer is the slot after that. (I think)
rsp += 8;
}
// System.err.println(String.format("Next rsp = 0x%08x", rsp));
// System.err.println(String.format("Next ip = 0x%08x", ip));
}
}
use of com.ibm.j9ddr.corereaders.osthread.OSStackFrame 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.OSStackFrame in project openj9 by eclipse.
the class BaseWindowsOSThread method walkStack32.
private void walkStack32() throws CorruptDataException {
// Windows stack frames can be read by following the ebp to the base of
// the stack: old ebp is at ebp(0) and and return address to parent context
// is ebp(sizeof(void*))
// 1) find the ebp in the register file
long ebp = getBasePointer();
long eip = getInstructionPointer();
long esp = getStackPointer();
long stackStart = getStackStart();
long stackEnd = getStackEnd();
// eip may be -1 if we're in a system call
if (-1 == eip && stackStart <= esp && esp < stackEnd) {
try {
eip = process.getPointerAt(esp);
} catch (MemoryFault e) {
// ignore
}
}
int bytesPerPointer = process.bytesPerPointer();
// Add the current frame first. If ebp doesn't point into the stack, try esp.
if (Addresses.lessThanOrEqual(stackStart, ebp) && Addresses.lessThan(ebp, stackEnd)) {
stackFrames.add(new OSStackFrame(ebp, eip));
} else if (Addresses.lessThan(stackStart, esp) && Addresses.lessThan(esp, stackEnd)) {
stackFrames.add(new OSStackFrame(esp, eip));
ebp = esp + bytesPerPointer;
}
while (stackStart <= ebp && ebp < stackEnd) {
try {
long newBP = process.getPointerAt(ebp);
long retAddress = process.getPointerAt(ebp + bytesPerPointer);
stackFrames.add(new OSStackFrame(newBP, retAddress));
ebp = newBP;
} catch (MemoryFault e) {
// stop trying to read meaningless memory
break;
}
}
}
Aggregations