33 #include "runtime/registerMap.hpp"
34 #include "runtime/thread.inline.hpp"
35
36 bool JfrGetCallTrace::find_top_frame(frame& top_frame, Method** method, frame& first_frame) {
37 assert(top_frame.cb() != NULL, "invariant");
38 RegisterMap map(_thread, false);
39 frame candidate = top_frame;
40 for (int i = 0; i < MaxJavaStackTraceDepth * 2; ++i) {
41 if (candidate.is_entry_frame()) {
42 JavaCallWrapper *jcw = candidate.entry_frame_call_wrapper_if_safe(_thread);
43 if (jcw == NULL || jcw->is_first_frame()) {
44 return false;
45 }
46 }
47
48 if (candidate.is_interpreted_frame()) {
49 JavaThreadState state = _thread->thread_state();
50 const bool known_valid = (state == _thread_in_native || state == _thread_in_vm || state == _thread_blocked);
51 if (known_valid || candidate.is_interpreted_frame_valid(_thread)) {
52 Method* im = candidate.interpreter_frame_method();
53 if (known_valid && !im->is_valid_method()) {
54 return false;
55 }
56 *method = im;
57 first_frame = candidate;
58 return true;
59 }
60 }
61
62 if (candidate.cb()->is_nmethod()) {
63 // first check to make sure that we have a sane stack,
64 // the PC is actually inside the code part of the codeBlob,
65 // and we are past is_frame_complete_at (stack has been setup)
66 if (!candidate.safe_for_sender(_thread)) {
67 return false;
68 }
69 nmethod* nm = (nmethod*)candidate.cb();
70 *method = nm->method();
71
72 if (_in_java) {
73 PcDesc* pc_desc = nm->pc_desc_near(candidate.pc() + 1);
|
33 #include "runtime/registerMap.hpp"
34 #include "runtime/thread.inline.hpp"
35
36 bool JfrGetCallTrace::find_top_frame(frame& top_frame, Method** method, frame& first_frame) {
37 assert(top_frame.cb() != NULL, "invariant");
38 RegisterMap map(_thread, false);
39 frame candidate = top_frame;
40 for (int i = 0; i < MaxJavaStackTraceDepth * 2; ++i) {
41 if (candidate.is_entry_frame()) {
42 JavaCallWrapper *jcw = candidate.entry_frame_call_wrapper_if_safe(_thread);
43 if (jcw == NULL || jcw->is_first_frame()) {
44 return false;
45 }
46 }
47
48 if (candidate.is_interpreted_frame()) {
49 JavaThreadState state = _thread->thread_state();
50 const bool known_valid = (state == _thread_in_native || state == _thread_in_vm || state == _thread_blocked);
51 if (known_valid || candidate.is_interpreted_frame_valid(_thread)) {
52 Method* im = candidate.interpreter_frame_method();
53 if (known_valid && !Method::is_valid_method(im)) {
54 return false;
55 }
56 *method = im;
57 first_frame = candidate;
58 return true;
59 }
60 }
61
62 if (candidate.cb()->is_nmethod()) {
63 // first check to make sure that we have a sane stack,
64 // the PC is actually inside the code part of the codeBlob,
65 // and we are past is_frame_complete_at (stack has been setup)
66 if (!candidate.safe_for_sender(_thread)) {
67 return false;
68 }
69 nmethod* nm = (nmethod*)candidate.cb();
70 *method = nm->method();
71
72 if (_in_java) {
73 PcDesc* pc_desc = nm->pc_desc_near(candidate.pc() + 1);
|