Search in sources :

Example 1 with IVMData

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;
            }
        }
    }
}
Also used : IAddressSpace(com.ibm.j9ddr.corereaders.memory.IAddressSpace) IOException(java.io.IOException) Logger(java.util.logging.Logger) IVMData(com.ibm.j9ddr.IVMData) JVMNotDDREnabledException(com.ibm.j9ddr.exceptions.JVMNotDDREnabledException) JVMNotFoundException(com.ibm.j9ddr.exceptions.JVMNotFoundException) StringWriter(java.io.StringWriter) MissingDDRStructuresException(com.ibm.j9ddr.exceptions.MissingDDRStructuresException) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess) PrintWriter(java.io.PrintWriter)

Example 2 with IVMData

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);
}
Also used : IVMData(com.ibm.j9ddr.IVMData)

Example 3 with IVMData

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);
    }
}
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)

Example 4 with IVMData

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;
}
Also used : IOException(java.io.IOException) DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IVMData(com.ibm.j9ddr.IVMData)

Example 5 with IVMData

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();
}
Also used : IOException(java.io.IOException) LinkedList(java.util.LinkedList) DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) IOException(java.io.IOException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) IVMData(com.ibm.j9ddr.IVMData)

Aggregations

IVMData (com.ibm.j9ddr.IVMData)6 IOException (java.io.IOException)4 IAddressSpace (com.ibm.j9ddr.corereaders.memory.IAddressSpace)3 DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)2 IProcess (com.ibm.j9ddr.corereaders.memory.IProcess)2 LinkedList (java.util.LinkedList)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 ICore (com.ibm.j9ddr.corereaders.ICore)1 JVMNotDDREnabledException (com.ibm.j9ddr.exceptions.JVMNotDDREnabledException)1 JVMNotFoundException (com.ibm.j9ddr.exceptions.JVMNotFoundException)1 MissingDDRStructuresException (com.ibm.j9ddr.exceptions.MissingDDRStructuresException)1 DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)1 J9DDRImageAddressSpace (com.ibm.j9ddr.view.dtfj.image.J9DDRImageAddressSpace)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Logger (java.util.logging.Logger)1