8316735: Print LockStack in hs_err files

Reviewed-by: dholmes, mbaesken
This commit is contained in:
Martin Doerr 2023-09-26 13:33:33 +00:00
parent e510dee162
commit 20ff603108
3 changed files with 21 additions and 1 deletions

View File

@ -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));
}
}
}

View File

@ -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;
@ -91,6 +92,8 @@ public:
// GC support
inline void oops_do(OopClosure* cl);
// Printing
void print_on(outputStream* st);
};
#endif // SHARE_RUNTIME_LOCKSTACK_HPP

View File

@ -1100,6 +1100,11 @@ void VMError::report(outputStream* st, bool _verbose) {
print_stack_location(st, _context, continuation);
st->cr();
STEP_IF("printing lock stack", _verbose && _thread != nullptr && _thread->is_Java_thread() && LockingMode == LM_LIGHTWEIGHT);
st->print_cr("Lock stack of current Java thread (top to bottom):");
JavaThread::cast(_thread)->lock_stack().print_on(st);
st->cr();
STEP_IF("printing code blobs if possible", _verbose)
const int printed_capacity = max_error_log_print_code;
address printed[printed_capacity];