use of com.ibm.j9ddr.corereaders.minidump.unwind.UnwindModule 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.minidump.unwind.UnwindModule in project openj9 by eclipse.
the class BaseWindowsOSThread method getModuleForInstructionAddress.
public UnwindModule getModuleForInstructionAddress(long address) throws CorruptDataException {
Collection<? extends IModule> modules = process.getModules();
IModule matchingModule = null;
OUTER_LOOP: for (IModule thisModule : modules) {
for (IMemoryRange thisRange : thisModule.getMemoryRanges()) {
if (thisRange.contains(address)) {
matchingModule = thisModule;
break OUTER_LOOP;
}
}
}
if (matchingModule == null || !(matchingModule instanceof UnwindModule)) {
return null;
}
return (UnwindModule) matchingModule;
}
use of com.ibm.j9ddr.corereaders.minidump.unwind.UnwindModule in project openj9 by eclipse.
the class ModuleStream method readFrom.
@Override
public void readFrom(MiniDumpReader dump, IAddressSpace as, boolean is64Bit) throws IOException, CorruptDataException {
dump.seek(getLocation());
int numberOfModules = dump.readInt();
if (numberOfModules > 1024) {
throw new CorruptDataException("Improbably high number of modules found: " + numberOfModules + ", location = " + Long.toHexString(getLocation()));
}
class ModuleData {
long imageBaseAddress;
Properties properties;
int nameAddress;
}
ModuleData[] moduleData = new ModuleData[numberOfModules];
for (int i = 0; i < numberOfModules; i++) {
moduleData[i] = new ModuleData();
moduleData[i].imageBaseAddress = dump.readLong();
int imageSize = dump.readInt();
int checksum = dump.readInt();
int timeDateStamp = dump.readInt();
moduleData[i].nameAddress = dump.readInt();
moduleData[i].properties = readProperties(dump, imageSize, checksum, timeDateStamp);
}
for (ModuleData thisModule : moduleData) {
final long imageBaseAddress = thisModule.imageBaseAddress;
final String moduleName = getModuleName(dump, thisModule.nameAddress);
final Properties properties = thisModule.properties;
short magic;
try {
magic = as.getShortAt(imageBaseAddress);
if (0x5A4D != magic) {
logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "readFrom", "Magic number was: " + Integer.toHexString(0xFFFF & magic) + " expected 0x5A4D");
}
} catch (MemoryFault e1) {
logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "readFrom", "MemoryFault reading magic number", e1);
}
long e_lfanewAddress = imageBaseAddress + 0x3c;
// load the e_lfanew since that is the load-address-relative location of
// the PE Header
Collection<IMemoryRange> sections = new LinkedList<IMemoryRange>();
try {
long e_lfanew = 0xFFFFFFFFL & as.getIntAt(e_lfanewAddress);
// push us to the start of the PE header
long readingAddress = e_lfanew + imageBaseAddress;
List<ISymbol> symbols = null;
if (0 != e_lfanew) {
loadModuleSections(as, imageBaseAddress, readingAddress, e_lfanew, sections);
symbols = buildSymbols(dump, as, imageBaseAddress);
}
if (symbols == null) {
symbols = new LinkedList<ISymbol>();
}
// Load the list of RUNTIME_FUNCTION structures that map code
// ranges to stack unwind information.
List<RuntimeFunction> runtimeFunctionList = null;
runtimeFunctionList = buildRuntimeFunctionList(dump, as, imageBaseAddress);
IModule module;
if (runtimeFunctionList != null) {
module = new UnwindModule(as.getProcesses().iterator().next(), moduleName, symbols, sections, thisModule.imageBaseAddress, properties, runtimeFunctionList);
// Uncommend to dump unwind info as we find it. This is very verbose.
// ((UnwindModule)module).dumpUndwindInfo(System.err);
} else {
module = new Module(as.getProcesses().iterator().next(), moduleName, symbols, sections, thisModule.imageBaseAddress, properties);
}
if (moduleName.toLowerCase().endsWith(".exe")) {
dump.setExecutable(module);
} else {
dump.addLibrary(module);
}
} catch (RuntimeException e) {
// Don't want to prevent RTE's propogating
throw e;
} catch (Exception e) {
// this needs to be here in order to not fail completely whenever we
// encounter a strange record
logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "readFrom", "Problem reading symbols", e);
}
}
}
Aggregations