use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class AIXDumpReader method loadUserInfo.
private void loadUserInfo() throws IOException, MemoryFault {
if (!_userInfoLoaded) {
seek(userInfoOffset());
_pid = readInt();
// Get the process command line. For AIX dumps we find the registers in
// the initial (top - this is to be consistent with AIX headers)
// stack frame. Register 3 has the number of command line arguments
// (argc), register 4 has
// a pointer to a list of pointers to the command line arguments (argv),
// and register 5 contains the pointer to the environment vars
IProcess memory = getProcess();
long workingAddress = _structTopOfStackVirtualAddress;
int pointerSize = pointerSize() / 8;
// Ignore GPR0-2
workingAddress += (2 * pointerSize);
// argc
long reg3 = memory.getPointerAt(workingAddress += pointerSize);
// argv
_argv = memory.getPointerAt(workingAddress += pointerSize);
// env
_environmentHandle = memory.getPointerAt(workingAddress += pointerSize);
// truncate to integer
_argc = (int) reg3;
_userInfoLoaded = true;
}
}
use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class AIXDumpReader method getCommandLine.
String getCommandLine() throws CorruptDataException {
try {
loadUserInfo();
} catch (IOException e1) {
throw new CorruptDataException(e1);
}
IProcess memory = getProcess();
int pointerSize = pointerSize() / 8;
if (_argc > 100) {
throw new CorruptDataException("Argc too high. Likely corrupt data. Argc=" + _argc + " structTopOfStackVirtualAddress = 0x" + Long.toHexString(_structTopOfStackVirtualAddress));
}
long[] addresses = new long[_argc];
for (int i = 0; i < _argc; i++) {
addresses[i] = memory.getPointerAt(_argv + (i * pointerSize));
}
StringBuffer commandLine = new StringBuffer();
for (int i = 0; i < _argc; i++) {
try {
long startingAddress = addresses[i];
long workingAddress = startingAddress;
while (memory.getByteAt(workingAddress) != 0) {
workingAddress++;
}
int stringLength = (int) (workingAddress - startingAddress);
byte[] buffer = new byte[stringLength];
memory.getBytesAt(startingAddress, buffer);
commandLine.append(new String(buffer, "ASCII"));
commandLine.append(" ");
} catch (MemoryFault e) {
commandLine.append(" <Fault reading argv[" + i + "] at 0x" + Long.toHexString(addresses[i]) + ">");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return commandLine.toString();
}
use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class AIXDumpReader method executablePathHint.
// Passback of executable path. If we couldn't load the executable the first time, try again now.
public void executablePathHint(String path) {
if (_executable instanceof MissingFileModule) {
// Check the hint points at the same file name
try {
if (!getFileName(_executable.getName()).equals(getFileName(path))) {
return;
}
} catch (CorruptDataException e1) {
return;
}
// Remove placeholder memory source
_process.removeMemorySource(_executableTextSection);
// Remember the current placeholder in case this one fails too
IModule currentExecutable = _executable;
IMemorySource currentExecutableTextSection = _executableTextSection;
ILibraryResolver resolver = LibraryResolverFactory.getResolverForCoreFile(this.coreFile);
IProcess proc = getProcess();
try {
seek(_loaderOffset);
readInt();
// Ignore flags
readLoaderInfoFlags();
// Ignore dataOffset
readAddress();
long textVirtualAddress = readAddress();
long textSize = readAddress();
long dataVirtualAddress = readAddress();
long dataSize = readAddress();
// Disregard fileName from core
readString();
String fileName = path;
String objectName = readString();
String moduleName = fileName;
if (0 < objectName.length()) {
moduleName += "(" + objectName + ")";
}
loadModule(resolver, proc, textVirtualAddress, textSize, dataVirtualAddress, dataSize, fileName, objectName, moduleName, true);
} catch (IOException e) {
// TODO handle
}
// If the executable is still a MissingFileModule, the hint didn't work
if (_executable instanceof MissingFileModule) {
_process.removeMemorySource(_executableTextSection);
_executableTextSection = currentExecutableTextSection;
_process.addMemorySource(_executableTextSection);
_executable = currentExecutable;
}
}
}
use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class JniReader method getAddressSpaces.
/**
* This method creates JNI address space and puts it into collection instance.
*
* @return Collection of address spaces
*/
public Collection<? extends IAddressSpace> getAddressSpaces() {
if (null == addressSpaces) {
addressSpaces = new ArrayList<IAddressSpace>(1);
JniAddressSpace addressSpace = new JniAddressSpace(0, this);
Iterator<? extends IProcess> ite = addressSpace.getProcesses().iterator();
if (ite.hasNext()) {
IProcess process = ite.next();
/* This is sanity check. It should always be the JniProcess instance */
if (process instanceof JniProcess) {
JniProcess jniProcess = (JniProcess) process;
/* Set ICore.PROCESSOR_TYPE_PROPERTY in the properties by checking the target architecture */
int targetArchitecture = jniProcess.getTargetArchitecture();
switch(targetArchitecture) {
case JniProcess.TARGET_TYPE_X86_32:
properties.setProperty(ICore.PROCESSOR_TYPE_PROPERTY, "x86");
break;
case JniProcess.TARGET_TYPE_X86_64:
properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "amd64");
break;
case JniProcess.TARGET_TYPE_S390_31:
case JniProcess.TARGET_TYPE_S390_64:
properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "s390");
break;
case JniProcess.TARGET_TYPE_PPC_32:
case JniProcess.TARGET_TYPE_PPC_64:
properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "ppc");
break;
default:
}
}
}
addressSpaces.add(addressSpace);
}
return addressSpaces;
}
use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class ThreadStream method readFrom.
@Override
public void readFrom(MiniDumpReader dump, IAddressSpace addressSpace, boolean is64Bit) throws CorruptDataException, IOException {
dump.seek(getLocation());
int numberOfThreads = dump.readInt();
if (numberOfThreads > 100000) {
throw new CorruptDataException("Unlikely number of threads found in dump: " + numberOfThreads + ". Suspect data corruption");
}
for (int i = 0; i < numberOfThreads; i++) {
dump.seek(getLocation() + 4 + i * 48);
int threadId = dump.readInt();
// Ignore suspendCount
dump.readInt();
int priorityClass = dump.readInt();
int priority = dump.readInt();
// Ignore teb
dump.readLong();
long stackStart = dump.readLong();
long stackSize = 0xFFFFFFFFL & dump.readInt();
long stackRva = 0xFFFFFFFFL & dump.readInt();
// contextDataSize
dump.readInt();
long contextRva = 0xFFFFFFFFL & dump.readInt();
Properties properties = new Properties();
properties.setProperty("priorityClass", String.valueOf(priorityClass));
properties.setProperty("priority", String.valueOf(priority));
dump.addThread(new WindowsOSThread(threadId, stackStart, stackSize, stackRva, contextRva, properties, dump, (IProcess) addressSpace));
}
}
Aggregations