Hi Yasumasa,

This is helpful, but looks like 'locked' is printed even when a thread is waiting for the monitor entry, or has unlocked a lock. For a simple test program, we would have:


"Thread-1" #11 prio=5 tid=0x00007f3938450000 nid=0x6be4 waiting for monitor entry [0x00007f3915010000]
   java.lang.Thread.State: BLOCKED (on object monitor)
   JavaThread state: _thread_blocked
 - ThreadLockTest.run() @bci=5, line=6 (Interpreted frame)
    - locked <0x000000072e96c490> (a java.lang.Class)
 - java.lang.Thread.run() @bci=11, line=844 (Interpreted frame)


"Thread-0" #10 prio=5 tid=0x00007f39383b7800 nid=0x6be3 waiting on condition [0x00007f3915111000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
   JavaThread state: _thread_blocked
 - java.lang.Thread.sleep(long) @bci=0 (Interpreted frame)
 - ThreadLockTest.run() @bci=8, line=6 (Interpreted frame)
    - locked <0x000000072e96c490> (a java.lang.Class)
 - java.lang.Thread.run() @bci=11, line=844 (Interpreted frame)

The corresponding output from the non SA jstack is as follows:

"Thread-1" #11 prio=5 os_prio=0 tid=0x00007f3938450000 nid=0x6be4 waiting for monitor entry [0x00007f3915010000]
   java.lang.Thread.State: BLOCKED (on object monitor)
   JavaThread state: _thread_blocked
Thread: 0x00007f3938450000 [0x6be4] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
        at ThreadLockTest.run(ThreadLockTest.java:6)
-waiting to lock <0x000000072e96c490> (a java.lang.Class for ThreadLockTest)
        at java.lang.Thread.run(java.base/Thread.java:844)

   Locked ownable synchronizers:
        - None

"Thread-0" #10 prio=5 os_prio=0 tid=0x00007f39383b7800 nid=0x6be3 waiting on condition [0x00007f3915111000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
   JavaThread state: _thread_blocked
Thread: 0x00007f39383b7800 [0x6be3] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
        at java.lang.Thread.sleep(java.base/Native Method)
        at ThreadLockTest.run(ThreadLockTest.java:6)
- locked <0x000000072e96c490> (a java.lang.Class for ThreadLockTest)
        at java.lang.Thread.run(java.base/Thread.java:844)

   Locked ownable synchronizers:
        - None

I think the various cases as seen in javaVFrame::print_lock_info_on() would have to be dealt with in SA. It would also be great if you could add a test case or modify an existing test case to test this along with the rest of your changes.

Thanks,
Jini (Not a (R)eviewer).


On 8/3/2017 8:13 PM, Yasumasa Suenaga wrote:
Hi all,

Thread dump shows lock objects, however jstack jhsdb and jstack in CLHSDB are not show them. They are very useful for checking monitors. So jstack mode should show them.

I uploaded webrev. Could you review it?

  http://cr.openjdk.java.net/~ysuenaga/JDK-8185796/webrev.00/

This change prints locked stack looks like:

* jhsdb jstack
----------------
"main" #1 prio=5 tid=0x00007f1844018800 nid=0xe7f0 waiting on condition [0x00007f184df31000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
   JavaThread state: _thread_blocked
 - java.lang.Thread.sleep(long) @bci=0 (Interpreted frame)
 - LongLock.main(java.lang.String[]) @bci=8, line=4 (Interpreted frame)
    - locked <0x00000000dfc13b28> (a java.lang.Class)
----------------

* jstack in CLHSDB
----------------
"main" #1 prio=5 tid=0x00007f1844018800 nid=0xe7f0 waiting on condition [0x00007f184df31000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
   JavaThread state: _thread_blocked
 - java.lang.Thread.sleep(long) @bci=0 (Interpreted frame)
 - LongLock.main(java.lang.String[]) @bci=8, line=4 (Interpreted frame)
    - locked <0x00000000dfc13b28> (a java.lang.Class)
----------------


I cannot access JPRT.
So I need a sponsor.


Thanks,

Yasumasa



Reply via email to