use of com.ibm.j9ddr.corereaders.memory.IMemoryRange in project openj9 by eclipse.
the class AIXDumpReader method readThread.
// private J9DDRImageThread readThread(J9DDRImageAddressSpace addressSpace,
// long offset) throws IOException
private IOSThread readThread(long offset) throws IOException {
// Note that we appear to be parsing a "struct thrdsinfo" here which is
// described in "/usr/include/procinfo.h"
// however, the shape for 64-bit is somewhat guessed since the structs
// thrdentry64 and thrdsinfo64 (for 64 and 32 bit dumps, respectively),
// which are listed in the documentation, don't appear to be the actual
// structures at work here
seek(offset);
// tid is 64-bits one 64-bit platforms but 32-bits on 32-bit platforms
// unsigned long ti_tid; /* thread identifier */
long tid = readAddress();
// unsigned long ti_pid; /* process identifier */
readInt();
/* scheduler information */
// unsigned long ti_policy; /* scheduling policy */
int ti_policy = readInt();
// unsigned long ti_pri; /* current effective priority */
int ti_pri = readInt();
// unsigned long ti_state; /* thread state -- from thread.h */
int ti_state = readInt();
// unsigned long ti_flag; /* thread flags -- from thread.h */
int ti_flag = readInt();
// unsigned long ti_scount; /* suspend count */
int ti_scount = readInt();
// unsigned long ti_wtype; /* type of thread wait */
int ti_wtype = readInt();
// unsigned long ti_wchan; /* wait channel */
int ti_wchan = readInt();
// unsigned long ti_cpu; /* processor usage */
int ti_cpu = readInt();
// cpu_t ti_cpuid; /* processor on which I'm bound */
int ti_cpuid = readInt();
// sigset_t ti_sigmask /* sigs to be blocked */
readSigset();
// sigset_t ti_sig; /* pending sigs */
readSigset();
// unsigned long ti_code; /* iar of exception */
readInt();
// struct sigcontext *ti_scp; /* sigctx location in userspace */
readAddress();
// char ti_cursig; /* current/last signal taken */
int signalNumber = 0xFF & readByte();
Map<String, Number> registers = readRegisters(offset);
Properties properties = new Properties();
properties.put("scheduling policy", Integer.toHexString(ti_policy));
properties.put("current effective priority", Integer.toHexString(ti_pri));
properties.put("thread state", Integer.toHexString(ti_state));
properties.put("thread flags", Integer.toHexString(ti_flag));
properties.put("suspend count", Integer.toHexString(ti_scount));
properties.put("type of thread wait", Integer.toHexString(ti_wtype));
properties.put("wait channel", Integer.toHexString(ti_wchan));
properties.put("processor usage", Integer.toHexString(ti_cpu));
properties.put("processor on which I'm bound", Integer.toHexString(ti_cpuid));
// the signal number should probably be exposed through a real API for,
// for now, it is interesting info so just return it
properties.put("current/last signal taken", Integer.toHexString(signalNumber));
long stackPointer = getStackPointerFrom(registers);
IMemoryRange range = getProcess().getMemoryRangeForAddress(stackPointer);
if (null == range) {
throw new IOException("Cannot find memory range for stackPointer " + Long.toHexString(stackPointer));
}
IMemoryRange stackRange = new MemoryRange(getProcess().getAddressSpace(), range, "stack");
return new AIXOSThread(getProcess(), tid, Collections.singletonList(stackRange), properties, registers);
}
use of com.ibm.j9ddr.corereaders.memory.IMemoryRange 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.IMemoryRange 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.IMemoryRange in project openj9 by eclipse.
the class MemoryRangesCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
IProcess process = context.process;
String format = "0x%0" + (process.bytesPerPointer() * 2) + "x%" + (16 - process.bytesPerPointer()) + "s";
Collection<? extends IMemoryRange> ranges = process.getMemoryRanges();
if (ranges != null && !ranges.isEmpty()) {
out.println("Base Top Size");
for (IMemoryRange range : ranges) {
out.print(String.format(format, range.getBaseAddress(), " "));
out.print(String.format(format, range.getTopAddress(), " "));
out.print(String.format(format, range.getSize(), " "));
out.print("\n");
}
} else {
out.println("No memory ranges found (Note: this has not yet been implemented for execution from a native debugger such as gdb)");
}
}
use of com.ibm.j9ddr.corereaders.memory.IMemoryRange in project openj9 by eclipse.
the class J9DDRImageModule method getSymbols.
/* (non-Javadoc)
* @see com.ibm.dtfj.image.ImageModule#getSymbols()
*/
public Iterator<?> getSymbols() {
Collection<? extends ISymbol> symbols;
try {
symbols = delegate.getSymbols();
} catch (DataUnavailableException e) {
// JEXTRACT slightly arbitrary code here. DTFJ/JExtract uses the base address of the .text section as the
// address of the corrupt data. We do the same for compatibility's sake.
Collection<? extends IMemoryRange> memoryRanges = delegate.getMemoryRanges();
long baseAddress = 0;
for (IMemoryRange range : memoryRanges) {
if (range.getName().contains(".text")) {
baseAddress = range.getBaseAddress();
break;
}
}
return Collections.singletonList(new J9DDRCorruptData(process, e.getMessage(), baseAddress)).iterator();
}
List<ImageSymbol> dtfjSymbols = new ArrayList<ImageSymbol>(symbols.size());
for (ISymbol symbol : symbols) {
dtfjSymbols.add(new J9DDRImageSymbol(symbol.getName(), new J9DDRImagePointer(process, symbol.getAddress())));
}
return dtfjSymbols.iterator();
}
Aggregations