From b45b97b2fd735eea5f0e5824b0a48132ccafd88e Mon Sep 17 00:00:00 2001 From: "mseaborn@chromium.org" Date: Wed, 8 May 2013 02:37:15 +0000 Subject: Make x86-64 stack walking work for Native Client minidumps For NaCl, a stack walker should ignore the top 32 bits of %rip, %rsp and %rbp, otherwise it will try to read from %r15-extended stack addresses and look up symbol info for %r15-extended code addresses, which will fail. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3424 TEST=tested manually with a NaCl minidump Review URL: https://breakpad.appspot.com/591002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1173 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/google_breakpad/processor/system_info.h | 9 +++++---- src/processor/stackwalker_amd64.cc | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/google_breakpad/processor/system_info.h b/src/google_breakpad/processor/system_info.h index 4a250482..9583d9e8 100644 --- a/src/google_breakpad/processor/system_info.h +++ b/src/google_breakpad/processor/system_info.h @@ -63,10 +63,11 @@ struct SystemInfo { string os; // A short form of the os string, using lowercase letters and no spaces, - // suitable for use in a filesystem. Possible values are "windows", - // "mac", and "linux". Empty if the information is not present in the dump - // or if the OS given by the dump is unknown. The values stored in this - // field should match those used by MinidumpSystemInfo::GetOS. + // suitable for use in a filesystem. Possible values include "windows", + // "mac", "linux" and "nacl". Empty if the information is not present + // in the dump or if the OS given by the dump is unknown. The values + // stored in this field should match those used by + // MinidumpSystemInfo::GetOS. string os_short; // A string identifying the version of the operating system, such as diff --git a/src/processor/stackwalker_amd64.cc b/src/processor/stackwalker_amd64.cc index 656af183..737a2496 100644 --- a/src/processor/stackwalker_amd64.cc +++ b/src/processor/stackwalker_amd64.cc @@ -40,6 +40,7 @@ #include "google_breakpad/processor/memory_region.h" #include "google_breakpad/processor/source_line_resolver_interface.h" #include "google_breakpad/processor/stack_frame_cpu.h" +#include "google_breakpad/processor/system_info.h" #include "processor/cfi_frame_info.h" #include "processor/logging.h" #include "processor/stackwalker_amd64.h" @@ -222,6 +223,16 @@ StackFrame* StackwalkerAMD64::GetCallerFrame(const CallStack* stack) { if (!new_frame.get()) return NULL; + if (system_info_->os_short == "nacl") { + // Apply constraints from Native Client's x86-64 sandbox. These + // registers have the 4GB-aligned sandbox base address (from r15) + // added to them, and only the bottom 32 bits are relevant for + // stack walking. + new_frame->context.rip = static_cast(new_frame->context.rip); + new_frame->context.rsp = static_cast(new_frame->context.rsp); + new_frame->context.rbp = static_cast(new_frame->context.rbp); + } + // Treat an instruction address of 0 as end-of-stack. if (new_frame->context.rip == 0) return NULL; -- cgit v1.2.1