hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
// Create a jvmtiStackInfo inside a linked list node and create a
// buffer for the frame information, both allocated as resource objects.
// Fill in both the jvmtiStackInfo and the jvmtiFrameInfo.
// Note that either or both of thr and thread_oop
// may be null if the thread is new or has exited.
void
VM_GetMultipleStackTraces::fill_frames(jthread jt, JavaThread *thr, oop thread_oop) {
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
jint state = 0;
struct StackInfoNode *node = NEW_RESOURCE_OBJ(struct StackInfoNode);
jvmtiStackInfo *infop = &(node->info);
node->next = head();
set_head(node);
infop->frame_count = 0;
infop->thread = jt;
if (thread_oop != NULL) {
// get most state bits
state = (jint)java_lang_Thread::get_thread_status(thread_oop);
}
if (thr != NULL) { // add more state bits if there is a JavaThead to query
// same as is_being_ext_suspended() but without locking
if (thr->is_ext_suspended() || thr->is_external_suspend()) {
state |= JVMTI_THREAD_STATE_SUSPENDED;
}
JavaThreadState jts = thr->thread_state();
if (jts == _thread_in_native) {
state |= JVMTI_THREAD_STATE_IN_NATIVE;
}
OSThread* osThread = thr->osthread();
if (osThread != NULL && osThread->interrupted()) {
state |= JVMTI_THREAD_STATE_INTERRUPTED;
}
}
infop->state = state;
if (thr != NULL || (state & JVMTI_THREAD_STATE_ALIVE) != 0) {
infop->frame_buffer = NEW_RESOURCE_ARRAY(jvmtiFrameInfo, max_frame_count());
env()->get_stack_trace(thr, 0, max_frame_count(),
infop->frame_buffer, &(infop->frame_count));
} else {
infop->frame_buffer = NULL;
infop->frame_count = 0;
}
_frame_count_total += infop->frame_count;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.