use of com.ibm.j9ddr.corereaders.memory.IModule 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.memory.IModule 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);
}
}
}
use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class WindowsProcessAddressSpace method getEnvironmentSymbols.
/**
* This method returns a list of symbols with the name "_environ"
*
* @return LinkedList instance of symbols with the name "_environ"
* @throws CorruptDataException
*/
private LinkedList<ISymbol> getEnvironmentSymbols() throws CorruptDataException {
List<IModule> modules = getModules();
LinkedList<ISymbol> symbols = new LinkedList<ISymbol>();
for (IModule thisModule : modules) {
try {
for (ISymbol thisSymbol : thisModule.getSymbols()) {
if (thisSymbol.getName().equals("_environ")) {
symbols.add(thisSymbol);
}
}
} catch (DataUnavailableException e) {
continue;
}
}
return symbols;
}
use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class J9DDRImageProcess method getLibraries.
public Iterator<?> getLibraries() throws DataUnavailable, CorruptDataException {
try {
Collection<? extends IModule> modules = process.getModules();
List<ImageModule> libraries = new ArrayList<ImageModule>();
for (IModule module : modules) {
libraries.add(new J9DDRImageModule(process, module));
}
return libraries.iterator();
} catch (com.ibm.j9ddr.CorruptDataException e) {
throw new DTFJCorruptDataException(new J9DDRCorruptData(process, e));
}
}
Aggregations