[Swift-commit] r7095 - trunk/src/org/griphyn/vdl/karajan

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Sat Sep 21 19:43:40 CDT 2013


Author: hategan
Date: 2013-09-21 19:43:40 -0500 (Sat, 21 Sep 2013)
New Revision: 7095

Modified:
   trunk/src/org/griphyn/vdl/karajan/HangChecker.java
Log:
a few fixes to the JVM stuff in the hang checker

Modified: trunk/src/org/griphyn/vdl/karajan/HangChecker.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/HangChecker.java	2013-09-22 00:16:43 UTC (rev 7094)
+++ trunk/src/org/griphyn/vdl/karajan/HangChecker.java	2013-09-22 00:43:40 UTC (rev 7095)
@@ -159,9 +159,12 @@
     }
 
     private void printThreadInfo(PrintStream pw, ThreadInfo ti) {
-        pw.println("\tThread \"" + ti.getThreadName() + "\" (" + hex(ti.getThreadId()) + ")");
+        pw.println("\tThread \"" + ti.getThreadName() + "\" (" + hex(ti.getThreadId()) + ") " + ti.getThreadState());
         LockInfo l = ti.getLockInfo();
-        pw.println("\t\twaiting for " + format(l) + " held by " + ti.getLockOwnerName() + " (" + hex(ti.getLockOwnerId()) + ")");
+        if (l != null) {
+            pw.println("\t\twaiting for " + format(l) + 
+                    (ti.getLockOwnerName() == null ? "" : " held by " + ti.getLockOwnerName() + " (" + hex(ti.getLockOwnerId()) + ")"));
+        }
         Map<StackTraceElement, MonitorInfo> mlocs = new HashMap<StackTraceElement, MonitorInfo>();
         MonitorInfo[] mis = ti.getLockedMonitors();
         if (mis.length > 0) {
@@ -181,7 +184,7 @@
         pw.println("\tStack trace:");
         StackTraceElement[] stes = ti.getStackTrace();
         for (StackTraceElement ste : stes) {
-            pw.print("\t\t" + ste.getClassName() + "." + ste.getMethodName() + ":" + ste.getLineNumber());
+            pw.print("\t\t" + ste.getClassName() + "." + ste.getMethodName() + formatLineNumber(":", ste.getLineNumber()));
             if (mlocs.containsKey(ste)) {
                 pw.print(" -> locked " + format(mlocs.get(ste)));
             }
@@ -190,8 +193,22 @@
         pw.println();
     }
 
+    private String formatLineNumber(String prefix, int n) {
+        if (n < 0) {
+            return "";
+        }
+        else {
+            return prefix + String.valueOf(n);
+        }
+    }
+
     private String format(LockInfo l) {
-        return l.getClassName() + " (" + hex(l.getIdentityHashCode()) + ")";
+        if (l != null) {
+            return l.getClassName() + " (" + hex(l.getIdentityHashCode()) + ")";
+        }
+        else {
+            return "<unknown>";
+        }
     }
 
     private String hex(long x) {




More information about the Swift-commit mailing list