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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/crashreporter/google-breakpad/src/processor/stackwalker_x86.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,117 @@
     1.4 +// -*- mode: c++ -*-
     1.5 +
     1.6 +// Copyright (c) 2010 Google Inc.
     1.7 +// All rights reserved.
     1.8 +//
     1.9 +// Redistribution and use in source and binary forms, with or without
    1.10 +// modification, are permitted provided that the following conditions are
    1.11 +// met:
    1.12 +//
    1.13 +//     * Redistributions of source code must retain the above copyright
    1.14 +// notice, this list of conditions and the following disclaimer.
    1.15 +//     * Redistributions in binary form must reproduce the above
    1.16 +// copyright notice, this list of conditions and the following disclaimer
    1.17 +// in the documentation and/or other materials provided with the
    1.18 +// distribution.
    1.19 +//     * Neither the name of Google Inc. nor the names of its
    1.20 +// contributors may be used to endorse or promote products derived from
    1.21 +// this software without specific prior written permission.
    1.22 +//
    1.23 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.24 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.25 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.26 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.27 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.28 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.29 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.30 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.31 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.32 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.33 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.34 +
    1.35 +// stackwalker_x86.h: x86-specific stackwalker.
    1.36 +//
    1.37 +// Provides stack frames given x86 register context and a memory region
    1.38 +// corresponding to an x86 stack.
    1.39 +//
    1.40 +// Author: Mark Mentovai
    1.41 +
    1.42 +
    1.43 +#ifndef PROCESSOR_STACKWALKER_X86_H__
    1.44 +#define PROCESSOR_STACKWALKER_X86_H__
    1.45 +
    1.46 +#include <vector>
    1.47 +
    1.48 +#include "google_breakpad/common/breakpad_types.h"
    1.49 +#include "google_breakpad/common/minidump_format.h"
    1.50 +#include "google_breakpad/processor/stackwalker.h"
    1.51 +#include "google_breakpad/processor/stack_frame_cpu.h"
    1.52 +#include "processor/cfi_frame_info.h"
    1.53 +
    1.54 +namespace google_breakpad {
    1.55 +
    1.56 +class CodeModules;
    1.57 +
    1.58 +
    1.59 +class StackwalkerX86 : public Stackwalker {
    1.60 + public:
    1.61 +  // context is an x86 context object that gives access to x86-specific
    1.62 +  // register state corresponding to the innermost called frame to be
    1.63 +  // included in the stack.  The other arguments are passed directly through
    1.64 +  // to the base Stackwalker constructor.
    1.65 +  StackwalkerX86(const SystemInfo* system_info,
    1.66 +                 const MDRawContextX86* context,
    1.67 +                 MemoryRegion* memory,
    1.68 +                 const CodeModules* modules,
    1.69 +                 StackFrameSymbolizer* frame_symbolizer);
    1.70 +
    1.71 + private:
    1.72 +  // A STACK CFI-driven frame walker for the X86.
    1.73 +  typedef SimpleCFIWalker<uint32_t, MDRawContextX86> CFIWalker;
    1.74 +
    1.75 +  // Implementation of Stackwalker, using x86 context (%ebp, %esp, %eip) and
    1.76 +  // stack conventions (saved %ebp at [%ebp], saved %eip at 4[%ebp], or
    1.77 +  // alternate conventions as guided by any WindowsFrameInfo available for the
    1.78 +  // code in question.).
    1.79 +  virtual StackFrame* GetContextFrame();
    1.80 +  virtual StackFrame* GetCallerFrame(const CallStack* stack,
    1.81 +                                     bool stack_scan_allowed);
    1.82 +
    1.83 +  // Use windows_frame_info (derived from STACK WIN and FUNC records)
    1.84 +  // to construct the frame that called frames.back(). The caller
    1.85 +  // takes ownership of the returned frame. Return NULL on failure.
    1.86 +  StackFrameX86* GetCallerByWindowsFrameInfo(
    1.87 +      const vector<StackFrame*> &frames,
    1.88 +      WindowsFrameInfo* windows_frame_info,
    1.89 +      bool stack_scan_allowed);
    1.90 +
    1.91 +  // Use cfi_frame_info (derived from STACK CFI records) to construct
    1.92 +  // the frame that called frames.back(). The caller takes ownership
    1.93 +  // of the returned frame. Return NULL on failure.
    1.94 +  StackFrameX86* GetCallerByCFIFrameInfo(const vector<StackFrame*> &frames,
    1.95 +                                         CFIFrameInfo* cfi_frame_info);
    1.96 +
    1.97 +  // Assuming a traditional frame layout --- where the caller's %ebp
    1.98 +  // has been pushed just after the return address and the callee's
    1.99 +  // %ebp points to the saved %ebp --- construct the frame that called
   1.100 +  // frames.back(). The caller takes ownership of the returned frame.
   1.101 +  // Return NULL on failure.
   1.102 +  StackFrameX86* GetCallerByEBPAtBase(const vector<StackFrame*> &frames,
   1.103 +                                      bool stack_scan_allowed);
   1.104 +
   1.105 +  // Stores the CPU context corresponding to the innermost stack frame to
   1.106 +  // be returned by GetContextFrame.
   1.107 +  const MDRawContextX86* context_;
   1.108 +
   1.109 +  // Our register map, for cfi_walker_.
   1.110 +  static const CFIWalker::RegisterSet cfi_register_map_[];
   1.111 +
   1.112 +  // Our CFI frame walker.
   1.113 +  const CFIWalker cfi_walker_;
   1.114 +};
   1.115 +
   1.116 +
   1.117 +}  // namespace google_breakpad
   1.118 +
   1.119 +
   1.120 +#endif  // PROCESSOR_STACKWALKER_X86_H__

mercurial