PageRenderTime 60ms CodeModel.GetById 48ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

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