PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/thirdparty/breakpad/processor/stackwalker_amd64.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 99 lines | 30 code | 19 blank | 50 comment | 0 complexity | 1788f0e625c7feed8fdbdcc8a37784f7 MD5 | raw file
 1// Copyright (c) 2010 Google Inc.
 2// All rights reserved.
 3//
 4// Redistribution and use in source and binary forms, with or without
 5// modification, are permitted provided that the following conditions are
 6// met:
 7//
 8//     * Redistributions of source code must retain the above copyright
 9// notice, this list of conditions and the following disclaimer.
10//     * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14//     * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30// stackwalker_amd64.h: amd64-specific stackwalker.
31//
32// Provides stack frames given amd64 register context and a memory region
33// corresponding to a amd64 stack.
34//
35// Author: Mark Mentovai, Ted Mielczarek
36
37
38#ifndef PROCESSOR_STACKWALKER_AMD64_H__
39#define PROCESSOR_STACKWALKER_AMD64_H__
40
41
42#include "google_breakpad/common/breakpad_types.h"
43#include "google_breakpad/common/minidump_format.h"
44#include "google_breakpad/processor/stackwalker.h"
45#include "google_breakpad/processor/stack_frame_cpu.h"
46#include "processor/cfi_frame_info.h"
47
48namespace google_breakpad {
49
50class CodeModules;
51
52class StackwalkerAMD64 : public Stackwalker {
53 public:
54  // context is a amd64 context object that gives access to amd64-specific
55  // register state corresponding to the innermost called frame to be
56  // included in the stack.  The other arguments are passed directly through
57  // to the base Stackwalker constructor.
58  StackwalkerAMD64(const SystemInfo *system_info,
59                   const MDRawContextAMD64 *context,
60                   MemoryRegion *memory,
61                   const CodeModules *modules,
62                   SymbolSupplier *supplier,
63                   SourceLineResolverInterface *resolver);
64
65 private:
66  // A STACK CFI-driven frame walker for the AMD64
67  typedef SimpleCFIWalker<u_int64_t, MDRawContextAMD64> CFIWalker;
68
69  // Implementation of Stackwalker, using amd64 context (stack pointer in %rsp,
70  // stack base in %rbp) and stack conventions (saved stack pointer at 0(%rbp))
71  virtual StackFrame* GetContextFrame();
72  virtual StackFrame* GetCallerFrame(const CallStack *stack);
73
74  // Use cfi_frame_info (derived from STACK CFI records) to construct
75  // the frame that called frames.back(). The caller takes ownership
76  // of the returned frame. Return NULL on failure.
77  StackFrameAMD64 *GetCallerByCFIFrameInfo(const vector<StackFrame *> &frames,
78                                           CFIFrameInfo *cfi_frame_info);
79
80  // Scan the stack for plausible return addresses. The caller takes ownership
81  // of the returned frame. Return NULL on failure. 
82  StackFrameAMD64 *GetCallerByStackScan(const vector<StackFrame *> &frames);
83
84  // Stores the CPU context corresponding to the innermost stack frame to
85  // be returned by GetContextFrame.
86  const MDRawContextAMD64 *context_;
87
88  // Our register map, for cfi_walker_.
89  static const CFIWalker::RegisterSet cfi_register_map_[];
90
91  // Our CFI frame walker.
92  const CFIWalker cfi_walker_;
93};
94
95
96}  // namespace google_breakpad
97
98
99#endif  // PROCESSOR_STACKWALKER_AMD64_H__