Search in sources :

Example 1 with J9DDRImageAddressSpace

use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageAddressSpace 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);
    }
}
Also used : IAddressSpace(com.ibm.j9ddr.corereaders.memory.IAddressSpace) J9DDRImageAddressSpace(com.ibm.j9ddr.view.dtfj.image.J9DDRImageAddressSpace) Method(java.lang.reflect.Method) IOException(java.io.IOException) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess) IVMData(com.ibm.j9ddr.IVMData)

Aggregations

IVMData (com.ibm.j9ddr.IVMData)1 IAddressSpace (com.ibm.j9ddr.corereaders.memory.IAddressSpace)1 IProcess (com.ibm.j9ddr.corereaders.memory.IProcess)1 J9DDRImageAddressSpace (com.ibm.j9ddr.view.dtfj.image.J9DDRImageAddressSpace)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1