/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. // stackwalker_amd64.h: amd64-specific stackwalker.
  30. //
  31. // Provides stack frames given amd64 register context and a memory region
  32. // corresponding to a amd64 stack.
  33. //
  34. // Author: Mark Mentovai, Ted Mielczarek
  35. #ifndef PROCESSOR_STACKWALKER_AMD64_H__
  36. #define PROCESSOR_STACKWALKER_AMD64_H__
  37. #include "google_breakpad/common/breakpad_types.h"
  38. #include "google_breakpad/common/minidump_format.h"
  39. #include "google_breakpad/processor/stackwalker.h"
  40. #include "google_breakpad/processor/stack_frame_cpu.h"
  41. #include "processor/cfi_frame_info.h"
  42. namespace google_breakpad {
  43. class CodeModules;
  44. class StackwalkerAMD64 : public Stackwalker {
  45. public:
  46. // context is a amd64 context object that gives access to amd64-specific
  47. // register state corresponding to the innermost called frame to be
  48. // included in the stack. The other arguments are passed directly through
  49. // to the base Stackwalker constructor.
  50. StackwalkerAMD64(const SystemInfo *system_info,
  51. const MDRawContextAMD64 *context,
  52. MemoryRegion *memory,
  53. const CodeModules *modules,
  54. SymbolSupplier *supplier,
  55. SourceLineResolverInterface *resolver);
  56. private:
  57. // A STACK CFI-driven frame walker for the AMD64
  58. typedef SimpleCFIWalker<u_int64_t, MDRawContextAMD64> CFIWalker;
  59. // Implementation of Stackwalker, using amd64 context (stack pointer in %rsp,
  60. // stack base in %rbp) and stack conventions (saved stack pointer at 0(%rbp))
  61. virtual StackFrame* GetContextFrame();
  62. virtual StackFrame* GetCallerFrame(const CallStack *stack);
  63. // Use cfi_frame_info (derived from STACK CFI records) to construct
  64. // the frame that called frames.back(). The caller takes ownership
  65. // of the returned frame. Return NULL on failure.
  66. StackFrameAMD64 *GetCallerByCFIFrameInfo(const vector<StackFrame *> &frames,
  67. CFIFrameInfo *cfi_frame_info);
  68. // Scan the stack for plausible return addresses. The caller takes ownership
  69. // of the returned frame. Return NULL on failure.
  70. StackFrameAMD64 *GetCallerByStackScan(const vector<StackFrame *> &frames);
  71. // Stores the CPU context corresponding to the innermost stack frame to
  72. // be returned by GetContextFrame.
  73. const MDRawContextAMD64 *context_;
  74. // Our register map, for cfi_walker_.
  75. static const CFIWalker::RegisterSet cfi_register_map_[];
  76. // Our CFI frame walker.
  77. const CFIWalker cfi_walker_;
  78. };
  79. } // namespace google_breakpad
  80. #endif // PROCESSOR_STACKWALKER_AMD64_H__