[10] RFR 8181647: jhsdb jstack could not output thread name
chihiro ito
chihiro.ito at oracle.com
Wed Jun 7 09:46:07 UTC 2017
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