mirror of
https://github.com/chromium/crashpad.git
synced 2025-01-17 12:58:16 +08:00
9554a89ab6
zx_task_resume() is deprecated for exception resumption, and replaced by zx_task_resume_from_exception(). The latter requires an additional argument, so plumb the exception port on which the exception was delivered through to where it needs to be resumed. Bug: fuchsia:ZX-2720 Change-Id: If3984ce13eb1735d061faaac9eecd42e0251d25f Reviewed-on: https://chromium-review.googlesource.com/c/1263017 Reviewed-by: Joshua Peraza <jperaza@chromium.org> Reviewed-by: Francois Rousseau <frousseau@google.com>
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
// Copyright 2017 The Crashpad Authors. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "handler/fuchsia/exception_handler_server.h"
|
|
|
|
#include <lib/zx/time.h>
|
|
#include <zircon/syscalls/port.h>
|
|
|
|
#include <utility>
|
|
|
|
#include "base/fuchsia/fuchsia_logging.h"
|
|
#include "base/logging.h"
|
|
#include "handler/fuchsia/crash_report_exception_handler.h"
|
|
#include "util/fuchsia/system_exception_port_key.h"
|
|
|
|
namespace crashpad {
|
|
|
|
ExceptionHandlerServer::ExceptionHandlerServer(zx::job root_job,
|
|
zx::port exception_port)
|
|
: root_job_(std::move(root_job)),
|
|
exception_port_(std::move(exception_port)) {}
|
|
|
|
ExceptionHandlerServer::~ExceptionHandlerServer() = default;
|
|
|
|
void ExceptionHandlerServer::Run(CrashReportExceptionHandler* handler) {
|
|
while (true) {
|
|
zx_port_packet_t packet;
|
|
zx_status_t status = exception_port_.wait(zx::time::infinite(), &packet);
|
|
if (status != ZX_OK) {
|
|
ZX_LOG(ERROR, status) << "zx_port_wait, aborting";
|
|
return;
|
|
}
|
|
|
|
if (packet.key != kSystemExceptionPortKey) {
|
|
LOG(ERROR) << "unexpected packet key, ignoring";
|
|
continue;
|
|
}
|
|
|
|
bool result = handler->HandleException(packet.exception.pid,
|
|
packet.exception.tid,
|
|
zx::unowned_port(exception_port_));
|
|
if (!result) {
|
|
LOG(ERROR) << "HandleException failed";
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace crashpad
|