diff options
Diffstat (limited to 'openjdkjvmti/ti_stack.h')
-rw-r--r-- | openjdkjvmti/ti_stack.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/openjdkjvmti/ti_stack.h b/openjdkjvmti/ti_stack.h index 2f506d0064..b41fa4bf5a 100644 --- a/openjdkjvmti/ti_stack.h +++ b/openjdkjvmti/ti_stack.h @@ -35,7 +35,9 @@ #include "jni.h" #include "jvmti.h" +#include "art_method.h" #include "base/mutex.h" +#include "stack.h" namespace openjdkjvmti { @@ -77,6 +79,41 @@ class StackUtil { jthread thread, jint* owned_monitor_count_ptr, jobject** owned_monitors_ptr); + + static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth); +}; + +struct FindFrameAtDepthVisitor : art::StackVisitor { + public: + FindFrameAtDepthVisitor(art::Thread* target, art::Context* ctx, jint depth) + REQUIRES_SHARED(art::Locks::mutator_lock_) + : art::StackVisitor(target, ctx, art::StackVisitor::StackWalkKind::kIncludeInlinedFrames), + found_frame_(false), + cnt_(0), + depth_(static_cast<size_t>(depth)) { } + + bool FoundFrame() { + return found_frame_; + } + + bool VisitFrame() NO_THREAD_SAFETY_ANALYSIS { + if (GetMethod()->IsRuntimeMethod()) { + return true; + } + if (cnt_ == depth_) { + // We found our frame, exit. + found_frame_ = true; + return false; + } else { + cnt_++; + return true; + } + } + + private: + bool found_frame_; + size_t cnt_; + size_t depth_; }; } // namespace openjdkjvmti |