@@ -235,6 +235,7 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
235235
236236 // Show extended frame types and stub frames for execution-type events
237237 bool details = event_type <= MALLOC_SAMPLE || features.mixed ;
238+ bool no_native = features.no_native ;
238239
239240 JavaFrameAnchor* anchor = NULL ;
240241 VMThread* vm_thread = VMThread::current ();
@@ -248,6 +249,12 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
248249 }
249250 }
250251
252+ // Jump directly to java frame if possible in case native frames are not desired
253+ if (no_native && anchor != NULL ) {
254+ anchor->restoreFrame (pc, sp, fp);
255+ anchor = NULL ;
256+ }
257+
251258 unwind_loop:
252259 uintptr_t prev_sp = sp;
253260 while (depth < max_depth) {
@@ -388,7 +395,7 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
388395 const void * start = stub != NULL ? stub->_start : nm->code ();
389396 const char * name = stub != NULL ? stub->_name : nm->name ();
390397
391- if (details) {
398+ if (!no_native && details) {
392399 fillFrame (frames[depth++], BCI_NATIVE_FRAME, name);
393400 }
394401
@@ -405,22 +412,24 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth,
405412 }
406413 } else {
407414 native_lib = profiler->findLibraryByAddress (pc);
408- const char * method_name = native_lib != NULL ? native_lib->binarySearch (pc) : NULL ;
409- char mark;
410- if (method_name != NULL && (mark = NativeFunc::mark (method_name)) != 0 ) {
411- if (mark == MARK_ASYNC_PROFILER && (event_type == MALLOC_SAMPLE || event_type == NATIVE_LOCK_SAMPLE)) {
412- // Skip all internal frames above hook functions, leave the hook itself
413- depth = 0 ;
414- } else if (mark == MARK_COMPILER_ENTRY && features.comp_task && vm_thread != NULL ) {
415- // Insert current compile task as a pseudo Java frame
416- VMMethod* method = vm_thread->compiledMethod ();
417- jmethodID method_id = method != NULL ? method->id () : NULL ;
418- if (method_id != NULL ) {
419- fillFrame (frames[depth++], FRAME_JIT_COMPILED, 0 , method_id);
415+ if (!no_native) {
416+ const char * method_name = native_lib != NULL ? native_lib->binarySearch (pc) : NULL ;
417+ char mark;
418+ if (method_name != NULL && (mark = NativeFunc::mark (method_name)) != 0 ) {
419+ if (mark == MARK_ASYNC_PROFILER && (event_type == MALLOC_SAMPLE || event_type == NATIVE_LOCK_SAMPLE)) {
420+ // Skip all internal frames above hook functions, leave the hook itself
421+ depth = 0 ;
422+ } else if (mark == MARK_COMPILER_ENTRY && features.comp_task && vm_thread != NULL ) {
423+ // Insert current compile task as a pseudo Java frame
424+ VMMethod* method = vm_thread->compiledMethod ();
425+ jmethodID method_id = method != NULL ? method->id () : NULL ;
426+ if (method_id != NULL ) {
427+ fillFrame (frames[depth++], FRAME_JIT_COMPILED, 0 , method_id);
428+ }
420429 }
421430 }
431+ fillFrame (frames[depth++], BCI_NATIVE_FRAME, method_name);
422432 }
423- fillFrame (frames[depth++], BCI_NATIVE_FRAME, method_name);
424433 }
425434
426435 FrameDesc* f = native_lib != NULL ? native_lib->findFrameDesc (pc) : &FrameDesc::default_frame;
0 commit comments