use of com.ibm.j9ddr.IVMData in project openj9 by eclipse.
the class DDRInteractive method locateRuntimes.
private void locateRuntimes(ICore reader) {
currentCore = reader;
Collection<? extends IAddressSpace> spaces = reader.getAddressSpaces();
for (IAddressSpace thisSpace : spaces) {
// indicates if a context has been allocated for the address space
boolean hasCtxBeenAddedForAS = false;
Collection<? extends IProcess> processes = thisSpace.getProcesses();
for (IProcess thisProcess : processes) {
hasCtxBeenAddedForAS = true;
try {
IVMData vmData = VMDataFactory.getVMData(thisProcess);
if (vmData != null) {
contexts.add(new Context(thisProcess, vmData, nonVMCommands));
} else {
addMissingJVMToContexts(thisProcess);
}
} catch (JVMNotDDREnabledException e) {
addMissingJVMToContexts(thisProcess);
} catch (JVMNotFoundException e) {
addMissingJVMToContexts(thisProcess);
} catch (MissingDDRStructuresException e) {
addMissingJVMToContexts(thisProcess);
} catch (IOException e) {
System.err.println("Problem searching for VMData in process " + thisProcess);
e.printStackTrace();
// put the stack trace to the log
Logger logger = Logger.getLogger(LoggerNames.LOGGER_INTERACTIVE_CONTEXT);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
logger.logp(FINE, null, null, sw.toString());
}
}
if (!hasCtxBeenAddedForAS) {
ASNoProcess as = new ASNoProcess(thisSpace);
addMissingJVMToContexts(as);
}
}
if (contexts.size() == 0) {
throw new RuntimeException("Couldn't find any address spaces in this dump");
} else {
// default to the first address space
currentContext = contexts.get(0);
for (Context ctx : contexts) {
// but if there is one with a JVM in it, set it to that
if (!(ctx.vmData instanceof MissingVMData)) {
currentContext = ctx;
break;
}
}
}
}
use of com.ibm.j9ddr.IVMData in project openj9 by eclipse.
the class DDRInteractive method addMissingJVMToContexts.
private void addMissingJVMToContexts(IProcess thisProcess) {
IVMData novm = new MissingVMData();
Context ctx = new Context(thisProcess, novm, nonVMCommands);
contexts.add(ctx);
}
use of com.ibm.j9ddr.IVMData in project openj9 by eclipse.
the class DDRInteractive method addDDRContextFromDTFJ.
private void addDDRContextFromDTFJ(Object dtfjctx) throws Exception {
Method getAddressSpace = findMethod(dtfjctx.getClass(), "getAddressSpace", (Class<?>[]) null);
Method getProcess = findMethod(dtfjctx.getClass(), "getProcess", (Class<?>[]) null);
Method getRuntime = findMethod(dtfjctx.getClass(), "getRuntime", (Class<?>[]) null);
Object addressSpace = getAddressSpace.invoke(dtfjctx, (Object[]) null);
Object process = getProcess.invoke(dtfjctx, (Object[]) null);
Object runtime = getRuntime.invoke(dtfjctx, (Object[]) null);
if (addressSpace == null) {
throw new IOException("Cannot create a context without an associated address space");
}
if (!(addressSpace instanceof J9DDRImageAddressSpace)) {
throw new UnsupportedOperationException("The supplied DTFJ context is not backed by a DDR implementation");
}
IAddressSpace space = ((J9DDRImageAddressSpace) addressSpace).getIAddressSpace();
IProcess proc = null;
if (process != null) {
proc = ((J9DDRImageProcess) process).getIProcess();
}
if (proc == null) {
ASNoProcess as = new ASNoProcess(space);
addMissingJVMToContexts(as);
return;
}
if (runtime == null) {
addMissingJVMToContexts(proc);
return;
}
// DDR will cache the VM data, so if the DTFJ context has already found it then this should be in the cache
IVMData vmData = VMDataFactory.getVMData(proc);
if (vmData != null) {
contexts.add(new Context(proc, vmData, nonVMCommands));
} else {
addMissingJVMToContexts(proc);
}
}
use of com.ibm.j9ddr.IVMData in project openj9 by eclipse.
the class J9RASImageDataFactory method getRasData.
private static Object getRasData(IProcess p) {
try {
IVMData vmData = VMDataFactory.getVMData(p);
Object[] passBackArray = new Object[1];
try {
vmData.bootstrapRelative("view.dtfj.J9RASInfoBootstrapShim", (Object) passBackArray);
} catch (ClassNotFoundException e) {
// Need to return null here for IDDE as the class will not be found for Node.js cores
return null;
}
return passBackArray[0];
} catch (IOException e) {
// Ignore
} catch (UnsupportedOperationException e) {
// VMDataFactory may throw unsupported UnsupportedOperationException
// exceptions for JVM's DDR does not support.
} catch (Exception e) {
// Ignore
}
return null;
}
use of com.ibm.j9ddr.IVMData in project openj9 by eclipse.
the class J9DDRImageProcess method getRuntimes.
public Iterator<?> getRuntimes() {
List<Object> toIterate = new LinkedList<Object>();
try {
IVMData data = VMDataFactory.getVMData(process);
version = data.getVersion();
Object[] passbackArray = new Object[1];
try {
// attempt to load a default bootstrap class which will allow different implementations to provide their own initialisers
data.bootstrapRelative("view.dtfj.DTFJBootstrapShim", (Object) passbackArray, this);
} catch (ClassNotFoundException e) {
// no specific class was found, so use a generic native one instead
try {
data.bootstrap("com.ibm.j9ddr.view.nativert.Bootstrap", (Object) passbackArray, this);
} catch (ClassNotFoundException e1) {
// this class should be packaged and without it we can't work, so abort
throw new Error(e1);
}
}
if (passbackArray[0] != null) {
toIterate.add(passbackArray[0]);
}
} catch (IOException e) {
// VMDataFactory may throw IOException for JVMs that this level of DDR does not support. Pass the
// detail message in a CDE. The underlying exception will have been logged in VMDataFactory.
toIterate.add(new J9DDRCorruptData(process, "Unsupported JVM level: " + e.getMessage()));
} catch (UnsupportedOperationException e) {
// VMDataFactory may throw unsupported UnsupportedOperationException
// exceptions for JVM's DDR does not support.
toIterate.add(new J9DDRCorruptData(process, "Unsupported JVM level"));
} catch (Exception e) {
toIterate.add(new J9DDRCorruptData(process, e.getMessage()));
}
return toIterate.iterator();
}
Aggregations