toolkit/crashreporter/google-breakpad/src/processor/stackwalker_amd64.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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.
    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
    38 #ifndef PROCESSOR_STACKWALKER_AMD64_H__
    39 #define PROCESSOR_STACKWALKER_AMD64_H__
    41 #include <vector>
    43 #include "google_breakpad/common/breakpad_types.h"
    44 #include "google_breakpad/common/minidump_format.h"
    45 #include "google_breakpad/processor/stackwalker.h"
    46 #include "google_breakpad/processor/stack_frame_cpu.h"
    47 #include "processor/cfi_frame_info.h"
    49 namespace google_breakpad {
    51 class CodeModules;
    53 class StackwalkerAMD64 : public Stackwalker {
    54  public:
    55   // context is a amd64 context object that gives access to amd64-specific
    56   // register state corresponding to the innermost called frame to be
    57   // included in the stack.  The other arguments are passed directly through
    58   // to the base Stackwalker constructor.
    59   StackwalkerAMD64(const SystemInfo* system_info,
    60                    const MDRawContextAMD64* context,
    61                    MemoryRegion* memory,
    62                    const CodeModules* modules,
    63                    StackFrameSymbolizer* frame_symbolizer);
    65  private:
    66   // A STACK CFI-driven frame walker for the AMD64
    67   typedef SimpleCFIWalker<uint64_t, MDRawContextAMD64> CFIWalker;
    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                                      bool stack_scan_allowed);
    75   // Use cfi_frame_info (derived from STACK CFI records) to construct
    76   // the frame that called frames.back(). The caller takes ownership
    77   // of the returned frame. Return NULL on failure.
    78   StackFrameAMD64* GetCallerByCFIFrameInfo(const vector<StackFrame*> &frames,
    79                                            CFIFrameInfo* cfi_frame_info);
    81   // Scan the stack for plausible return addresses. The caller takes ownership
    82   // of the returned frame. Return NULL on failure.
    83   StackFrameAMD64* GetCallerByStackScan(const vector<StackFrame*> &frames);
    85   // Stores the CPU context corresponding to the innermost stack frame to
    86   // be returned by GetContextFrame.
    87   const MDRawContextAMD64* context_;
    89   // Our register map, for cfi_walker_.
    90   static const CFIWalker::RegisterSet cfi_register_map_[];
    92   // Our CFI frame walker.
    93   const CFIWalker cfi_walker_;
    94 };
    97 }  // namespace google_breakpad
   100 #endif  // PROCESSOR_STACKWALKER_AMD64_H__

mercurial