Skip to content

Commit

Permalink
8316735: Print LockStack in hs_err files
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealMDoerr committed Sep 22, 2023
1 parent d3e8218 commit 14e4d67
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/hotspot/share/runtime/lockStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@ void LockStack::verify(const char* msg) const {
}
}
#endif

void LockStack::print_on(outputStream* st) {
for (int i = to_index(_top); (--i) >= 0;) {
st->print("LockStack[%d]: ", i);
oop o = _base[i];
if (oopDesc::is_oop(o)) {
o->print_on(st);
} else {
st->print_cr("not an oop: " PTR_FORMAT, p2i(o));
}
}
}
5 changes: 4 additions & 1 deletion src/hotspot/share/runtime/lockStack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/sizes.hpp"

class Thread;
class JavaThread;
class OopClosure;
class outputStream;

class LockStack {
friend class VMStructs;
Expand Down Expand Up @@ -91,6 +92,8 @@ class LockStack {
// GC support
inline void oops_do(OopClosure* cl);

// Printing
void print_on(outputStream* st);
};

#endif // SHARE_RUNTIME_LOCKSTACK_HPP
4 changes: 4 additions & 0 deletions src/hotspot/share/utilities/vmError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,10 @@ void VMError::report(outputStream* st, bool _verbose) {
st->cr();
}

STEP_IF("printing fast locked objects", _verbose && _thread != nullptr && _thread->is_Java_thread() && LockingMode == LM_LIGHTWEIGHT);
st->print_cr("Objects fast locked by this thread (top to bottom):");
JavaThread::cast(_thread)->lock_stack().print_on(st);

STEP_IF("printing process", _verbose)
st->cr();
st->print_cr("--------------- P R O C E S S ---------------");
Expand Down

0 comments on commit 14e4d67

Please sign in to comment.