< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java

Print this page

        

@@ -29,10 +29,15 @@
 import sun.jvm.hotspot.oops.*;
 
 /** Traverses and prints the stack traces for all Java threads in the
  * remote VM */
 public class StackTrace extends Tool {
+
+    private static final String ADDRESS_FORMAT = VM.getVM().isLP64() ? "0x%016x" : "0x%08x";
+
+    private static final String LOCK_OUTPUT = "    - locked <" + ADDRESS_FORMAT + "> (a %s)";
+
     // in non-verbose mode pc, sp and Method* are not printed
     public StackTrace(boolean v, boolean concurrentLocks) {
         this.verbose = v;
         this.concurrentLocks = concurrentLocks;
     }

@@ -107,10 +112,16 @@
                             if (vf.mayBeImpreciseDbg()) {
                                 tty.print("; information may be imprecise");
                             }
 
                             tty.println(")");
+
+                            vf.getMonitors()
+                              .stream()
+                              .map(m -> m.ownerIsScalarReplaced() ? m.ownerKlass() : m.owner())
+                              .map(m -> String.format(LOCK_OUTPUT, m.asLongValue(), Oop.getKlassForOopHandle(m).getName().asString().replace('/', '.')))
+                              .forEach(tty::println);
                         }
                     } catch (Exception e) {
                         tty.println("Error occurred during stack walking:");
                         e.printStackTrace();
                     }
< prev index next >