Run method entry callbacks for all methods on the stack am: 819f8b2354 am: 598a6fb0ab am: ddc4ea6cc8

Original change: https://android-review.googlesource.com/c/platform/art/+/2238835

Change-Id: I72352c5eaf779322ff37e848f26f0196280503d7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index aac0f6f..7f02cbf 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -532,6 +532,14 @@
           LOG(INFO) << "Ignoring already instrumented " << frame.Dump();
         }
       } else {
+        if (!m->IsRuntimeMethod()) {
+          // Record the method so we can call method entry callbacks for all non-runtime methods on
+          // the stack. Runtime methods don't need method entry callbacks.
+          // TODO(232212577): Add tests to check the validity of the tracefiles generated.
+          // Currently the tracing tests only check a trace file is generated.
+          stack_methods_.push_back(m);
+        }
+
         if (m->IsNative() && Runtime::Current()->IsJavaDebuggable()) {
           // Native methods in debuggable runtimes don't use instrumentation stubs.
           return true;
@@ -567,10 +575,6 @@
           LOG(INFO) << "Pushing frame " << instrumentation_frame.Dump();
         }
 
-        if (!m->IsRuntimeMethod()) {
-          // Runtime methods don't need to run method entry callbacks.
-          stack_methods_.push_back(m);
-        }
         instrumentation_stack_->insert({GetReturnPcAddr(), instrumentation_frame});
         SetReturnPc(instrumentation_exit_pc_);
       }