Search in sources :

Example 1 with JavaRuntime

use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.

the class DTFJHeapUnitTest method setUp.

@Before
public void setUp() throws Exception {
    File core = parseCoreFilePath(getSystemProperty(PROPERTY_CORE_FILE_PATH));
    File output = new File(getSystemProperty(PROPERTY_OUTPUT_PATH));
    if (!output.exists()) {
        output.mkdirs();
    }
    JavaRuntime rt = getRuntime(core);
    File jxoutput = new File(output, "dtfj.xml");
    filesToCompare[0] = jxoutput.getPath();
    generateXML(jxoutput, rt);
    testJ9DDR = true;
    rt = getRuntime(core);
    File ddroutput = new File(output, "ddr.xml");
    filesToCompare[1] = ddroutput.getPath();
    generateXML(ddroutput, rt);
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) File(java.io.File) Before(org.junit.Before)

Example 2 with JavaRuntime

use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.

the class JExtractXMLGenerator method generate.

/**
 * Generate a JExtract compatible XML file
 */
public void generate() {
    try {
        xml.append("<j9dump>\n");
        JavaRuntime rt = getRuntime();
        generateJavaVM(rt);
        xml.append("</j9dump>\n");
    } catch (Exception e) {
        // catch all errors and write out what data we have so far
        System.err.println("Error generating XML : " + e.getMessage());
        e.printStackTrace();
    }
    createOutputFile();
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime)

Example 3 with JavaRuntime

use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.

the class ImageFactory method hasJavaRuntime.

/**
 * Checks to see if the supplied image has an available DTFJ Java Runtime. This is to force the parsing of the jextract XML
 * for legacy DTFJ and blob parsing for DDR. It does not make any guarantees about the quality and availability of the
 * run time data.
 * @return true if a non-corrupt runtime is returned
 */
private static boolean hasJavaRuntime(ImageReference imageReference) {
    if (null == imageReference || null == imageReference.image) {
        return false;
    }
    Iterator<?> spaces = imageReference.image.getAddressSpaces();
    while ((null != spaces) && spaces.hasNext()) {
        // search address spaces
        Object obj = spaces.next();
        if ((null != obj) && (obj instanceof ImageAddressSpace)) {
            ImageAddressSpace space = (ImageAddressSpace) obj;
            Iterator<?> procs = space.getProcesses();
            while ((null != procs) && procs.hasNext()) {
                // search processes
                Object procobj = procs.next();
                if ((null != procobj) && (procobj instanceof ImageProcess)) {
                    ImageProcess proc = (ImageProcess) procobj;
                    Iterator<?> runtimes = proc.getRuntimes();
                    while ((null != runtimes) && runtimes.hasNext()) {
                        Object rtobj = runtimes.next();
                        if ((null != rtobj) && (rtobj instanceof JavaRuntime)) {
                            // found a non-corrupt java runtime
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) JavaRuntime(com.ibm.dtfj.java.JavaRuntime) ImageProcess(com.ibm.dtfj.image.ImageProcess)

Example 4 with JavaRuntime

use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.

the class InfoThreadCommand method getJavaThreads.

private Map getJavaThreads(String id) {
    Map threads = new HashMap();
    ManagedRuntime mr = ctx.getRuntime();
    if (mr instanceof JavaRuntime) {
        JavaRuntime jr = (JavaRuntime) mr;
        Iterator itThread = jr.getThreads();
        while (itThread.hasNext()) {
            Object next = itThread.next();
            // skip any corrupt threads
            if (next instanceof CorruptData)
                continue;
            JavaThread jt = (JavaThread) next;
            // Obtain the native thread ID for this thread, and for zOS also obtain the TCB
            String currentTID = null;
            String currentTCB = null;
            try {
                ImageThread it = jt.getImageThread();
                currentTID = it.getID();
                if (_is_zOS) {
                    currentTCB = it.getProperties().getProperty("TCB");
                }
            } catch (DTFJException e) {
            // Continue with what we have obtained so far
            }
            if (null == id) {
                // save all orphaned java threads in a list within the hashmap
                if (null == currentTID) {
                    if (threads.containsKey(null)) {
                        ArrayList ta = (ArrayList) threads.get(null);
                        ta.add(new ThreadData(jt, jr));
                    } else {
                        ArrayList ta = new ArrayList(1);
                        ta.add(new ThreadData(jt, jr));
                        threads.put(null, ta);
                    }
                } else {
                    threads.put(currentTID, new ThreadData(jt, jr));
                }
            } else if (id.equalsIgnoreCase(currentTID) || id.equalsIgnoreCase(currentTCB)) {
                // We just want the specific Java thread that matches the native thread ID or zOS TCB
                threads.put(currentTID, new ThreadData(jt, jr));
            }
        }
    }
    return threads;
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) HashMap(java.util.HashMap) DTFJException(com.ibm.dtfj.image.DTFJException) ArrayList(java.util.ArrayList) StateToString(com.ibm.jvm.dtfjview.commands.helpers.StateToString) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) ImageThread(com.ibm.dtfj.image.ImageThread) HashMap(java.util.HashMap) Map(java.util.Map) ManagedRuntime(com.ibm.dtfj.runtime.ManagedRuntime) ThreadData(com.ibm.jvm.dtfjview.commands.helpers.ThreadData)

Example 5 with JavaRuntime

use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.

the class JavaRuntimeComparator method testEquals.

// getCompiledMethods()
// getHeapRoots()
// getHeaps()
// getJavaClassLoaders()
// getJavaVM()
// getJavaVMInitArgs()
// getMonitors()
// getThreads()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
    JavaRuntime ddrJavaRuntime = (JavaRuntime) ddrObject;
    JavaRuntime jextractJavaRuntime = (JavaRuntime) jextractObject;
    // getCompiledMethods()
    if ((COMPILED_METHODS & members) != 0)
        new JavaMethodComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getCompiledMethods", JavaMethod.class);
    // getHeaps()
    if ((HEAPS & members) != 0)
        new JavaHeapComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getHeaps", JavaHeap.class);
    // getJavaClassLoaders()
    if ((JAVA_CLASS_LOADERS & members) != 0)
        new JavaClassLoaderComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getJavaClassLoaders", JavaClassLoader.class);
    // getJavaVM()
    if ((JAVA_VM & members) != 0)
        new ImagePointerComparator().testComparatorEquals(ddrJavaRuntime, jextractJavaRuntime, "getJavaVM");
    // getJavaVMInitArgs()
    if ((JAVA_VM_INIT_ARGS & members) != 0)
        new JavaVMInitArgsComparator().testComparatorEquals(ddrJavaRuntime, jextractJavaRuntime, "getJavaVMInitArgs");
    // getMonitors()
    if ((MONITORS & members) != 0)
        new JavaMonitorComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getMonitors", JavaMonitor.class);
    // getThreads()
    if ((THREADS & members) != 0)
        new JavaThreadComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getThreads", JavaThread.class);
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaHeap(com.ibm.dtfj.java.JavaHeap) JavaMonitor(com.ibm.dtfj.java.JavaMonitor) JavaClassLoader(com.ibm.dtfj.java.JavaClassLoader) JavaMethod(com.ibm.dtfj.java.JavaMethod) JavaThread(com.ibm.dtfj.java.JavaThread)

Aggregations

JavaRuntime (com.ibm.dtfj.java.JavaRuntime)27 Iterator (java.util.Iterator)13 JavaObject (com.ibm.dtfj.java.JavaObject)10 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)8 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)8 ImageProcess (com.ibm.dtfj.image.ImageProcess)8 CorruptData (com.ibm.dtfj.image.CorruptData)7 JavaClass (com.ibm.dtfj.java.JavaClass)6 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)5 Image (com.ibm.dtfj.image.Image)5 JavaHeap (com.ibm.dtfj.java.JavaHeap)5 JavaThread (com.ibm.dtfj.java.JavaThread)5 File (java.io.File)4 HashMap (java.util.HashMap)4 ImageFactory (com.ibm.dtfj.image.ImageFactory)3 JavaClassLoader (com.ibm.dtfj.java.JavaClassLoader)3 JavaMonitor (com.ibm.dtfj.java.JavaMonitor)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ImageSection (com.ibm.dtfj.image.ImageSection)2