PageRenderTime 17ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/thirdparty/breakpad/processor/stackwalker_x86.h

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