/thirdparty/breakpad/google_breakpad/processor/stack_frame.h

http://github.com/tomahawk-player/tomahawk · C Header · 121 lines · 53 code · 18 blank · 50 comment · 1 complexity · b14180ed43d9441cb0241bf2d0593aed MD5 · raw file

  1. // Copyright (c) 2006, 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. #ifndef GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
  30. #define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__
  31. #include <string>
  32. #include "google_breakpad/common/breakpad_types.h"
  33. namespace google_breakpad {
  34. class CodeModule;
  35. using std::string;
  36. struct StackFrame {
  37. // Indicates how well the instruction pointer derived during
  38. // stack walking is trusted. Since the stack walker can resort to
  39. // stack scanning, it can wind up with dubious frames.
  40. // In rough order of "trust metric".
  41. enum FrameTrust {
  42. FRAME_TRUST_NONE, // Unknown
  43. FRAME_TRUST_SCAN, // Scanned the stack, found this
  44. FRAME_TRUST_CFI_SCAN, // Scanned the stack using call frame info, found this
  45. FRAME_TRUST_FP, // Derived from frame pointer
  46. FRAME_TRUST_CFI, // Derived from call frame info
  47. FRAME_TRUST_CONTEXT // Given as instruction pointer in a context
  48. };
  49. StackFrame()
  50. : instruction(),
  51. module(NULL),
  52. function_name(),
  53. function_base(),
  54. source_file_name(),
  55. source_line(),
  56. source_line_base(),
  57. trust(FRAME_TRUST_NONE) {}
  58. virtual ~StackFrame() {}
  59. // Return a string describing how this stack frame was found
  60. // by the stackwalker.
  61. string trust_description() const {
  62. switch (trust) {
  63. case StackFrame::FRAME_TRUST_CONTEXT:
  64. return "given as instruction pointer in context";
  65. case StackFrame::FRAME_TRUST_CFI:
  66. return "call frame info";
  67. case StackFrame::FRAME_TRUST_CFI_SCAN:
  68. return "call frame info with scanning";
  69. case StackFrame::FRAME_TRUST_FP:
  70. return "previous frame's frame pointer";
  71. case StackFrame::FRAME_TRUST_SCAN:
  72. return "stack scanning";
  73. default:
  74. return "unknown";
  75. }
  76. };
  77. // The program counter location as an absolute virtual address. For the
  78. // innermost called frame in a stack, this will be an exact program counter
  79. // or instruction pointer value. For all other frames, this will be within
  80. // the instruction that caused execution to branch to a called function,
  81. // but may not necessarily point to the exact beginning of that instruction.
  82. u_int64_t instruction;
  83. // The module in which the instruction resides.
  84. const CodeModule *module;
  85. // The function name, may be omitted if debug symbols are not available.
  86. string function_name;
  87. // The start address of the function, may be omitted if debug symbols
  88. // are not available.
  89. u_int64_t function_base;
  90. // The source file name, may be omitted if debug symbols are not available.
  91. string source_file_name;
  92. // The (1-based) source line number, may be omitted if debug symbols are
  93. // not available.
  94. int source_line;
  95. // The start address of the source line, may be omitted if debug symbols
  96. // are not available.
  97. u_int64_t source_line_base;
  98. // Amount of trust the stack walker has in the instruction pointer
  99. // of this frame.
  100. FrameTrust trust;
  101. };
  102. } // namespace google_breakpad
  103. #endif // GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__