8292674: ReportJNIFatalError should print all java frames

Reviewed-by: pchilanomate
This commit is contained in:
David Holmes 2022-12-13 00:04:38 +00:00
parent be69930d9d
commit 829cbc2cb1
6 changed files with 93 additions and 17 deletions

View file

@ -1673,6 +1673,16 @@ oop JavaThread::current_park_blocker() {
return NULL;
}
// Print stack trace for checked JNI warnings and JNI fatal errors.
// This is the external format from above, but selecting the platform
// or vthread as applicable.
void JavaThread::print_jni_stack() {
if (is_vthread_mounted()) {
print_vthread_stack_on(tty);
} else {
print_stack_on(tty);
}
}
void JavaThread::print_stack_on(outputStream* st) {
if (!has_last_Java_frame()) return;
@ -1706,6 +1716,48 @@ void JavaThread::print_stack_on(outputStream* st) {
}
}
void JavaThread::print_vthread_stack_on(outputStream* st) {
assert(is_vthread_mounted(), "Caller should have checked this");
assert(has_last_Java_frame(), "must be");
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
RegisterMap reg_map(this,
RegisterMap::UpdateMap::include,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::include);
ContinuationEntry* cont_entry = last_continuation();
vframe* start_vf = last_java_vframe(&reg_map);
int count = 0;
for (vframe* f = start_vf; f != NULL; f = f->sender()) {
// Watch for end of vthread stack
if (Continuation::is_continuation_enterSpecial(f->fr())) {
assert(cont_entry == Continuation::get_continuation_entry_for_entry_frame(this, f->fr()), "");
if (cont_entry->is_virtual_thread()) {
break;
}
cont_entry = cont_entry->parent();
}
if (f->is_java_frame()) {
javaVFrame* jvf = javaVFrame::cast(f);
java_lang_Throwable::print_stack_element(st, jvf->method(), jvf->bci());
// Print out lock information
if (JavaMonitorsInStackTrace) {
jvf->print_lock_info_on(st, count);
}
} else {
// Ignore non-Java frames
}
// Bail-out case for too deep stacks if MaxJavaStackTraceDepth > 0
count++;
if (MaxJavaStackTraceDepth > 0 && MaxJavaStackTraceDepth == count) return;
}
}
#if INCLUDE_JVMTI
// Rebind JVMTI thread state from carrier to virtual or from virtual to carrier.
JvmtiThreadState* JavaThread::rebind_to_jvmti_thread_state_of(oop thread_oop) {