Crashpad
Classes | Public Member Functions | List of all members
crashpad::UniversalMachExcServer Class Referencefinal

A server interface for the exc and mach_exc Mach subsystems, unified to handle exceptions delivered to either subsystem, and simplified to have only a single interface method needing implementation. More...

#include "util/mach/exc_server_variants.h"

Inheritance diagram for crashpad::UniversalMachExcServer:
crashpad::MachMessageServer::Interface

Classes

class  Interface
 An interface that the different request messages that are a part of the exc and mach_exc Mach subsystems can be dispatched to. More...
 

Public Member Functions

 UniversalMachExcServer (Interface *interface)
 Constructs an object of this class. More...
 
bool MachMessageServerFunction (const mach_msg_header_t *in_header, mach_msg_header_t *out_header, bool *destroy_complex_request) override
 Handles a Mach RPC request. More...
 
std::set< mach_msg_id_t > MachMessageServerRequestIDs () override
 
mach_msg_size_t MachMessageServerRequestSize () override
 
mach_msg_size_t MachMessageServerReplySize () override
 

Detailed Description

A server interface for the exc and mach_exc Mach subsystems, unified to handle exceptions delivered to either subsystem, and simplified to have only a single interface method needing implementation.

The <mach/exc.defs> and <mach/mach_exc.defs> interfaces are identical, except that the latter allows for 64-bit exception codes, and is requested by setting the MACH_EXCEPTION_CODES behavior bit associated with an exception port.

UniversalMachExcServer operates by translating messages received in the exc subsystem to a variant that is compatible with the mach_exc subsystem. This involves changing the format of code, the exception code field, from exception_data_type_t to mach_exception_data_type_t.

Constructor & Destructor Documentation

◆ UniversalMachExcServer()

crashpad::UniversalMachExcServer::UniversalMachExcServer ( UniversalMachExcServer::Interface interface)
explicit

Constructs an object of this class.

Parameters
[in]interfaceThe interface to dispatch requests to. Weak.

Member Function Documentation

◆ MachMessageServerFunction()

bool crashpad::UniversalMachExcServer::MachMessageServerFunction ( const mach_msg_header_t *  in,
mach_msg_header_t *  out,
bool *  destroy_complex_request 
)
overridevirtual

Handles a Mach RPC request.

This method is a stand-in for a MIG-generated Mach RPC server “demux” function such as exc_server() and mach_exc_server(). Implementations may call such a function directly. This method is expected to behave exactly as these functions behave.

Parameters
[in]inThe request message, received as a Mach message. Note that this interface uses a const parameter for this purpose, whereas MIG-generated “demux” functions do not.
[out]outThe reply message. The caller allocates storage, and the callee is expected to populate the reply message appropriately. After returning, the caller will send this reply as a Mach message via the message’s reply port.
[out]destroy_complex_requesttrue if a complex request message is to be destroyed even when handled successfully, false otherwise. The traditional behavior is false. In this case, the caller only destroys the request message in in when the reply message in out is not complex and when it indicates a return code other than KERN_SUCCESS or MIG_NO_REPLY. The assumption is that the rights or out-of-line data carried in a complex message may be retained by the server in this situation, and that it is the responsibility of the server to release these resources as needed. However, in many cases, these resources are not needed beyond the duration of a request-reply transaction, and in such cases, it is less error-prone to always have the caller, MachMessageServer::Run(), destroy complex request messages. To choose this behavior, this parameter should be set to true.
Returns
true on success and false on failure, although the caller ignores the return value. However, the return code to be included in the reply message should be set as mig_reply_error_t::RetCode. The non-void return value is used for increased compatibility with MIG-generated functions.

Implements crashpad::MachMessageServer::Interface.

◆ MachMessageServerReplySize()

mach_msg_size_t crashpad::UniversalMachExcServer::MachMessageServerReplySize ( )
overridevirtual
Returns
The maximum size, in bytes, of a reply message to be sent via the out parameter of MachMessageServerFunction(). This value does not need to include the size of any trailer to be sent with the message.

Implements crashpad::MachMessageServer::Interface.

◆ MachMessageServerRequestIDs()

std::set< mach_msg_id_t > crashpad::UniversalMachExcServer::MachMessageServerRequestIDs ( )
overridevirtual
Returns
The set of request message Mach message IDs that MachMessageServerFunction() is able to handle.

Implements crashpad::MachMessageServer::Interface.

◆ MachMessageServerRequestSize()

mach_msg_size_t crashpad::UniversalMachExcServer::MachMessageServerRequestSize ( )
overridevirtual
Returns
The expected or maximum size, in bytes, of a request message to be received as the in parameter of MachMessageServerFunction().

Implements crashpad::MachMessageServer::Interface.


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