Search in sources :

Example 1 with ManagedRuntime

use of com.ibm.dtfj.runtime.ManagedRuntime 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 2 with ManagedRuntime

use of com.ibm.dtfj.runtime.ManagedRuntime in project openj9 by eclipse.

the class ManagedRuntimeComparator method testEquals.

/* (non-Javadoc)
	 * @see com.ibm.j9ddr.view.dtfj.test.DTFJComparator#testEquals(java.lang.Object, java.lang.Object, int)
	 */
@Override
public void testEquals(Object ddrObject, Object jextractObject, int members) {
    ManagedRuntime ddrRuntime = (ManagedRuntime) ddrObject;
    ManagedRuntime jextractRuntime = (ManagedRuntime) jextractObject;
    // getVersion()
    if ((VERSION & members) != 0) {
        testJavaEquals(ddrRuntime, jextractRuntime, "getVersion");
    }
    // getFullVersion
    if ((FULL_VERSION & members) != 0) {
        testJavaEquals(ddrRuntime, jextractRuntime, "getFullVersion");
    }
}
Also used : ManagedRuntime(com.ibm.dtfj.runtime.ManagedRuntime)

Example 3 with ManagedRuntime

use of com.ibm.dtfj.runtime.ManagedRuntime in project openj9 by eclipse.

the class PHDImageAddressSpace method getImageSections.

public Iterator<ImageSection> getImageSections() {
    List<ImageSection> list = new ArrayList<ImageSection>();
    for (Iterator<ImageProcess> ip = getProcesses(); ip.hasNext(); ) {
        ImageProcess p = ip.next();
        if (p instanceof CorruptData)
            continue;
        for (Iterator<ManagedRuntime> jr = p.getRuntimes(); jr.hasNext(); ) {
            ManagedRuntime mr = jr.next();
            if (mr instanceof CorruptData)
                continue;
            if (mr instanceof JavaRuntime) {
                for (Iterator<JavaHeap> jh = ((JavaRuntime) mr).getHeaps(); jh.hasNext(); ) {
                    JavaHeap hp = jh.next();
                    if (hp instanceof CorruptData)
                        continue;
                    for (Iterator<ImageSection> is = hp.getSections(); is.hasNext(); ) {
                        // Add the corrupt sections too
                        list.add(is.next());
                    }
                }
            }
        }
    }
    if (metaImageAddressSpace != null) {
        for (Iterator it = metaImageAddressSpace.getImageSections(); it.hasNext(); ) {
            Object next = it.next();
            if (next instanceof ImageSection) {
                ImageSection section = (ImageSection) next;
                ImageSection newSection = new PHDImageSection(section.getName(), getPointer(section.getBaseAddress().getAddress()), section.getSize());
                list.add(newSection);
            }
        }
    }
    return list.iterator();
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaHeap(com.ibm.dtfj.java.JavaHeap) ArrayList(java.util.ArrayList) ImageSection(com.ibm.dtfj.image.ImageSection) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) CorruptData(com.ibm.dtfj.image.CorruptData) ManagedRuntime(com.ibm.dtfj.runtime.ManagedRuntime)

Example 4 with ManagedRuntime

use of com.ibm.dtfj.runtime.ManagedRuntime in project openj9 by eclipse.

the class Utils method getRuntimes.

public static Iterator getRuntimes(Image loadedImage) {
    Vector runtimes = new Vector();
    Iterator itAddressSpace;
    Iterator itProcess;
    Iterator itRuntime;
    ManagedRuntime mr;
    ImageAddressSpace ias;
    ImageProcess ip;
    itAddressSpace = loadedImage.getAddressSpaces();
    while (itAddressSpace.hasNext()) {
        ias = (ImageAddressSpace) itAddressSpace.next();
        itProcess = ias.getProcesses();
        while (itProcess.hasNext()) {
            ip = (ImageProcess) itProcess.next();
            itRuntime = ip.getRuntimes();
            while (itRuntime.hasNext()) {
                // this iterator can contain ManagedRuntime or CorruptData objects
                Object next = itRuntime.next();
                if (next instanceof CorruptData) {
                    // skip any CorruptData objects
                    continue;
                } else {
                    mr = (ManagedRuntime) next;
                    if (!runtimes.contains(mr))
                        runtimes.add(mr);
                }
            }
        }
    }
    return runtimes.iterator();
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) Vector(java.util.Vector) ManagedRuntime(com.ibm.dtfj.runtime.ManagedRuntime)

Aggregations

ManagedRuntime (com.ibm.dtfj.runtime.ManagedRuntime)4 CorruptData (com.ibm.dtfj.image.CorruptData)3 Iterator (java.util.Iterator)3 ImageProcess (com.ibm.dtfj.image.ImageProcess)2 JavaObject (com.ibm.dtfj.java.JavaObject)2 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)2 ArrayList (java.util.ArrayList)2 DTFJException (com.ibm.dtfj.image.DTFJException)1 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)1 ImageSection (com.ibm.dtfj.image.ImageSection)1 ImageThread (com.ibm.dtfj.image.ImageThread)1 JavaHeap (com.ibm.dtfj.java.JavaHeap)1 JavaThread (com.ibm.dtfj.java.JavaThread)1 StateToString (com.ibm.jvm.dtfjview.commands.helpers.StateToString)1 ThreadData (com.ibm.jvm.dtfjview.commands.helpers.ThreadData)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Vector (java.util.Vector)1