/thirdparty/breakpad/client/windows/crash_generation/client_info.h

http://github.com/tomahawk-player/tomahawk · C Header · 176 lines · 69 code · 34 blank · 73 comment · 0 complexity · 8076e777f50cc2147fafe902a9f3089e MD5 · raw file

  1. // Copyright (c) 2008, 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 CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__
  30. #define CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__
  31. #include <Windows.h>
  32. #include <DbgHelp.h>
  33. #include "client/windows/common/ipc_protocol.h"
  34. #include "google_breakpad/common/minidump_format.h"
  35. #include "processor/scoped_ptr.h"
  36. namespace google_breakpad {
  37. class CrashGenerationServer;
  38. // Abstraction for a crash client process.
  39. class ClientInfo {
  40. public:
  41. // Creates an instance with the given values. Gets the process
  42. // handle for the given process id and creates necessary event
  43. // objects.
  44. ClientInfo(CrashGenerationServer* crash_server,
  45. DWORD pid,
  46. MINIDUMP_TYPE dump_type,
  47. DWORD* thread_id,
  48. EXCEPTION_POINTERS** ex_info,
  49. MDRawAssertionInfo* assert_info,
  50. const CustomClientInfo& custom_client_info);
  51. ~ClientInfo();
  52. CrashGenerationServer* crash_server() const { return crash_server_; }
  53. DWORD pid() const { return pid_; }
  54. MINIDUMP_TYPE dump_type() const { return dump_type_; }
  55. EXCEPTION_POINTERS** ex_info() const { return ex_info_; }
  56. MDRawAssertionInfo* assert_info() const { return assert_info_; }
  57. DWORD* thread_id() const { return thread_id_; }
  58. HANDLE process_handle() const { return process_handle_; }
  59. HANDLE dump_requested_handle() const { return dump_requested_handle_; }
  60. HANDLE dump_generated_handle() const { return dump_generated_handle_; }
  61. DWORD crash_id() const { return crash_id_; }
  62. HANDLE dump_request_wait_handle() const {
  63. return dump_request_wait_handle_;
  64. }
  65. void set_dump_request_wait_handle(HANDLE value) {
  66. dump_request_wait_handle_ = value;
  67. }
  68. HANDLE process_exit_wait_handle() const {
  69. return process_exit_wait_handle_;
  70. }
  71. void set_process_exit_wait_handle(HANDLE value) {
  72. process_exit_wait_handle_ = value;
  73. }
  74. // Unregister all waits for the client.
  75. void UnregisterWaits();
  76. bool Initialize();
  77. bool GetClientExceptionInfo(EXCEPTION_POINTERS** ex_info) const;
  78. bool GetClientThreadId(DWORD* thread_id) const;
  79. // Reads the custom information from the client process address space.
  80. bool PopulateCustomInfo();
  81. // Returns the client custom information.
  82. CustomClientInfo GetCustomInfo() const;
  83. private:
  84. // Calcualtes the uptime for the client process, converts it to a string and
  85. // stores it in the last entry of client custom info.
  86. void SetProcessUptime();
  87. // Crash generation server.
  88. CrashGenerationServer* crash_server_;
  89. // Client process ID.
  90. DWORD pid_;
  91. // Dump type requested by the client.
  92. MINIDUMP_TYPE dump_type_;
  93. // Address of an EXCEPTION_POINTERS* variable in the client
  94. // process address space that will point to an instance of
  95. // EXCEPTION_POINTERS containing information about crash.
  96. //
  97. // WARNING: Do not dereference these pointers as they are pointers
  98. // in the address space of another process.
  99. EXCEPTION_POINTERS** ex_info_;
  100. // Address of an instance of MDRawAssertionInfo in the client
  101. // process address space that will contain information about
  102. // non-exception related crashes like invalid parameter assertion
  103. // failures and pure calls.
  104. //
  105. // WARNING: Do not dereference these pointers as they are pointers
  106. // in the address space of another process.
  107. MDRawAssertionInfo* assert_info_;
  108. // Custom information about the client.
  109. CustomClientInfo custom_client_info_;
  110. // Contains the custom client info entries read from the client process
  111. // memory. This will be populated only if the method GetClientCustomInfo
  112. // is called.
  113. scoped_array<CustomInfoEntry> custom_info_entries_;
  114. // Address of a variable in the client process address space that
  115. // will contain the thread id of the crashing client thread.
  116. //
  117. // WARNING: Do not dereference these pointers as they are pointers
  118. // in the address space of another process.
  119. DWORD* thread_id_;
  120. // Client process handle.
  121. HANDLE process_handle_;
  122. // Dump request event handle.
  123. HANDLE dump_requested_handle_;
  124. // Dump generated event handle.
  125. HANDLE dump_generated_handle_;
  126. // Wait handle for dump request event.
  127. HANDLE dump_request_wait_handle_;
  128. // Wait handle for process exit event.
  129. HANDLE process_exit_wait_handle_;
  130. // Time when the client process started. It is used to determine the uptime
  131. // for the client process when it signals a crash.
  132. FILETIME start_time_;
  133. // The crash id which can be used to request an upload. This will be the
  134. // value of the low order dword of the process creation time for the process
  135. // being dumped.
  136. DWORD crash_id_;
  137. // Disallow copy ctor and operator=.
  138. ClientInfo(const ClientInfo& client_info);
  139. ClientInfo& operator=(const ClientInfo& client_info);
  140. };
  141. } // namespace google_breakpad
  142. #endif // CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__