PageRenderTime 22ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/thirdparty/breakpad/google_breakpad/processor/minidump_processor.h

http://github.com/tomahawk-player/tomahawk
C Header | 169 lines | 51 code | 27 blank | 91 comment | 2 complexity | 62337bd4ec69da724bba23f8a44bb95e MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, GPL-2.0
  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_MINIDUMP_PROCESSOR_H__
  30. #define GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__
  31. #include <assert.h>
  32. #include <string>
  33. #include "google_breakpad/common/breakpad_types.h"
  34. namespace google_breakpad {
  35. using std::string;
  36. class Minidump;
  37. class ProcessState;
  38. class SourceLineResolverInterface;
  39. class SymbolSupplier;
  40. struct SystemInfo;
  41. // Return type for Process()
  42. enum ProcessResult {
  43. PROCESS_OK, // The minidump was
  44. // processed
  45. // successfully.
  46. PROCESS_ERROR_MINIDUMP_NOT_FOUND, // The minidump file
  47. // was not found.
  48. PROCESS_ERROR_NO_MINIDUMP_HEADER, // The minidump file
  49. // had no header
  50. PROCESS_ERROR_NO_THREAD_LIST, // The minidump file
  51. // had no thread list.
  52. PROCESS_ERROR_GETTING_THREAD, // There was an error
  53. // getting one
  54. // thread's data from
  55. // the minidump.
  56. PROCESS_ERROR_GETTING_THREAD_ID, // There was an error
  57. // getting a thread id
  58. // from the thread's
  59. // data.
  60. PROCESS_ERROR_DUPLICATE_REQUESTING_THREADS, // There was more than
  61. // one requesting
  62. // thread.
  63. PROCESS_ERROR_NO_MEMORY_FOR_THREAD, // A thread had no
  64. // memory region.
  65. PROCESS_ERROR_NO_STACKWALKER_FOR_THREAD, // We couldn't
  66. // determine the
  67. // StackWalker to walk
  68. // the minidump's
  69. // threads.
  70. PROCESS_SYMBOL_SUPPLIER_INTERRUPTED // The minidump
  71. // processing was
  72. // interrupted by the
  73. // SymbolSupplier(not
  74. // fatal)
  75. };
  76. class MinidumpProcessor {
  77. public:
  78. // Initializes this MinidumpProcessor. supplier should be an
  79. // implementation of the SymbolSupplier abstract base class.
  80. MinidumpProcessor(SymbolSupplier *supplier,
  81. SourceLineResolverInterface *resolver);
  82. // Initializes the MinidumpProcessor with the option of
  83. // enabling the exploitability framework to analyze dumps
  84. // for probable security relevance.
  85. MinidumpProcessor(SymbolSupplier *supplier,
  86. SourceLineResolverInterface *resolver,
  87. bool enable_exploitability);
  88. ~MinidumpProcessor();
  89. // Processes the minidump file and fills process_state with the result.
  90. ProcessResult Process(const string &minidump_file,
  91. ProcessState *process_state);
  92. // Processes the minidump structure and fills process_state with the
  93. // result.
  94. ProcessResult Process(Minidump *minidump,
  95. ProcessState *process_state);
  96. // Populates the cpu_* fields of the |info| parameter with textual
  97. // representations of the CPU type that the minidump in |dump| was
  98. // produced on. Returns false if this information is not available in
  99. // the minidump.
  100. static bool GetCPUInfo(Minidump *dump, SystemInfo *info);
  101. // Populates the os_* fields of the |info| parameter with textual
  102. // representations of the operating system that the minidump in |dump|
  103. // was produced on. Returns false if this information is not available in
  104. // the minidump.
  105. static bool GetOSInfo(Minidump *dump, SystemInfo *info);
  106. // Returns a textual representation of the reason that a crash occurred,
  107. // if the minidump in dump was produced as a result of a crash. Returns
  108. // an empty string if this information cannot be determined. If address
  109. // is non-NULL, it will be set to contain the address that caused the
  110. // exception, if this information is available. This will be a code
  111. // address when the crash was caused by problems such as illegal
  112. // instructions or divisions by zero, or a data address when the crash
  113. // was caused by a memory access violation.
  114. static string GetCrashReason(Minidump *dump, u_int64_t *address);
  115. // This function returns true if the passed-in error code is
  116. // something unrecoverable(i.e. retry should not happen). For
  117. // instance, if the minidump is corrupt, then it makes no sense to
  118. // retry as we won't be able to glean additional information.
  119. // However, as an example of the other case, the symbol supplier can
  120. // return an error code indicating it was 'interrupted', which can
  121. // happen of the symbols are fetched from a remote store, and a
  122. // retry might be successful later on.
  123. // You should not call this method with PROCESS_OK! Test for
  124. // that separately before calling this.
  125. static bool IsErrorUnrecoverable(ProcessResult p) {
  126. assert(p != PROCESS_OK);
  127. return (p != PROCESS_SYMBOL_SUPPLIER_INTERRUPTED);
  128. }
  129. // Returns a textual representation of an assertion included
  130. // in the minidump. Returns an empty string if this information
  131. // does not exist or cannot be determined.
  132. static string GetAssertion(Minidump *dump);
  133. private:
  134. SymbolSupplier *supplier_;
  135. SourceLineResolverInterface *resolver_;
  136. // This flag enables the exploitability scanner which attempts to
  137. // guess how likely it is that the crash represents an exploitable
  138. // memory corruption issue.
  139. bool enable_exploitability_;
  140. };
  141. } // namespace google_breakpad
  142. #endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_PROCESSOR_H__