Display all stack frames on a crash.
Bug: 74121887
Test: Forced a crash in the unwind code and verified the frames
Test: in the unwinder are present.
Change-Id: Id158dadea25e986a0d2e9feba0873a921644fd22
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index c26c26e..0db1770 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -287,7 +287,8 @@
BacktraceMap* existing_map,
const char* prefix,
ArtMethod* current_method,
- void* ucontext_ptr) {
+ void* ucontext_ptr,
+ bool skip_frames) {
// b/18119146
if (RUNNING_ON_MEMORY_TOOL != 0) {
return;
@@ -300,6 +301,7 @@
map = tmp_map.get();
}
std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, tid, map));
+ backtrace->SetSkipFrames(skip_frames);
if (!backtrace->Unwind(0, reinterpret_cast<ucontext*>(ucontext_ptr))) {
os << prefix << "(backtrace::Unwind failed for thread " << tid
<< ": " << backtrace->GetErrorString(backtrace->GetError()) << ")" << std::endl;
diff --git a/runtime/native_stack_dump.h b/runtime/native_stack_dump.h
index d64bc82..ad4bfab 100644
--- a/runtime/native_stack_dump.h
+++ b/runtime/native_stack_dump.h
@@ -35,7 +35,8 @@
BacktraceMap* map = nullptr,
const char* prefix = "",
ArtMethod* current_method = nullptr,
- void* ucontext = nullptr)
+ void* ucontext = nullptr,
+ bool skip_frames = true)
NO_THREAD_SAFETY_ANALYSIS;
// Dumps the kernel stack for thread 'tid' to 'os'. Note that this is only available on linux-x86.
diff --git a/runtime/runtime_common.h b/runtime/runtime_common.h
index 3fba441..698d060 100644
--- a/runtime/runtime_common.h
+++ b/runtime/runtime_common.h
@@ -40,7 +40,9 @@
public:
explicit Backtrace(void* raw_context) : raw_context_(raw_context) {}
void Dump(std::ostream& os) const {
- DumpNativeStack(os, GetTid(), nullptr, "\t", nullptr, raw_context_);
+ // This is a backtrace from a crash, do not skip any frames in case the
+ // crash is in the unwinder itself.
+ DumpNativeStack(os, GetTid(), nullptr, "\t", nullptr, raw_context_, false);
}
private:
// Stores the context of the signal that was unexpected and will terminate the runtime. The