use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class DTFJUnitTest method buildContext.
private static TestContext buildContext(ImageFactory imageFactory, File coreFile) throws IOException {
TestContext ctx = new DTFJUnitTest.TestContext();
Image image = imageFactory.getImage(coreFile);
ctx.setImage(image);
Iterator<?> addressSpaceIt = image.getAddressSpaces();
while (addressSpaceIt.hasNext()) {
Object asObj = addressSpaceIt.next();
if (asObj instanceof CorruptData) {
System.err.println("Corrupt AddressSpace returned: " + asObj);
} else if (asObj instanceof ImageAddressSpace) {
ImageAddressSpace as = (ImageAddressSpace) asObj;
ctx.setSpace(as);
Iterator<?> processIterator = as.getProcesses();
while (processIterator.hasNext()) {
Object processObj = processIterator.next();
if (processObj instanceof CorruptData) {
System.err.println("Corrupt ImageProcess returned: " + asObj);
} else if (processObj instanceof ImageProcess) {
ImageProcess process = (ImageProcess) processObj;
ctx.setProcess(process);
Iterator<?> runtimeIterator = process.getRuntimes();
while (runtimeIterator.hasNext()) {
Object runtimeObj = runtimeIterator.next();
if (runtimeObj instanceof CorruptData) {
System.err.println("Corrupt ImageProcess returned: " + asObj);
} else if (runtimeObj instanceof JavaRuntime) {
JavaRuntime runtime = (JavaRuntime) runtimeObj;
ctx.setRuntime(runtime);
return ctx;
} else {
throw new ClassCastException("Unexpected type from Runtime iterator: " + runtimeObj.getClass() + ": " + runtimeObj);
}
}
} else {
throw new ClassCastException("Unexpected type from Process iterator: " + processObj.getClass() + ": " + processObj);
}
}
} else {
throw new ClassCastException("Unexpected type from AddressSpace iterator: " + asObj.getClass() + ": " + asObj);
}
}
throw new RuntimeException("Could not find a Java Runtime");
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class JCImageAddressSpace method getCurrentProcess.
/**
* At the moment, just the last process to be added
*/
public ImageProcess getCurrentProcess() {
ImageProcess currentProcess = null;
int size = fProcesses.size();
if (size > 0) {
currentProcess = (ImageProcess) fProcesses.get(size - 1);
}
return currentProcess;
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class Utils method _extractAddressSpace.
// CMVC 175488 : fixed so that this function returns an address space which contains a process
// rather than the first address space it finds.
public static ImageAddressSpace _extractAddressSpace(Image loadedImage) {
ImageAddressSpace space = null;
Iterator spaces = loadedImage.getAddressSpaces();
// object returned through DTFJ iterators
Object obj = null;
while (spaces.hasNext()) {
obj = spaces.next();
if (obj instanceof ImageAddressSpace) {
space = (ImageAddressSpace) obj;
Iterator procs = space.getProcesses();
while (procs.hasNext()) {
obj = procs.next();
if (obj instanceof ImageProcess) {
return space;
}
}
}
}
// failed to find an address space which contains a process.
return null;
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class InfoThreadCommand method printProcessInfo.
private void printProcessInfo(String id, Map threads) {
Iterator itProcess;
ImageProcess ip;
boolean found = false;
ip = ctx.getProcess();
_pointerSize = ip.getPointerSize();
out.print(" process id: ");
try {
out.print(ip.getID());
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
}
out.print("\n\n");
found = printThreadInfo(id, threads);
if (!found) {
out.print(" no native threads found with specified id\n");
}
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class InfoProcCommand method printCommandLine.
private void printCommandLine() {
ImageProcess ip = ctx.getProcess();
out.print("\t Command line:\n\t ");
try {
String commandLine = ip.getCommandLine();
if (null == commandLine)
out.print("<null>");
else
out.print(commandLine);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
} catch (DataUnavailable e) {
out.print("Could not determine command line");
}
out.println();
out.println();
// Print the VM initialization options, similar to javacore.
try {
JavaVMInitArgs args = ctx.getRuntime().getJavaVMInitArgs();
if (args != null) {
out.print("\t Java VM init options: ");
Iterator<?> opts = args.getOptions();
while (opts.hasNext()) {
out.println();
Object obj = opts.next();
if (obj instanceof JavaVMOption) {
JavaVMOption opt = (JavaVMOption) obj;
out.print("\t " + opt.getOptionString());
if (opt.getExtraInfo().getAddress() != 0) {
out.print(" " + Utils.toHex(opt.getExtraInfo()));
}
}
}
} else {
out.print(Exceptions.getDataUnavailableString());
}
} catch (Exception cde) {
// in the event of an exception getting the VM init options, just print the original message
out.print(Exceptions.getDataUnavailableString());
}
out.print("\n");
}
Aggregations