[10] RFR 8181647: jhsdb jstack could not output thread name
chihiro ito
chihiro.ito at oracle.com
Thu Jun 8 09:04:58 UTC 2017
Hi Jini,
Thank you for your advices. I try to add the test case and modify the
copyright year to 2017.
Basically, I agree with your idea, but I think that the separator line
should finally be the same as the output of the jstack command. I worry
which is better way.
Thanks,
Chihiro
On 2017/06/08 16:42, Jini George wrote:
> Hi Chihiro,
>
> Thank you for making this useful change. Your changes look good.
>
> It would be great though if you could add a test case for this. Could
> you also modify the copyright year to 2017 ? One additional
> suggestion: The addition of the thread name makes the separator lines
> unaligned in the pstack/jstack --mixed cases. Like:
>
> ----------------- "Service Thread" nid=16051 -----------------
> and
> ----------------- nid=16052 -----------------
>
> So I am wondering if it would make sense to have the name printed out
> on a separate line to keep the separator lines aligned. But this is a
> nit, and I would leave it to you to decide on this.
>
> Thanks,
> Jini (Not a (R)eviewer)
>
> On 6/7/2017 3:16 PM, chihiro ito wrote:
>> Hi all,
>>
>> I changed to output Java thread name in jhsdb jstack as following.
>>
>> jhsdb jstack --pid 25879
>> "main" nid=25884: (state = BLOCKED)
>>
>> jhsdb jstack --mixed --pid 25879
>> ----------------- "main" nid=25884 -----------------
>>
>> Could you possibly review for this following small change? If review
>> is ok, please commit this as cito.
>>
>> Source:
>> diff --git
>> a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java
>> b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java
>> ---
>> a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java
>> +++
>> b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java
>> @@ -86,6 +86,13 @@
>> try {
>> CFrame f = cdbg.topFrameForThread(th);
>> out.print("----------------- ");
>> + JavaThread jthread = (JavaThread) proxyToThread.get(th);
>> + if (jthread != null) {
>> + out.print("\"");
>> + out.print(jthread.getThreadName());
>> + out.print("\" ");
>> + }
>> + out.print("nid=");
>> out.print(th);
>> out.println(" -----------------");
>> while (f != null) {
>> diff --git
>> a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java
>> b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java
>>
>> ---
>> a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java
>> +++
>> b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/StackTrace.java
>> @@ -75,7 +75,9 @@
>> for (JavaThread cur = threads.first(); cur != null; cur
>> = cur.next(), i++) {
>> if (cur.isJavaThread()) {
>> Address sp = cur.getLastJavaSP();
>> - tty.print("Thread ");
>> + tty.print("\"");
>> + tty.print(cur.getThreadName());
>> + tty.print("\" nid=");
>> cur.printThreadIDOn(tty);
>> tty.print(": (state = " + cur.getThreadState());
>> if (verbose) {
>>
>> Regards,
>> Chihiro
>>
>
--
Chihiro Ito | Principal Consultant | +81.90.6148.8815
Oracle <http://www.oracle.com> Consultant
ORACLE Japan | Akasaka Center Bldg. | Motoakasaka 1-3-13 | 1070051
Minato-ku, Tokyo, JAPAN
Oracle is committed to developing practices and products that help
protect the environment <http://www.oracle.com/commitment>
More information about the serviceability-dev
mailing list