Print the correct return address, even on architectures where StackFrame::instruction is offset.
a=bruce.dawson, r=jimblandy git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1105 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
//
|
||||
// Author: Mark Mentovai, Ted Mielczarek
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "common/scoped_ptr.h"
|
||||
#include "google_breakpad/processor/call_stack.h"
|
||||
@@ -100,6 +101,11 @@ StackwalkerAMD64::StackwalkerAMD64(const SystemInfo* system_info,
|
||||
(sizeof(cfi_register_map_) / sizeof(cfi_register_map_[0]))) {
|
||||
}
|
||||
|
||||
u_int64_t StackFrameAMD64::ReturnAddress() const
|
||||
{
|
||||
assert(context_validity & StackFrameAMD64::CONTEXT_VALID_RIP);
|
||||
return context.rip;
|
||||
}
|
||||
|
||||
StackFrame* StackwalkerAMD64::GetContextFrame() {
|
||||
if (!context_) {
|
||||
@@ -226,14 +232,11 @@ StackFrame* StackwalkerAMD64::GetCallerFrame(const CallStack* stack) {
|
||||
if (new_frame->context.rsp <= last_frame->context.rsp)
|
||||
return NULL;
|
||||
|
||||
// new_frame->context.rip is the return address, which is one instruction
|
||||
// past the CALL that caused us to arrive at the callee. Set
|
||||
// new_frame->instruction to one less than that. This won't reference the
|
||||
// beginning of the CALL instruction, but it's guaranteed to be within
|
||||
// the CALL, which is sufficient to get the source line information to
|
||||
// match up with the line that contains a function call. Callers that
|
||||
// require the exact return address value may access the context.rip
|
||||
// field of StackFrameAMD64.
|
||||
// new_frame->context.rip is the return address, which is the instruction
|
||||
// after the CALL that caused us to arrive at the callee. Set
|
||||
// new_frame->instruction to one less than that, so it points within the
|
||||
// CALL instruction. See StackFrame::instruction for details, and
|
||||
// StackFrameAMD64::ReturnAddress.
|
||||
new_frame->instruction = new_frame->context.rip - 1;
|
||||
|
||||
return new_frame.release();
|
||||
|
||||
Reference in New Issue
Block a user