debug ps(x) and psf(x)
Christian Thalinger
Christian.Thalinger at Sun.COM
Fri Oct 16 03:06:23 PDT 2009
During debugging of MethodHandle invokes, where some stacks were
corrupted because of bugs, I found it very useful to print stacktraces
of particular threads. As I couldn't find similar methods I added these
(psx and psfx) myself:
diff --git a/src/share/vm/utilities/debug.cpp b/src/share/vm/utilities/debug.cpp
--- a/src/share/vm/utilities/debug.cpp
+++ b/src/share/vm/utilities/debug.cpp
@@ -396,12 +396,9 @@
extern "C" void pa(intptr_t p) { ((AllocatedObj*) p)->print(); }
extern "C" void findpc(intptr_t x);
-extern "C" void ps() { // print stack
- Command c("ps");
-
-
- // Prints the stack of the current Java thread
- JavaThread* p = JavaThread::active();
+extern "C" void psx(intptr_t x) { // print stack
+ Command c("psx");
+ JavaThread* p = (JavaThread*) x;
tty->print(" for thread: ");
p->print();
tty->cr();
@@ -416,25 +413,34 @@
f = f.sender(®_map);
tty->print("(guessing starting frame id=%#p based on current fp)\n", f.id());
p->trace_stack_from(vframe::new_vframe(&f, ®_map, p));
- pd_ps(f);
+ pd_ps(f);
}
-
}
+extern "C" void ps() { // print stack of current Java thread
+ Command c("ps");
+ JavaThread* p = JavaThread::active();
+ psx((intptr_t) p);
+}
-extern "C" void psf() { // print stack frames
- {
- Command c("psf");
- JavaThread* p = JavaThread::active();
- tty->print(" for thread: ");
- p->print();
- tty->cr();
- if (p->has_last_Java_frame()) {
- p->trace_frames();
- }
+
+extern "C" void psfx(intptr_t x) { // print stack frames
+ Command c("psfx");
+ JavaThread* p = (JavaThread*) x;
+ tty->print(" for thread: ");
+ p->print();
+ tty->cr();
+ if (p->has_last_Java_frame()) {
+ p->trace_frames();
}
}
+extern "C" void psf() { // print stack frames of current Java thread
+ Command c("psf");
+ JavaThread* p = JavaThread::active();
+ psfx((intptr_t) p);
+}
+
extern "C" void threads() {
Command c("threads");
Could we add these or did I miss any methods which are exactly doing
that?
-- Christian
More information about the hotspot-dev
mailing list