mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8307517: Add VMErrorCallback infrastructure to extend hs_err dumping
Reviewed-by: eosterlund, aboldtch, dholmes, stuefe
This commit is contained in:
parent
7a1cb64bc1
commit
33245d6b38
4 changed files with 49 additions and 0 deletions
|
@ -98,6 +98,7 @@ Thread::Thread() {
|
||||||
_jvmti_env_iteration_count = 0;
|
_jvmti_env_iteration_count = 0;
|
||||||
set_allocated_bytes(0);
|
set_allocated_bytes(0);
|
||||||
_current_pending_raw_monitor = nullptr;
|
_current_pending_raw_monitor = nullptr;
|
||||||
|
_vm_error_callbacks = nullptr;
|
||||||
|
|
||||||
// thread-specific hashCode stream generator state - Marsaglia shift-xor form
|
// thread-specific hashCode stream generator state - Marsaglia shift-xor form
|
||||||
_hashStateX = os::random();
|
_hashStateX = os::random();
|
||||||
|
|
|
@ -55,6 +55,7 @@ class SafeThreadsListPtr;
|
||||||
class ThreadClosure;
|
class ThreadClosure;
|
||||||
class ThreadsList;
|
class ThreadsList;
|
||||||
class ThreadsSMRSupport;
|
class ThreadsSMRSupport;
|
||||||
|
class VMErrorCallback;
|
||||||
|
|
||||||
class OopClosure;
|
class OopClosure;
|
||||||
class CodeBlobClosure;
|
class CodeBlobClosure;
|
||||||
|
@ -104,6 +105,8 @@ class JavaThread;
|
||||||
// - this->entry_point() // set differently for each kind of JavaThread
|
// - this->entry_point() // set differently for each kind of JavaThread
|
||||||
|
|
||||||
class Thread: public ThreadShadow {
|
class Thread: public ThreadShadow {
|
||||||
|
friend class VMError;
|
||||||
|
friend class VMErrorCallbackMark;
|
||||||
friend class VMStructs;
|
friend class VMStructs;
|
||||||
friend class JVMCIVMStructs;
|
friend class JVMCIVMStructs;
|
||||||
private:
|
private:
|
||||||
|
@ -634,6 +637,9 @@ protected:
|
||||||
Thread *cur = Thread::current_or_null_safe();
|
Thread *cur = Thread::current_or_null_safe();
|
||||||
return cur != nullptr && cur->in_asgct();
|
return cur != nullptr && cur->in_asgct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VMErrorCallback* _vm_error_callbacks;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ThreadInAsgct {
|
class ThreadInAsgct {
|
||||||
|
|
|
@ -948,6 +948,14 @@ void VMError::report(outputStream* st, bool _verbose) {
|
||||||
st->cr();
|
st->cr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STEP_IF("printing registered callbacks", _verbose && _thread != nullptr);
|
||||||
|
for (VMErrorCallback* callback = _thread->_vm_error_callbacks;
|
||||||
|
callback != nullptr;
|
||||||
|
callback = callback->_next) {
|
||||||
|
callback->call(st);
|
||||||
|
st->cr();
|
||||||
|
}
|
||||||
|
|
||||||
STEP("printing process")
|
STEP("printing process")
|
||||||
|
|
||||||
STEP_IF("printing process", _verbose)
|
STEP_IF("printing process", _verbose)
|
||||||
|
@ -1896,3 +1904,14 @@ void VMError::controlled_crash(int how) {
|
||||||
ShouldNotReachHere();
|
ShouldNotReachHere();
|
||||||
}
|
}
|
||||||
#endif // !ASSERT
|
#endif // !ASSERT
|
||||||
|
|
||||||
|
VMErrorCallbackMark::VMErrorCallbackMark(VMErrorCallback* callback)
|
||||||
|
: _thread(Thread::current()) {
|
||||||
|
callback->_next = _thread->_vm_error_callbacks;
|
||||||
|
_thread->_vm_error_callbacks = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
VMErrorCallbackMark::~VMErrorCallbackMark() {
|
||||||
|
assert(_thread->_vm_error_callbacks != nullptr, "Popped too far");
|
||||||
|
_thread->_vm_error_callbacks = _thread->_vm_error_callbacks->_next;
|
||||||
|
}
|
||||||
|
|
|
@ -213,4 +213,27 @@ public:
|
||||||
static int prepare_log_file(const char* pattern, const char* default_pattern, bool overwrite_existing, char* buf, size_t buflen);
|
static int prepare_log_file(const char* pattern, const char* default_pattern, bool overwrite_existing, char* buf, size_t buflen);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VMErrorCallback {
|
||||||
|
friend class VMError;
|
||||||
|
friend class VMErrorCallbackMark;
|
||||||
|
|
||||||
|
// Link through all callbacks active on a thread
|
||||||
|
VMErrorCallback* _next;
|
||||||
|
|
||||||
|
// Called by VMError reporting
|
||||||
|
virtual void call(outputStream* st) = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VMErrorCallback() : _next(nullptr) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class VMErrorCallbackMark : public StackObj {
|
||||||
|
Thread* _thread;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VMErrorCallbackMark(VMErrorCallback* callback);
|
||||||
|
~VMErrorCallbackMark();
|
||||||
|
};
|
||||||
|
|
||||||
#endif // SHARE_UTILITIES_VMERROR_HPP
|
#endif // SHARE_UTILITIES_VMERROR_HPP
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue