From 5497f749b4d35c7b0767d21cb487e2fee293cd07 Mon Sep 17 00:00:00 2001 From: Mythri Alle Date: Mon, 19 Dec 2022 09:40:18 +0000 Subject: Fix method tracing in non-debuggable runtimes There are a few fixes needed for correctly supporting method tracing in non-debuggable runtimes: 1. When we start method tracing we report method entry events for methods already on the stack with the expectation that method exit events would be called when method finishes. In non-debuggable runtimes some of these may not support method exit events, so report method entry events only if the frame supports them. 2. When method tracing is enabled, we switch the runtime to debuggable. When we switch to debuggable runtime, we missed updating entrypoints and deoptimizing boot image. Fix it so we get method entry / exit events for all methods. Also updates test 2246-method-trace to work in non-debuggable runtimes. Bug: 259258187 Test: art/testrunner.py -t 2246 Change-Id: I040416c7cb72062c02312eedb5bcd41da09e53dc --- runtime/quick_exception_handler.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime/quick_exception_handler.cc') diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index eb9b47180f..1dc90097e0 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -476,6 +476,12 @@ class DeoptimizeStackVisitor final : public StackVisitor { } else { HandleOptimizingDeoptimization(method, new_frame, updated_vregs); } + // Update if method exit event needs to be reported. We should report exit event only if we + // have reported an entry event. So tell interpreter if/ an entry event was reported. + bool supports_exit_events = + Runtime::Current()->GetInstrumentation()->MethodSupportsExitEvents( + method, GetCurrentOatQuickMethodHeader()); + new_frame->SetSkipMethodExitEvents(!supports_exit_events); if (updated_vregs != nullptr) { // Calling Thread::RemoveDebuggerShadowFrameMapping will also delete the updated_vregs // array so this must come after we processed the frame. -- cgit v1.2.3-59-g8ed1b