[fuchsia] add a non-resuming exception API

While switching over to the new channel-based exception APIs, we decided
it probably no longer makes sense for crashpad to resume from exception
itself, but instead let the caller do it.

The first step is adding these new non-resuming APIs, and once callers
have been switched over we will remove the existing port-based APIs.

Bug: fuchsia:ZX-4031
Test: runtests
Change-Id: I79a833479f4e5e57bce4baebc61e1b3f9faf70a4
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1597730
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Francois Rousseau <frousseau@google.com>
Commit-Queue: Francois Rousseau <frousseau@google.com>
This commit is contained in:
David Pursell 2019-05-06 15:18:50 -07:00 committed by Commit Bot
parent 02a3bf6e27
commit d221b7cada
2 changed files with 26 additions and 5 deletions

View File

@ -99,12 +99,15 @@ bool CrashReportExceptionHandler::HandleExceptionHandles(
const zx::thread& thread,
const zx::unowned_port& exception_port,
UUID* local_report_id) {
ScopedTaskSuspend suspend(process);
// Now that the thread has been successfully retrieved, it is possible to
// correctly call zx_task_resume_from_exception() to continue exception
// processing, even if something else during this function fails.
ScopedThreadResumeAfterException resume(thread, exception_port);
return HandleException(process, thread, local_report_id);
}
bool CrashReportExceptionHandler::HandleException(
const zx::process& process,
const zx::thread& thread,
UUID* local_report_id) {
ScopedTaskSuspend suspend(process);
ProcessSnapshotFuchsia process_snapshot;
if (!process_snapshot.Initialize(process)) {

View File

@ -84,6 +84,8 @@ class CrashReportExceptionHandler {
//! \param[out] local_report_id The unique identifier for the report created
//! in the local report database. Optional.
//! \return `true` on success, or `false` with an error logged.
//!
//! \deprecated Use the port-less version instead and have the caller resume.
bool HandleException(uint64_t process_id,
uint64_t thread_id,
const zx::unowned_port& exception_port,
@ -104,11 +106,27 @@ class CrashReportExceptionHandler {
//! \param[out] local_report_id The unique identifier for the report created
//! in the local report database. Optional.
//! \return `true` on success, or `false` with an error logged.
//!
//! \deprecated Use the port-less #HandleException instead.
bool HandleExceptionHandles(const zx::process& process,
const zx::thread& thread,
const zx::unowned_port& exception_port,
UUID* local_report_id = nullptr);
//! \brief Called when the exception handler server has caught an exception
//! and wants a crash dump to be taken.
//!
//! \param[in] process The handle to the process which sustained the
//! exception.
//! \param[in] thread The handle to the thread of \a process which sustained
//! the exception.
//! \param[out] local_report_id The unique identifier for the report created
//! in the local report database. Optional.
//! \return `true` on success, or `false` with an error logged.
bool HandleException(const zx::process& process,
const zx::thread& thread,
UUID* local_report_id = nullptr);
private:
CrashReportDatabase* database_; // weak
CrashReportUploadThread* upload_thread_; // weak