Crashpad
Public Member Functions | Static Public Member Functions | List of all members
crashpad::CrashpadClient Class Reference

The primary interface for an application to have Crashpad monitor it for crashes. More...

#include "client/crashpad_client.h"

Public Member Functions

bool StartHandler (const base::FilePath &handler, const base::FilePath &database, const std::string &url, const std::map< std::string, std::string > &annotations, const std::vector< std::string > &arguments)
 Starts a Crashpad handler process, performing any necessary handshake to configure it. More...
 
bool SetHandler (const std::string &ipc_port)
 Sets the IPC port of a presumably-running Crashpad handler process which was started with StartHandler() or by other compatible means and does an IPC message exchange to register this process with the handler. However, just like StartHandler(), crashes are not serviced until UseHandler() is called. More...
 
bool UseHandler ()
 Configures the process to direct its crashes to a Crashpad handler. More...
 

Static Public Member Functions

static void DumpWithoutCrash (const CONTEXT &context)
 Requests that the handler capture a dump even though there hasn't been a crash. More...
 
static void UseSystemDefaultHandler ()
 Configures the process to direct its crashes to the default handler for the operating system. More...
 

Detailed Description

The primary interface for an application to have Crashpad monitor it for crashes.

Member Function Documentation

void crashpad::CrashpadClient::DumpWithoutCrash ( const CONTEXT &  context)
static

Requests that the handler capture a dump even though there hasn't been a crash.

Parameters
[in]contextA CONTEXT, generally captured by CaptureContext() or similar.
bool crashpad::CrashpadClient::SetHandler ( const std::string &  ipc_port)

Sets the IPC port of a presumably-running Crashpad handler process which was started with StartHandler() or by other compatible means and does an IPC message exchange to register this process with the handler. However, just like StartHandler(), crashes are not serviced until UseHandler() is called.

The IPC port name (somehow) encodes enough information so that registration is done with a crash handler using the appropriate database and upload server.

Parameters
[in]ipc_portThe full name of the crash handler IPC port.
Returns
true on success and false on failure.
bool crashpad::CrashpadClient::StartHandler ( const base::FilePath &  handler,
const base::FilePath &  database,
const std::string &  url,
const std::map< std::string, std::string > &  annotations,
const std::vector< std::string > &  arguments 
)

Starts a Crashpad handler process, performing any necessary handshake to configure it.

This method does not actually direct any crashes to the Crashpad handler, because there may be alternative ways to use an existing Crashpad handler without having to start one. To begin directing crashes to the handler, started by this method, call UseHandler() after this method returns successfully.

On Mac OS X, this method starts a Crashpad handler and obtains a Mach send right corresponding to a receive right held by the handler process. The handler process runs an exception server on this port.

On Windows, SetHandler() is normally used instead since the handler is started by other means.

Parameters
[in]handlerThe path to a Crashpad handler executable.
[in]databaseThe path to a Crashpad database. The handler will be started with this path as its --database argument.
[in]urlThe URL of an upload server. The handler will be started with this URL as its --url argument.
[in]annotationsProcess annotations to set in each crash report. The handler will be started with an --annotation argument for each element in this map.
[in]argumentsAdditional arguments to pass to the Crashpad handler. Arguments passed in other parameters and arguments required to perform the handshake are the responsibility of this method, and must not be specified in this parameter.
Returns
true on success, false on failure with a message logged.
bool crashpad::CrashpadClient::UseHandler ( )

Configures the process to direct its crashes to a Crashpad handler.

The Crashpad handler must previously have been started by StartHandler() or configured by SetHandler().

On Mac OS X, this method sets the task’s exception port for EXC_CRASH, EXC_RESOURCE, and EXC_GUARD exceptions to the Mach send right obtained by StartHandler(). The handler will be installed with behavior EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES and thread state flavor MACHINE_THREAD_STATE. Exception ports are inherited, so a Crashpad handler chosen by UseHandler() will remain the handler for any child processes created after UseHandler() is called. Child processes do not need to call StartHandler() or UseHandler() or be aware of Crashpad in any way. The Crashpad handler will receive crashes from child processes that have inherited it as their exception handler even after the process that called StartHandler() exits.

On Windows, this method sets the unhandled exception handler to a local function that when reached will "signal and wait" for the crash handler process to create the dump.

Returns
true on success, false on failure with a message logged.
void crashpad::CrashpadClient::UseSystemDefaultHandler ( )
static

Configures the process to direct its crashes to the default handler for the operating system.

On OS X, this sets the task’s exception port as in UseHandler(), but the exception handler used is obtained from SystemCrashReporterHandler(). If the system’s crash reporter handler cannot be determined or set, the task’s exception ports for crash-type exceptions are cleared.

Use of this function is strongly discouraged.

Warning
After a call to this function, Crashpad will no longer monitor the process for crashes until a subsequent call to UseHandler().
Note
This is provided as a static function to allow it to be used in situations where a CrashpadClient object is not otherwise available. This may be useful when a child process inherits its parent’s Crashpad handler, but wants to sever this tie.

The documentation for this class was generated from the following files: