use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class NativeLibrariesCommand method showLibList.
// list the libraries from the core file and report whether or not they have been collected
private void showLibList(Context ctx, PrintStream out) {
LibReader reader = new LibReader();
out.println("Showing library list for " + DDRInteractive.getPath());
Collection<? extends IModule> libs = null;
try {
libs = ctx.process.getModules();
} catch (CorruptDataException e) {
out.println("Corrupt data exception when retrieving list of libraries : " + e.getMessage());
return;
}
getExeFromDDR(ctx, out);
for (IModule lib : libs) {
try {
out.println("Lib : " + lib.getName());
FooterLibraryEntry entry = reader.getEntry(lib.getName());
if (entry == null) {
out.println("\tLibrary is not appended to the core file, it may be present on the local disk");
} else {
out.println("\tLibrary has been collected");
out.println("\tPath : " + entry.getPath());
out.println("\tName : " + entry.getName());
out.println("\tSize : " + entry.getSize());
}
} catch (CorruptDataException e) {
out.println("Library name is corrupt");
}
}
}
use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class DDRSymbolFinder method addVoidPointersAsSymbols.
private static void addVoidPointersAsSymbols(String structureName, long structureAddress, StructureReader structureReader, IProcess process) throws DataUnavailableException, CorruptDataException {
if (structureAddress == 0) {
return;
}
List<String> voidFields = getVoidPointerFieldsFromStructure(structureReader, structureName);
if (voidFields == null) {
return;
}
// Format the hex and structure name the same as the rest of DDR.
int paddingSize = process.bytesPerPointer() * 2;
String formatString = "[!%s 0x%0" + paddingSize + "X->%s]";
for (String field : voidFields) {
if (ignoredSymbols.contains(structureName + "." + field)) {
// Ignore this field, it's not a function.
continue;
}
long functionAddress = followPointerFromStructure(structureName, structureAddress, field, structureReader, process);
if (functionAddress == 0) {
// Skip null pointers.
continue;
}
// Lower case the structure name to match the rest of the DDR !<struct> commands.
String symName = String.format(formatString, structureName.toLowerCase(), structureAddress, field);
if (functionAddress == 0) {
// Null pointer, possibly unset or no longer used.
continue;
}
if (addSymbols) {
IModule module = getModuleForInstructionAddress(process, functionAddress);
if (module == null) {
continue;
}
boolean found = false;
// Don't override/duplicate symbols we've already seen.
for (ISymbol sym : module.getSymbols()) {
if (sym.getAddress() == functionAddress) {
Logger logger = Logger.getLogger(LoggerNames.LOGGER_STRUCTURE_READER);
logger.log(FINER, "DDRSymbolFinder: Found exact match with " + sym.toString() + " not adding.");
found = true;
break;
}
}
if (!found) {
Logger logger = Logger.getLogger(LoggerNames.LOGGER_STRUCTURE_READER);
logger.log(FINER, "DDRSymbolFinder: Adding new DDR symbol " + symName);
SymbolUtil.addDDRSymbolToModule(module, "[" + field + "]", symName, functionAddress);
}
}
}
}
use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class AIXDumpReader method loadModule.
private void loadModule(ILibraryResolver resolver, IProcess proc, long textVirtualAddress, long textSize, long dataVirtualAddress, long dataSize, String fileName, String objectName, String moduleName, boolean loadingExecutable) {
// .data range will be loaded in core. .text range will be in the module itself.
IMemoryRange data = new MemoryRange(proc.getAddressSpace(), dataVirtualAddress, dataSize, ".data");
IModule module;
IMemorySource text;
try {
LibraryDataSource library = null;
if (loadingExecutable) {
library = resolver.getLibrary(fileName, true);
} else {
library = resolver.getLibrary(fileName);
}
IModuleFile moduleFile = loadModuleFile(library, objectName);
text = moduleFile.getTextSegment(textVirtualAddress, textSize);
List<? extends ISymbol> symbols = moduleFile.getSymbols(textVirtualAddress);
List<IMemoryRange> moduleMemoryRanges = new LinkedList<IMemoryRange>();
moduleMemoryRanges.add(text);
moduleMemoryRanges.add(data);
module = new Module(proc, moduleName, symbols, moduleMemoryRanges, textVirtualAddress, moduleFile.getProperties());
} catch (Exception e) {
// Create a non-backed memory range for the text segment (so we know it exists)
text = new UnbackedMemorySource(textVirtualAddress, textSize, "Native library " + moduleName + " couldn't be found", 0, ".text");
List<IMemoryRange> moduleMemoryRanges = new LinkedList<IMemoryRange>();
moduleMemoryRanges.add(text);
moduleMemoryRanges.add(data);
// Can't find the library - put a stub in with the information we have.
module = new MissingFileModule(proc, moduleName, moduleMemoryRanges);
}
// Add .text to _memoryRanges so it becomes part of the native address space.
addMemorySource(text);
if (loadingExecutable) {
_executable = module;
_executableTextSection = text;
} else {
_modules.add(module);
}
}
use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class ELFDumpReader method close.
public void close() throws IOException {
// close the handle to the dump
_reader.close();
// now close any open module handles
if ((_executable != null) && (_executable instanceof ELFFileReader)) {
((ELFFileReader) _executable).is.close();
}
for (IModule module : _modules) {
if (module instanceof ELFFileReader) {
((ELFFileReader) module).is.close();
}
}
// close any tracked open files
for (ELFFileReader reader : openFileTracker) {
if (reader != null) {
reader.close();
}
}
// release any resources acquired for library resolution
_resolver.dispose();
}
use of com.ibm.j9ddr.corereaders.memory.IModule in project openj9 by eclipse.
the class MiniDumpReader method parseStreams.
private void parseStreams() throws IOException, CorruptCoreException {
seek(_streamDirectoryRva);
List<EarlyInitializedStream> earlyStreams = new LinkedList<EarlyInitializedStream>();
for (int i = 0; i < _numberOfStreams; i++) {
int streamType = readInt();
int dataSize = readInt();
// TODO: should location be a long?
// long location = (readInt() << 32) + rva1;
int location = readInt();
switch(streamType) {
case Stream.THREADLIST:
threadStreams.add(new ThreadStream(dataSize, location));
break;
case Stream.MODULELIST:
moduleStreams.add(new ModuleStream(dataSize, location));
break;
case Stream.SYSTEMINFO:
// Needs to go at the front - we rely on it to tell us the
// pointer size
earlyStreams.add(0, new SystemInfoStream(dataSize, location));
break;
case Stream.MEMORY64LIST:
earlyStreams.add(new Memory64Stream(dataSize, location));
break;
case Stream.MISCINFO:
earlyStreams.add(new MiscInfoStream(dataSize, location));
break;
case Stream.THREADINFO:
threadInfoStreams.add(new ThreadInfoStream(dataSize, location));
break;
case Stream.MEMORYINFO:
memoryInfoStreams.add(new MemoryInfoStream(dataSize, location));
break;
}
}
for (EarlyInitializedStream entry : earlyStreams) {
entry.readFrom(this);
int ptrSize = entry.readPtrSize(this);
if (0 != ptrSize) {
_is64bit = ptrSize == 64 ? true : false;
}
}
for (MemoryInfoStream entry : memoryInfoStreams) {
entry.readFrom(this, is64Bit(), _memoryRanges);
}
// and user32, so any WOW64 process will have at least these 5 loaded.
if (_is64bit) {
int wowCount = 0;
for (IModule module : getModules()) {
try {
String modName = module.getName().toLowerCase();
if (modName.contains("syswow64")) {
wowCount++;
}
} catch (CorruptDataException e) {
// Silently ignore for now, and report when the user actually wants to read the modules.
}
}
if (wowCount > 5) {
_is64bit = false;
// A side effect of loading the modules above is that we must (later) reconstruct the address spaces.
addressSpaces = null;
}
}
}
Aggregations