Fix DumpNativeStack function for traced methods.
The art_quick_instrumentation_exit stub does not have oat header.
Bug: 123510633
Test: test.py -b -r --host --trace -r -t 163
Change-Id: I56d72816daf836440feccb42c81031f120e8c4c5
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index a4425ce..40bab0f 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -44,6 +44,7 @@
#include "arch/instruction_set.h"
#include "base/aborting.h"
+#include "base/bit_utils.h"
#include "base/file_utils.h"
#include "base/memory_tool.h"
#include "base/mutex.h"
@@ -51,6 +52,7 @@
#include "base/unix_file/fd_file.h"
#include "base/utils.h"
#include "class_linker.h"
+#include "entrypoints/runtime_asm_entrypoints.h"
#include "oat_quick_method_header.h"
#include "runtime.h"
#include "thread-current-inl.h"
@@ -299,6 +301,12 @@
class_linker->IsQuickToInterpreterBridge(entry_point)) {
return false;
}
+ // The backtrace library might have heuristically subracted 1 from the pc,
+ // to pretend the pc is at the calling instruction.
+ DCHECK_ALIGNED(GetQuickInstrumentationExitPc(), sizeof(void*));
+ if (AlignUp(reinterpret_cast<void*>(pc), sizeof(void*)) == GetQuickInstrumentationExitPc()) {
+ return false;
+ }
uintptr_t code = reinterpret_cast<uintptr_t>(EntryPointToCodePointer(entry_point));
uintptr_t code_size = reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].GetCodeSize();
return code <= pc && pc <= (code + code_size);