crashpad::ExceptionHandlerServer Class Reference

Runs the main exception-handling server in Crashpad's handler process. More...

`#include "util/win/exception_handler_server.h"`

## Classes

class | Delegate
struct | Event

## Public Member Functions

| ExceptionHandlerServer (base::ScopedZxHandle root_job, base::ScopedZxHandle exception_port)
| Constructs an ExceptionHandlerServer object. More...
void | Run (CrashReportExceptionHandler *handler)
| Runs the exception-handling server. More...
void | SetPtraceStrategyDecider (std::unique_ptr< PtraceStrategyDecider > decider)
| Sets the handler's PtraceStrategyDecider. More...
bool | InitializeWithClient (ScopedFileHandle sock)
| Initializes this object. More...
void | Run (Delegate *delegate)
| Runs the exception-handling server. More...
void | Stop ()
| Stops a running exception-handling server. More...
| ExceptionHandlerServer (base::mac::ScopedMachReceiveRight receive_port, bool launchd)
| Constructs an ExceptionHandlerServer object. More...
void | Run (UniversalMachExcServer::Interface *exception_interface)
| Runs the exception-handling server. More...
void | Stop ()
| Stops a running exception-handling server. More...
| ExceptionHandlerServer (bool persistent)
| Constructs the exception handling server. More...
void | SetPipeName (const std::wstring &pipe_name)
| Sets the pipe name to listen for client registrations on. More...
void | InitializeWithInheritedDataForInitialClient (const InitialClientData &initial_client_data, Delegate *delegate)
| Sets the pipe to listen for client registrations on, providing the first precreated instance. More...
void | Run (Delegate *delegate)
| Runs the exception-handling server. More...
void | Stop ()
| Stops the exception-handling server. Returns immediately. The object must not be destroyed until Run() returns.

## Static Public Attributes

static const size_t | kPipeInstances = 2
| The number of server-side pipe instances that the exception handler server creates to listen for connections from clients.

## Detailed Description

Runs the main exception-handling server in Crashpad's handler process.

Runs the main exception-handling server in Crashpad’s handler process.

## Constructor & Destructor Documentation

## ExceptionHandlerServer() [1/3]

crashpad::ExceptionHandlerServer::ExceptionHandlerServer | ( | base::ScopedZxHandle | root_job,
|  | base::ScopedZxHandle | exception_port
| ) |  |

Constructs an ExceptionHandlerServer object.

Parameters

  [in] | root_job | The root of the tree of processes that will be handled by this server. It is assumed that exception_port is the exception port of this job.
  [in] | exception_port | The exception port that this server will monitor.

## ExceptionHandlerServer() [2/3]

crashpad::ExceptionHandlerServer::ExceptionHandlerServer | ( | base::mac::ScopedMachReceiveRight | receive_port,
|  | bool | launchd
| ) |  |

Constructs an ExceptionHandlerServer object.

Parameters

  [in] | receive_port | The port that exception messages and no-senders notifications will be received on.
  [in] | launchd | If `true`, the exception handler is being run from launchd. receive_port is not monitored for no-senders notifications, and instead, Stop() must be called to provide a “quit” signal.

## ExceptionHandlerServer() [3/3]

crashpad::ExceptionHandlerServer::ExceptionHandlerServer | ( | bool | persistent | ) |

explicit

Constructs the exception handling server.

Parameters

  [in] | persistent | `true` if Run() should not return until Stop() is called. If `false`, Run() will return when all clients have exited, although Run() will always wait for the first client to connect.

## Member Function Documentation

## InitializeWithClient()

bool crashpad::ExceptionHandlerServer::InitializeWithClient | ( | ScopedFileHandle | sock | ) |

Initializes this object.

This method must be successfully called before Run().

Parameters

  [in] | sock | A socket on which to receive client requests.

Returns
  `true` on success. `false` on failure with a message logged.

## InitializeWithInheritedDataForInitialClient()

void crashpad::ExceptionHandlerServer::InitializeWithInheritedDataForInitialClient | ( | const InitialClientData & | initial_client_data,
|  | Delegate * | delegate
| ) |  |

Sets the pipe to listen for client registrations on, providing the first precreated instance.

This method, or SetPipeName(), must be called before Run(). All of these parameters are generally created in a parent process that launches the handler. For more details see the Windows implementation of CrashpadClient.

See also
  CrashpadClient
  RegistrationRequest

Parameters

  [in] | initial_client_data | The handles and addresses of data inherited from a parent process needed to initialize and register the first client. Ownership of these handles is taken.
  [in] | delegate | The interface to which the exceptions are delegated when they are caught in Run(). Ownership is not transferred.

## Run() [1/4]

void crashpad::ExceptionHandlerServer::Run | ( | CrashReportExceptionHandler * | handler | ) |

Runs the exception-handling server.

Parameters

  [in] | handler | The handler to which the exceptions are delegated when they are caught in Run(). Ownership is not transferred.

## Run() [2/4]

void crashpad::ExceptionHandlerServer::Run | ( | UniversalMachExcServer::Interface * | exception_interface | ) |

Runs the exception-handling server.

Parameters

  [in] | exception_interface | An object to send exception messages to.

This method monitors the receive port for exception messages and, if not being run by launchd, no-senders notifications. It continues running until it has no more clients, indicated by the receipt of a no-senders notification, or until Stop() is called. When not being run by launchd, it is important to assure that a send right exists in a client (or has been queued by `mach_msg()` to be sent to a client) prior to calling this method, or it will detect that it is sender-less and return immediately.

All exception messages will be passed to exception_interface.

This method must only be called once on an ExceptionHandlerServer object.

If an unexpected condition that prevents this method from functioning is encountered, it will log a message and terminate execution. Receipt of an invalid message on the receive port will cause a message to be logged, but this method will continue running normally.

## Run() [3/4]

void crashpad::ExceptionHandlerServer::Run | ( | Delegate * | delegate | ) |

Runs the exception-handling server.

Parameters

  [in] | delegate | The interface to which the exceptions are delegated when they are caught in Run(). Ownership is not transferred.

## Run() [4/4]

void crashpad::ExceptionHandlerServer::Run | ( | Delegate * | delegate | ) |

Runs the exception-handling server.

This method must only be called once on an ExceptionHandlerServer object. This method returns when there are no more client connections or Stop() has been called.

Parameters

  [in] | delegate | An object to send exceptions to.

## SetPipeName()

void crashpad::ExceptionHandlerServer::SetPipeName | ( | const std::wstring & | pipe_name | ) |

Sets the pipe name to listen for client registrations on.

This method, or InitializeWithInheritedDataForInitialClient(), must be called before Run().

Parameters

  [in] | pipe_name | The name of the pipe to listen on. Must be of the form "\\.\pipe\<some_name>".

## SetPtraceStrategyDecider()

void crashpad::ExceptionHandlerServer::SetPtraceStrategyDecider | ( | std::unique_ptr< PtraceStrategyDecider > | decider | ) |

Sets the handler's PtraceStrategyDecider.

If this method is not called, a default PtraceStrategyDecider will be used.

## Stop() [1/2]

void crashpad::ExceptionHandlerServer::Stop | ( |  | ) |

Stops a running exception-handling server.

Stop() may be called at any time, and may be called from a signal handler. If Stop() is called before Run() it will cause Run() to return as soon as it is called. It is harmless to call Stop() after Run() has already returned, or to call Stop() after it has already been called.

## Stop() [2/2]

void crashpad::ExceptionHandlerServer::Stop | ( |  | ) |

Stops a running exception-handling server.

Stop() may be called at any time, and may be called from a signal handler. If Stop() is called before Run() it will cause Run() to return as soon as it is called. It is harmless to call Stop() after Run() has already returned, or to call Stop() after it has already been called.

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

- handler/fuchsia/exception_handler_server.h
- handler/fuchsia/exception_handler_server.cc