| 309 | } |
| 310 | |
| 311 | int Profiler::convertNativeTrace(int native_frames, const void** callchain, ASGCT_CallFrame* frames, EventType event_type) { |
| 312 | int depth = 0; |
| 313 | |
| 314 | for (int i = 0; i < native_frames; i++) { |
| 315 | const char* current_method_name = findNativeMethod(callchain[i]); |
| 316 | char mark; |
| 317 | if (current_method_name != NULL && (mark = NativeFunc::mark(current_method_name)) != 0) { |
| 318 | if (mark == MARK_VM_RUNTIME && event_type >= ALLOC_SAMPLE) { |
| 319 | // Skip all internal frames above VM runtime entry for allocation samples |
| 320 | depth = 0; |
| 321 | continue; |
| 322 | } else if (mark == MARK_ASYNC_PROFILER && (event_type == MALLOC_SAMPLE || event_type == NATIVE_LOCK_SAMPLE)) { |
| 323 | // Skip all internal frames above the *_hook functions. Include the hook function itself. |
| 324 | depth = 0; |
| 325 | } else if (mark == MARK_INTERPRETER) { |
| 326 | // This is C++ interpreter frame, this and later frames should be reported |
| 327 | // as Java frames returned by AGCT. Terminate the scan here. |
| 328 | return depth; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | frames[depth].bci = BCI_NATIVE_FRAME; |
| 333 | frames[depth].method_id = (jmethodID)current_method_name; |
| 334 | depth++; |
| 335 | } |
| 336 | |
| 337 | return depth; |
| 338 | } |
| 339 | |
| 340 | int Profiler::getJavaTraceAsync(void* ucontext, ASGCT_CallFrame* frames, int max_depth) { |
| 341 | // Workaround for JDK-8132510: it's not safe to call GetEnv() inside a signal handler |