Manage intermediate minidump generation, and own the crash report upload thread and database. More...
#include "client/ios_handler/in_process_handler.h"
Public Types | |
using | ProcessPendingReportsObservationCallback = std::function<void()> |
Observation callback invoked each time this object finishes processing and attempting to upload on-disk crash reports (whether or not the uploads succeeded). | |
Public Member Functions | |
InProcessHandler (const InProcessHandler &)=delete | |
InProcessHandler & | operator= (const InProcessHandler &)=delete |
bool | Initialize (const base::FilePath &database, const std::string &url, const std::map< std::string, std::string > &annotations, ProcessPendingReportsObservationCallback callback=ProcessPendingReportsObservationCallback()) |
Initializes the in-process handler. | |
void | DumpExceptionFromSignal (siginfo_t *siginfo, ucontext_t *context) |
Generate an intermediate dump from a signal handler exception. Writes the dump with the cached writer does not allow concurrent exceptions to be written. It is expected the system will terminate the application after this call. | |
void | DumpExceptionFromMachException (exception_behavior_t behavior, thread_t thread, exception_type_t exception, const mach_exception_data_type_t *code, mach_msg_type_number_t code_count, thread_state_flavor_t flavor, ConstThreadState old_state, mach_msg_type_number_t old_state_count) |
Generate an intermediate dump from a mach exception. Writes the dump with the cached writer does not allow concurrent exceptions to be written. It is expected the system will terminate the application after this call. | |
void | DumpExceptionFromNSExceptionWithFrames (const uint64_t *frames, const size_t num_frames) |
Generate an intermediate dump from an uncaught NSException. | |
bool | DumpExceptionFromSimulatedMachException (const NativeCPUContext *context, exception_type_t exception, base::FilePath *path) |
Generate a simulated intermediate dump similar to a Mach exception in the same base directory as other exceptions. Does not use the cached writer. | |
bool | DumpExceptionFromSimulatedMachExceptionAtPath (const NativeCPUContext *context, exception_type_t exception, const base::FilePath &path) |
Generate a simulated intermediate dump similar to a Mach exception at a specific path. Does not use the cached writer. | |
bool | MoveIntermediateDumpAtPathToPending (const base::FilePath &path) |
Moves an intermediate dump to the pending directory. This is meant to be used by the UncaughtExceptionHandler, when NSException caught by the preprocessor matches the UncaughtExceptionHandler. | |
void | ProcessIntermediateDumps (const std::map< std::string, std::string > &annotations) |
Requests that the handler convert all intermediate dumps into minidumps and trigger an upload if possible. | |
void | ProcessIntermediateDump (const base::FilePath &path, const std::map< std::string, std::string > &annotations={}) |
Requests that the handler convert a specific intermediate dump into a minidump and trigger an upload if possible. | |
void | StartProcessingPendingReports (UploadBehavior upload_behavior=UploadBehavior::kUploadWhenAppIsActive) |
Requests that the handler begin in-process uploading of any pending reports. | |
void | SetMachExceptionCallbackForTesting (void(*callback)()) |
Inject a callback into Mach handling. Intended to be used by tests to trigger a reentrant exception. | |
Manage intermediate minidump generation, and own the crash report upload thread and database.
using crashpad::internal::InProcessHandler::ProcessPendingReportsObservationCallback = std::function<void()> |
Observation callback invoked each time this object finishes processing and attempting to upload on-disk crash reports (whether or not the uploads succeeded).
This callback is copied into this object. Any references or pointers inside must outlive this object.
The callback might be invoked on a background thread, so clients must synchronize appropriately.
void crashpad::internal::InProcessHandler::DumpExceptionFromMachException | ( | exception_behavior_t | behavior, |
thread_t | thread, | ||
exception_type_t | exception, | ||
const mach_exception_data_type_t * | code, | ||
mach_msg_type_number_t | code_count, | ||
thread_state_flavor_t | flavor, | ||
ConstThreadState | old_state, | ||
mach_msg_type_number_t | old_state_count ) |
Generate an intermediate dump from a mach exception. Writes the dump with the cached writer does not allow concurrent exceptions to be written. It is expected the system will terminate the application after this call.
[in] | behavior | |
[in] | thread | |
[in] | exception | |
[in] | code | |
[in] | code_count | |
[in,out] | flavor | |
[in] | old_state | |
[in] | old_state_count |
void crashpad::internal::InProcessHandler::DumpExceptionFromNSExceptionWithFrames | ( | const uint64_t * | frames, |
const size_t | num_frames ) |
Generate an intermediate dump from an uncaught NSException.
When the ObjcExceptionPreprocessor does not detect an NSException as it is thrown, the last-chance uncaught exception handler passes a list of call stack frame addresses. Record them in the intermediate dump so a minidump with a 'fake' call stack is generated. Writes the dump with the cached writer does not allow concurrent exceptions to be written. It is expected the system will terminate the application after this call.
[in] | frames | An array of call stack frame addresses. |
[in] | num_frames | The number of frames in |frames|. |
void crashpad::internal::InProcessHandler::DumpExceptionFromSignal | ( | siginfo_t * | siginfo, |
ucontext_t * | context ) |
Generate an intermediate dump from a signal handler exception. Writes the dump with the cached writer does not allow concurrent exceptions to be written. It is expected the system will terminate the application after this call.
[in] | siginfo | A pointer to a siginfo_t object received by a signal handler. |
[in] | context | A pointer to a ucontext_t object received by a signal. |
bool crashpad::internal::InProcessHandler::DumpExceptionFromSimulatedMachException | ( | const NativeCPUContext * | context, |
exception_type_t | exception, | ||
base::FilePath * | path ) |
Generate a simulated intermediate dump similar to a Mach exception in the same base directory as other exceptions. Does not use the cached writer.
[in] | context | A pointer to a NativeCPUContext object for this simulated exception. |
[in] | exception | |
[out] | path | The path of the intermediate dump generated. |
true
if the pending intermediate dump could be written. bool crashpad::internal::InProcessHandler::DumpExceptionFromSimulatedMachExceptionAtPath | ( | const NativeCPUContext * | context, |
exception_type_t | exception, | ||
const base::FilePath & | path ) |
Generate a simulated intermediate dump similar to a Mach exception at a specific path. Does not use the cached writer.
[in] | context | A pointer to a NativeCPUContext object for this simulated exception. |
[in] | exception | |
[in] | path | Path to where the intermediate dump should be written. |
true
if the pending intermediate dump could be written. bool crashpad::internal::InProcessHandler::Initialize | ( | const base::FilePath & | database, |
const std::string & | url, | ||
const std::map< std::string, std::string > & | annotations, | ||
ProcessPendingReportsObservationCallback | callback = ProcessPendingReportsObservationCallback() ) |
Initializes the in-process handler.
This method must be called only once, and must be successfully called before any other method in this class may be called.
[in] | database | The path to a Crashpad database. |
[in] | url | The URL of an upload server. |
[in] | annotations | Process annotations to set in each crash report. |
[in] | callback | Optional callback invoked zero or more times on a background thread each time this object finishes processing and attempting to upload on-disk crash reports. |
true
if a handler to a pending intermediate dump could be opened. bool crashpad::internal::InProcessHandler::MoveIntermediateDumpAtPathToPending | ( | const base::FilePath & | path | ) |
Moves an intermediate dump to the pending directory. This is meant to be used by the UncaughtExceptionHandler, when NSException caught by the preprocessor matches the UncaughtExceptionHandler.
[in] | path | Path to the specific intermediate dump. |
void crashpad::internal::InProcessHandler::ProcessIntermediateDump | ( | const base::FilePath & | path, |
const std::map< std::string, std::string > & | annotations = {} ) |
Requests that the handler convert a specific intermediate dump into a minidump and trigger an upload if possible.
[in] | path | Path to the specific intermediate dump. |
[in] | annotations | Process annotations to set in each crash report. |
void crashpad::internal::InProcessHandler::ProcessIntermediateDumps | ( | const std::map< std::string, std::string > & | annotations | ) |
Requests that the handler convert all intermediate dumps into minidumps and trigger an upload if possible.
[in] | annotations | Process annotations to set in each crash report. |
void crashpad::internal::InProcessHandler::StartProcessingPendingReports | ( | UploadBehavior | upload_behavior = UploadBehavior::kUploadWhenAppIsActive | ) |
Requests that the handler begin in-process uploading of any pending reports.
[in] | upload_behavior | Controls when the upload thread will run and process pending reports. By default, only uploads pending reports when the application is active. |