summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sebastien Hertz <shertz@google.com> 2015-10-13 09:58:38 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-10-13 09:58:38 +0000
commit7edef7441d28db1403fbc5641b56a26ecf355879 (patch)
tree8dd65db0eb70e7a0524a3ea0a326db3c7e52f586
parentc1b4a1efcfb249651bc9ae34c9285a693ede2550 (diff)
parentb2feaafd89813af69c65da95e0b51b1a4cecaf0b (diff)
Merge "Revert "Revert "Fix instrumentation frame check with inlining"""
-rw-r--r--runtime/instrumentation.cc9
-rw-r--r--runtime/instrumentation.h5
-rw-r--r--runtime/stack.cc17
3 files changed, 25 insertions, 6 deletions
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index deada4c5dc..955a8c3fa5 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -960,6 +960,15 @@ void Instrumentation::ExceptionCaughtEvent(Thread* thread,
}
}
+// Computes a frame ID by ignoring inlined frames.
+size_t Instrumentation::ComputeFrameId(Thread* self,
+ size_t frame_depth,
+ size_t inlined_frames_before_frame) {
+ CHECK_GE(frame_depth, inlined_frames_before_frame);
+ size_t no_inline_depth = frame_depth - inlined_frames_before_frame;
+ return StackVisitor::ComputeNumFrames(self, kInstrumentationStackWalk) - no_inline_depth;
+}
+
static void CheckStackDepth(Thread* self, const InstrumentationStackFrame& instrumentation_frame,
int delta)
SHARED_REQUIRES(Locks::mutator_lock_) {
diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h
index 612ca14cf5..8dd2357e06 100644
--- a/runtime/instrumentation.h
+++ b/runtime/instrumentation.h
@@ -397,6 +397,11 @@ class Instrumentation {
SHARED_REQUIRES(Locks::mutator_lock_)
REQUIRES(!Locks::thread_list_lock_);
+ static size_t ComputeFrameId(Thread* self,
+ size_t frame_depth,
+ size_t inlined_frames_before_frame)
+ SHARED_REQUIRES(Locks::mutator_lock_);
+
private:
InstrumentationLevel GetCurrentInstrumentationLevel() const;
diff --git a/runtime/stack.cc b/runtime/stack.cc
index d93a57daa9..4715224f6e 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -891,6 +891,7 @@ void StackVisitor::WalkStack(bool include_transitions) {
CHECK_EQ(cur_depth_, 0U);
bool exit_stubs_installed = Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled();
uint32_t instrumentation_stack_depth = 0;
+ size_t inlined_frames_count = 0;
for (const ManagedStack* current_fragment = thread_->GetManagedStack();
current_fragment != nullptr; current_fragment = current_fragment->GetLink()) {
@@ -922,6 +923,7 @@ void StackVisitor::WalkStack(bool include_transitions) {
return;
}
cur_depth_++;
+ inlined_frames_count++;
}
}
}
@@ -952,16 +954,19 @@ void StackVisitor::WalkStack(bool include_transitions) {
ArtMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs);
CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: "
<< PrettyMethod(GetMethod());
- } else if (instrumentation_frame.method_ != GetMethod()) {
- LOG(FATAL) << "Expected: " << PrettyMethod(instrumentation_frame.method_)
- << " Found: " << PrettyMethod(GetMethod());
+ } else {
+ CHECK_EQ(instrumentation_frame.method_, GetMethod())
+ << "Expected: " << PrettyMethod(instrumentation_frame.method_)
+ << " Found: " << PrettyMethod(GetMethod());
}
if (num_frames_ != 0) {
// Check agreement of frame Ids only if num_frames_ is computed to avoid infinite
// recursion.
- CHECK(instrumentation_frame.frame_id_ == GetFrameId())
- << "Expected: " << instrumentation_frame.frame_id_
- << " Found: " << GetFrameId();
+ size_t frame_id = instrumentation::Instrumentation::ComputeFrameId(
+ thread_,
+ cur_depth_,
+ inlined_frames_count);
+ CHECK_EQ(instrumentation_frame.frame_id_, frame_id);
}
return_pc = instrumentation_frame.return_pc_;
}