Breakpad: Support DWARF CFI-driven stack walking on ARM.
This patch allows the Breakpad minidump processor to use data from
STACK CFI records to generate stack traces for the ARM processor.
In the symbol dumper, we need a table mapping DWARF CFI register
numbers to their names: STACK CFI records refer to registers by name.
In the processor, we expand StackwalkerARM::GetCallerFrame to see if
there are STACK CFI records covering the callee, and then use those to
recover the caller's register values.
There's no good reason the ARM walker couldn't use the SimpleCFIWalker
interface declared in cfi_frame_info.h. Unfortunately, that interface
assumes that one can map register names to member pointers of the raw
context type, while MDRawContextARM uses an array to hold the
registers' values: C++ pointer-to-member types can't refer to elements
of member arrays. So we have to write out SimpleCFIWalker::FindCallerRegisters
in StackwalkerARM::GetCallerFrame.
We define enum MDARMRegisterNumbers in minidump_cpu_arm.h, for
convenience in referring to certain ARM registers with dedicated
purposes, like the stack pointer and the PC.
We define validity flags in StackFrameARM for all the registers, since
CFI could theoretically recover any of them. In the same vein, we
expand minidump_stackwalk.cc to print the values of all valid
callee-saves registers in the context --- and use the proper names for
special-purpose registers.
We provide unit tests that give full code and branch coverage (with
minor exceptions). We add a testing interface to StackwalkerARM that
allows us to create context frames that lack some register values.
a=jimblandy, r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@553 4c0a9323-5329-0410-9bdc-e9ce6186880e
2010-03-16 16:46:22 +00:00
|
|
|
// -*- mode: C++ -*-
|
|
|
|
|
2010-02-09 17:08:56 +00:00
|
|
|
// Copyright (c) 2010 Google Inc.
|
2009-12-19 21:43:53 +00:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
|
|
// in the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived from
|
|
|
|
// this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
// stackwalker_arm.h: arm-specific stackwalker.
|
|
|
|
//
|
|
|
|
// Provides stack frames given arm register context and a memory region
|
|
|
|
// corresponding to an arm stack.
|
|
|
|
//
|
|
|
|
// Author: Mark Mentovai, Ted Mielczarek
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PROCESSOR_STACKWALKER_ARM_H__
|
|
|
|
#define PROCESSOR_STACKWALKER_ARM_H__
|
|
|
|
|
|
|
|
#include "google_breakpad/common/breakpad_types.h"
|
|
|
|
#include "google_breakpad/common/minidump_format.h"
|
|
|
|
#include "google_breakpad/processor/stackwalker.h"
|
|
|
|
|
|
|
|
namespace google_breakpad {
|
|
|
|
|
|
|
|
class CodeModules;
|
|
|
|
|
|
|
|
class StackwalkerARM : public Stackwalker {
|
|
|
|
public:
|
|
|
|
// context is an arm context object that gives access to arm-specific
|
|
|
|
// register state corresponding to the innermost called frame to be
|
|
|
|
// included in the stack. The other arguments are passed directly through
|
|
|
|
// to the base Stackwalker constructor.
|
2012-10-10 21:41:52 +00:00
|
|
|
StackwalkerARM(const SystemInfo* system_info,
|
|
|
|
const MDRawContextARM* context,
|
2011-10-17 13:42:35 +00:00
|
|
|
int fp_register,
|
2012-10-10 21:41:52 +00:00
|
|
|
MemoryRegion* memory,
|
|
|
|
const CodeModules* modules,
|
|
|
|
StackFrameSymbolizer* frame_symbolizer);
|
2009-12-19 21:43:53 +00:00
|
|
|
|
Breakpad: Support DWARF CFI-driven stack walking on ARM.
This patch allows the Breakpad minidump processor to use data from
STACK CFI records to generate stack traces for the ARM processor.
In the symbol dumper, we need a table mapping DWARF CFI register
numbers to their names: STACK CFI records refer to registers by name.
In the processor, we expand StackwalkerARM::GetCallerFrame to see if
there are STACK CFI records covering the callee, and then use those to
recover the caller's register values.
There's no good reason the ARM walker couldn't use the SimpleCFIWalker
interface declared in cfi_frame_info.h. Unfortunately, that interface
assumes that one can map register names to member pointers of the raw
context type, while MDRawContextARM uses an array to hold the
registers' values: C++ pointer-to-member types can't refer to elements
of member arrays. So we have to write out SimpleCFIWalker::FindCallerRegisters
in StackwalkerARM::GetCallerFrame.
We define enum MDARMRegisterNumbers in minidump_cpu_arm.h, for
convenience in referring to certain ARM registers with dedicated
purposes, like the stack pointer and the PC.
We define validity flags in StackFrameARM for all the registers, since
CFI could theoretically recover any of them. In the same vein, we
expand minidump_stackwalk.cc to print the values of all valid
callee-saves registers in the context --- and use the proper names for
special-purpose registers.
We provide unit tests that give full code and branch coverage (with
minor exceptions). We add a testing interface to StackwalkerARM that
allows us to create context frames that lack some register values.
a=jimblandy, r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@553 4c0a9323-5329-0410-9bdc-e9ce6186880e
2010-03-16 16:46:22 +00:00
|
|
|
// Change the context validity mask of the frame returned by
|
|
|
|
// GetContextFrame to VALID. This is only for use by unit tests; the
|
|
|
|
// default behavior is correct for all application code.
|
|
|
|
void SetContextFrameValidity(int valid) { context_frame_validity_ = valid; }
|
|
|
|
|
2009-12-19 21:43:53 +00:00
|
|
|
private:
|
|
|
|
// Implementation of Stackwalker, using arm context and stack conventions.
|
|
|
|
virtual StackFrame* GetContextFrame();
|
2013-08-19 18:31:51 +00:00
|
|
|
virtual StackFrame* GetCallerFrame(const CallStack* stack,
|
|
|
|
bool stack_scan_allowed);
|
2009-12-19 21:43:53 +00:00
|
|
|
|
2010-10-01 13:04:16 +00:00
|
|
|
// Use cfi_frame_info (derived from STACK CFI records) to construct
|
|
|
|
// the frame that called frames.back(). The caller takes ownership
|
|
|
|
// of the returned frame. Return NULL on failure.
|
2012-10-10 21:41:52 +00:00
|
|
|
StackFrameARM* GetCallerByCFIFrameInfo(const vector<StackFrame*> &frames,
|
|
|
|
CFIFrameInfo* cfi_frame_info);
|
2010-10-01 13:04:16 +00:00
|
|
|
|
2011-10-17 13:42:35 +00:00
|
|
|
// Use the frame pointer. The caller takes ownership of the returned frame.
|
|
|
|
// Return NULL on failure.
|
2012-10-10 21:41:52 +00:00
|
|
|
StackFrameARM* GetCallerByFramePointer(const vector<StackFrame*> &frames);
|
2011-10-17 13:42:35 +00:00
|
|
|
|
2010-10-01 13:04:16 +00:00
|
|
|
// Scan the stack for plausible return addresses. The caller takes ownership
|
2011-10-17 13:42:35 +00:00
|
|
|
// of the returned frame. Return NULL on failure.
|
2012-10-10 21:41:52 +00:00
|
|
|
StackFrameARM* GetCallerByStackScan(const vector<StackFrame*> &frames);
|
2010-10-01 13:04:16 +00:00
|
|
|
|
Breakpad: Support DWARF CFI-driven stack walking on ARM.
This patch allows the Breakpad minidump processor to use data from
STACK CFI records to generate stack traces for the ARM processor.
In the symbol dumper, we need a table mapping DWARF CFI register
numbers to their names: STACK CFI records refer to registers by name.
In the processor, we expand StackwalkerARM::GetCallerFrame to see if
there are STACK CFI records covering the callee, and then use those to
recover the caller's register values.
There's no good reason the ARM walker couldn't use the SimpleCFIWalker
interface declared in cfi_frame_info.h. Unfortunately, that interface
assumes that one can map register names to member pointers of the raw
context type, while MDRawContextARM uses an array to hold the
registers' values: C++ pointer-to-member types can't refer to elements
of member arrays. So we have to write out SimpleCFIWalker::FindCallerRegisters
in StackwalkerARM::GetCallerFrame.
We define enum MDARMRegisterNumbers in minidump_cpu_arm.h, for
convenience in referring to certain ARM registers with dedicated
purposes, like the stack pointer and the PC.
We define validity flags in StackFrameARM for all the registers, since
CFI could theoretically recover any of them. In the same vein, we
expand minidump_stackwalk.cc to print the values of all valid
callee-saves registers in the context --- and use the proper names for
special-purpose registers.
We provide unit tests that give full code and branch coverage (with
minor exceptions). We add a testing interface to StackwalkerARM that
allows us to create context frames that lack some register values.
a=jimblandy, r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@553 4c0a9323-5329-0410-9bdc-e9ce6186880e
2010-03-16 16:46:22 +00:00
|
|
|
// Stores the CPU context corresponding to the youngest stack frame, to
|
2009-12-19 21:43:53 +00:00
|
|
|
// be returned by GetContextFrame.
|
2012-10-10 21:41:52 +00:00
|
|
|
const MDRawContextARM* context_;
|
Breakpad: Support DWARF CFI-driven stack walking on ARM.
This patch allows the Breakpad minidump processor to use data from
STACK CFI records to generate stack traces for the ARM processor.
In the symbol dumper, we need a table mapping DWARF CFI register
numbers to their names: STACK CFI records refer to registers by name.
In the processor, we expand StackwalkerARM::GetCallerFrame to see if
there are STACK CFI records covering the callee, and then use those to
recover the caller's register values.
There's no good reason the ARM walker couldn't use the SimpleCFIWalker
interface declared in cfi_frame_info.h. Unfortunately, that interface
assumes that one can map register names to member pointers of the raw
context type, while MDRawContextARM uses an array to hold the
registers' values: C++ pointer-to-member types can't refer to elements
of member arrays. So we have to write out SimpleCFIWalker::FindCallerRegisters
in StackwalkerARM::GetCallerFrame.
We define enum MDARMRegisterNumbers in minidump_cpu_arm.h, for
convenience in referring to certain ARM registers with dedicated
purposes, like the stack pointer and the PC.
We define validity flags in StackFrameARM for all the registers, since
CFI could theoretically recover any of them. In the same vein, we
expand minidump_stackwalk.cc to print the values of all valid
callee-saves registers in the context --- and use the proper names for
special-purpose registers.
We provide unit tests that give full code and branch coverage (with
minor exceptions). We add a testing interface to StackwalkerARM that
allows us to create context frames that lack some register values.
a=jimblandy, r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@553 4c0a9323-5329-0410-9bdc-e9ce6186880e
2010-03-16 16:46:22 +00:00
|
|
|
|
2011-10-18 07:35:46 +00:00
|
|
|
// The register to use a as frame pointer. The value is -1 if frame pointer
|
|
|
|
// cannot be used.
|
|
|
|
int fp_register_;
|
|
|
|
|
Breakpad: Support DWARF CFI-driven stack walking on ARM.
This patch allows the Breakpad minidump processor to use data from
STACK CFI records to generate stack traces for the ARM processor.
In the symbol dumper, we need a table mapping DWARF CFI register
numbers to their names: STACK CFI records refer to registers by name.
In the processor, we expand StackwalkerARM::GetCallerFrame to see if
there are STACK CFI records covering the callee, and then use those to
recover the caller's register values.
There's no good reason the ARM walker couldn't use the SimpleCFIWalker
interface declared in cfi_frame_info.h. Unfortunately, that interface
assumes that one can map register names to member pointers of the raw
context type, while MDRawContextARM uses an array to hold the
registers' values: C++ pointer-to-member types can't refer to elements
of member arrays. So we have to write out SimpleCFIWalker::FindCallerRegisters
in StackwalkerARM::GetCallerFrame.
We define enum MDARMRegisterNumbers in minidump_cpu_arm.h, for
convenience in referring to certain ARM registers with dedicated
purposes, like the stack pointer and the PC.
We define validity flags in StackFrameARM for all the registers, since
CFI could theoretically recover any of them. In the same vein, we
expand minidump_stackwalk.cc to print the values of all valid
callee-saves registers in the context --- and use the proper names for
special-purpose registers.
We provide unit tests that give full code and branch coverage (with
minor exceptions). We add a testing interface to StackwalkerARM that
allows us to create context frames that lack some register values.
a=jimblandy, r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@553 4c0a9323-5329-0410-9bdc-e9ce6186880e
2010-03-16 16:46:22 +00:00
|
|
|
// Validity mask for youngest stack frame. This is always
|
|
|
|
// CONTEXT_VALID_ALL in real use; it is only changeable for the sake of
|
|
|
|
// unit tests.
|
|
|
|
int context_frame_validity_;
|
2009-12-19 21:43:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace google_breakpad
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PROCESSOR_STACKWALKER_ARM_H__
|