blob: 21c3fd3834fba2eb497a03c157979161553c5808 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include <fuchsia/exception/internal/cpp/fidl.h>
#include <lib/async/dispatcher.h>
#include <lib/fit/function.h>
#include <lib/zx/channel.h>
#include <lib/zx/exception.h>
#include <lib/zx/process.h>
#include <lib/zx/thread.h>
namespace forensics {
namespace exceptions {
// Handles a pending exception by handing it off to a subprocess. The lifetime of the subprocess
// is automatically managed and it is replaced if it crashes.
class ProcessHandler {
using LogMonikerFn = fit::function<void(const std::string&)>;
ProcessHandler(async_dispatcher_t* dispatcher, LogMonikerFn log_moniker,
fit::closure on_available);
ProcessHandler(ProcessHandler&&) = default;
ProcessHandler& operator=(ProcessHandler&&) = default;
void Handle(zx::exception exception, zx::process process, zx::thread thread);
async_dispatcher_t* dispatcher_;
LogMonikerFn log_moniker_;
fit::closure on_available_;
zx::process subprocess_;
fuchsia::exception::internal::CrashReporterPtr crash_reporter_;
} // namespace exceptions
} // namespace forensics