Search in sources :

Example 21 with JavaThread

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

the class InfoLockCommand method showSystemLocks.

private void showSystemLocks() {
    Vector vMonitorsWithLockedObjects = new Vector();
    JavaRuntime jRuntime = ctx.getRuntime();
    Iterator monitors = jRuntime.getMonitors();
    out.println("\nSystem locks...");
    while (monitors.hasNext()) {
        JavaMonitor jMonitor = (JavaMonitor) monitors.next();
        JavaObject jObject = jMonitor.getObject();
        try {
            String monitorName = jMonitor.getName().trim();
            if (monitorName.equalsIgnoreCase("")) {
                monitorName = "<un-named monitor>";
            }
            out.println("id: 0x" + jMonitor.getID() + " name: " + jMonitor.getName());
            JavaThread owner = jMonitor.getOwner();
            if (null != owner) {
                try {
                    out.println("\towner thread id: " + owner.getImageThread().getID() + " name: " + owner.getName());
                } catch (DataUnavailable e) {
                    out.println("\towner thread id: " + Exceptions.getDataUnavailableString());
                    logger.log(Level.FINE, Exceptions.getDataUnavailableString(), e);
                }
            }
            showWaiters(jMonitor);
        } catch (CorruptDataException cde) {
            out.println("\nwarning, corrupt data encountered during scan for system locks...");
        }
        if (null != jObject) {
            // Remember object monitors (flat or inflated) for later
            vMonitorsWithLockedObjects.add(jMonitor);
        }
    }
    showLockedObjects(vMonitorsWithLockedObjects);
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Vector(java.util.Vector) JavaMonitor(com.ibm.dtfj.java.JavaMonitor)

Example 22 with JavaThread

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

the class InfoLockCommand method showLockedObjects.

private void showLockedObjects(Vector vMonitorsWithLockedObjects) {
    out.println("\nObject Locks in use...");
    if (0 == vMonitorsWithLockedObjects.size()) {
        out.println("\t...None.");
        return;
    }
    Iterator lockedObjects = vMonitorsWithLockedObjects.iterator();
    while (lockedObjects.hasNext()) {
        JavaMonitor jMonitor = (JavaMonitor) lockedObjects.next();
        JavaObject jObject = jMonitor.getObject();
        try {
            JavaThread owner = jMonitor.getOwner();
            String className = "<unknown class>";
            JavaClass jClass = jObject.getJavaClass();
            if (null != jClass) {
                className = jClass.getName();
            }
            String jObjectID = Long.toHexString(jObject.getID().getAddress());
            if (null == owner) {
                out.println(className + "@0x" + jObjectID);
            } else {
                String owningThreadID = null;
                try {
                    owningThreadID = owner.getImageThread().getID();
                } catch (DataUnavailable e) {
                    owningThreadID = Exceptions.getDataUnavailableString();
                }
                out.println(className + "@0x" + jObjectID);
                out.println("\towner thread id: " + owningThreadID + " name: " + owner.getName());
            }
            showWaiters(jMonitor);
        } catch (CorruptDataException cde) {
            logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JavaMonitor(com.ibm.dtfj.java.JavaMonitor)

Aggregations

JavaThread (com.ibm.dtfj.java.JavaThread)22 Iterator (java.util.Iterator)14 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)13 JavaObject (com.ibm.dtfj.java.JavaObject)13 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)9 CorruptData (com.ibm.dtfj.image.CorruptData)5 ImageThread (com.ibm.dtfj.image.ImageThread)5 JavaMonitor (com.ibm.dtfj.java.JavaMonitor)5 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)4 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)4 LinkedList (java.util.LinkedList)4 StateToString (com.ibm.jvm.dtfjview.commands.helpers.StateToString)3 ImageSection (com.ibm.dtfj.image.ImageSection)2 JavaClass (com.ibm.dtfj.java.JavaClass)2 JavaStackFrame (com.ibm.dtfj.java.JavaStackFrame)2 IAttributeValueMap (com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)2 MonitorState (com.ibm.jvm.dtfjview.commands.helpers.MonitorState)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2