505 // (< 0 indicates the frame is not walkable). 506 // frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers. 507 // 508 // ASGCT_CallFrame: 509 // typedef struct { 510 // jint lineno; 511 // jmethodID method_id; 512 // } ASGCT_CallFrame; 513 // 514 // Fields: 515 // 1) For Java frame (interpreted and compiled), 516 // lineno - bci of the method being executed or -1 if bci is not available 517 // method_id - jmethodID of the method being executed 518 // 2) For native method 519 // lineno - (-3) 520 // method_id - jmethodID of the method being executed 521 522 extern "C" { 523 JNIEXPORT 524 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { 525 526 // This is if'd out because we no longer use thread suspension. 527 // However if someone wanted to backport this to a 5.0 jvm then this 528 // code would be important. 529 #if 0 530 if (SafepointSynchronize::is_synchronizing()) { 531 // The safepoint mechanism is trying to synchronize all the threads. 532 // Since this can involve thread suspension, it is not safe for us 533 // to be here. We can reduce the deadlock risk window by quickly 534 // returning to the SIGPROF handler. However, it is still possible 535 // for VMThread to catch us here or in the SIGPROF handler. If we 536 // are suspended while holding a resource and another thread blocks 537 // on that resource in the SIGPROF handler, then we will have a 538 // three-thread deadlock (VMThread, this thread, the other thread). 539 trace->num_frames = ticks_safepoint; // -10 540 return; 541 } 542 #endif 543 544 JavaThread* thread; 545 546 if (trace->env_id == NULL || 547 (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL || 548 thread->is_exiting()) { 549 550 // bad env_id, thread has exited or thread is exiting 551 trace->num_frames = ticks_thread_exit; // -8 552 return; 553 } 554 555 if (thread->in_deopt_handler()) { 556 // thread is in the deoptimization handler so return no frames 557 trace->num_frames = ticks_deopt; // -9 558 return; 559 } 560 561 assert(JavaThread::current() == thread, 562 "AsyncGetCallTrace must be called by the current interrupted thread"); 563 | 505 // (< 0 indicates the frame is not walkable). 506 // frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers. 507 // 508 // ASGCT_CallFrame: 509 // typedef struct { 510 // jint lineno; 511 // jmethodID method_id; 512 // } ASGCT_CallFrame; 513 // 514 // Fields: 515 // 1) For Java frame (interpreted and compiled), 516 // lineno - bci of the method being executed or -1 if bci is not available 517 // method_id - jmethodID of the method being executed 518 // 2) For native method 519 // lineno - (-3) 520 // method_id - jmethodID of the method being executed 521 522 extern "C" { 523 JNIEXPORT 524 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { 525 JavaThread* thread; 526 527 if (trace->env_id == NULL || 528 (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL || 529 thread->is_exiting()) { 530 531 // bad env_id, thread has exited or thread is exiting 532 trace->num_frames = ticks_thread_exit; // -8 533 return; 534 } 535 536 if (thread->in_deopt_handler()) { 537 // thread is in the deoptimization handler so return no frames 538 trace->num_frames = ticks_deopt; // -9 539 return; 540 } 541 542 assert(JavaThread::current() == thread, 543 "AsyncGetCallTrace must be called by the current interrupted thread"); 544 |