mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
linux: Add CrashWithoutDump()
When a renderer crashes in Multi-process WebView, the browser process may need to crash itself to maintain equivalent behavior with single process WebView. This allows it to do so without generating a dump of the browser process, which would provide no useful information. Change-Id: I272d6322269bd0ba8753b5b3959a613877eaf867 Reviewed-on: https://chromium-review.googlesource.com/c/1258082 Commit-Queue: Joshua Peraza <jperaza@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
39d73623dd
commit
91781418bc
@ -266,6 +266,12 @@ class CrashpadClient {
|
||||
//! CaptureContext() or similar.
|
||||
static void DumpWithoutCrash(NativeCPUContext* context);
|
||||
|
||||
//! \brief Disables any installed crash handler, including any
|
||||
//! FirstChanceHandler and crashes the current process.
|
||||
//!
|
||||
//! \param[in] message A message to be logged before crashing.
|
||||
static void CrashWithoutDump(const std::string& message);
|
||||
|
||||
//! \brief The type for custom handlers installed by clients.
|
||||
using FirstChanceHandler = bool (*)(int, siginfo_t*, ucontext_t*);
|
||||
|
||||
|
@ -78,28 +78,8 @@ std::vector<std::string> BuildAppProcessArgs(
|
||||
|
||||
#endif // OS_ANDROID
|
||||
|
||||
class SignalHandler {
|
||||
public:
|
||||
virtual void HandleCrashFatal(int signo,
|
||||
siginfo_t* siginfo,
|
||||
void* context) = 0;
|
||||
virtual bool HandleCrashNonFatal(int signo,
|
||||
siginfo_t* siginfo,
|
||||
void* context) = 0;
|
||||
|
||||
void SetFirstChanceHandler(CrashpadClient::FirstChanceHandler handler) {
|
||||
first_chance_handler_ = handler;
|
||||
}
|
||||
|
||||
protected:
|
||||
SignalHandler() = default;
|
||||
~SignalHandler() = default;
|
||||
|
||||
CrashpadClient::FirstChanceHandler first_chance_handler_ = nullptr;
|
||||
};
|
||||
|
||||
// Launches a single use handler to snapshot this process.
|
||||
class LaunchAtCrashHandler : public SignalHandler {
|
||||
class LaunchAtCrashHandler {
|
||||
public:
|
||||
static LaunchAtCrashHandler* Get() {
|
||||
static LaunchAtCrashHandler* instance = new LaunchAtCrashHandler();
|
||||
@ -123,9 +103,7 @@ class LaunchAtCrashHandler : public SignalHandler {
|
||||
return Signals::InstallCrashHandlers(HandleCrash, 0, nullptr);
|
||||
}
|
||||
|
||||
bool HandleCrashNonFatal(int signo,
|
||||
siginfo_t* siginfo,
|
||||
void* context) override {
|
||||
bool HandleCrashNonFatal(int signo, siginfo_t* siginfo, void* context) {
|
||||
if (first_chance_handler_ &&
|
||||
first_chance_handler_(
|
||||
signo, siginfo, static_cast<ucontext_t*>(context))) {
|
||||
@ -162,13 +140,19 @@ class LaunchAtCrashHandler : public SignalHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
void HandleCrashFatal(int signo, siginfo_t* siginfo, void* context) override {
|
||||
if (HandleCrashNonFatal(signo, siginfo, context)) {
|
||||
void HandleCrashFatal(int signo, siginfo_t* siginfo, void* context) {
|
||||
if (enabled_ && HandleCrashNonFatal(signo, siginfo, context)) {
|
||||
return;
|
||||
}
|
||||
Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, nullptr);
|
||||
}
|
||||
|
||||
void SetFirstChanceHandler(CrashpadClient::FirstChanceHandler handler) {
|
||||
first_chance_handler_ = handler;
|
||||
}
|
||||
|
||||
static void Disable() { enabled_ = false; }
|
||||
|
||||
private:
|
||||
LaunchAtCrashHandler() = default;
|
||||
|
||||
@ -183,16 +167,20 @@ class LaunchAtCrashHandler : public SignalHandler {
|
||||
std::vector<const char*> argv_;
|
||||
std::vector<std::string> envp_strings_;
|
||||
std::vector<const char*> envp_;
|
||||
bool set_envp_ = false;
|
||||
ExceptionInformation exception_information_;
|
||||
CrashpadClient::FirstChanceHandler first_chance_handler_ = nullptr;
|
||||
bool set_envp_ = false;
|
||||
|
||||
static thread_local bool enabled_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(LaunchAtCrashHandler);
|
||||
};
|
||||
thread_local bool LaunchAtCrashHandler::enabled_ = true;
|
||||
|
||||
// A pointer to the currently installed crash signal handler. This allows
|
||||
// the static method CrashpadClient::DumpWithoutCrashing to simulate a crash
|
||||
// using the currently configured crash handling strategy.
|
||||
static SignalHandler* g_crash_handler;
|
||||
static LaunchAtCrashHandler* g_crash_handler;
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -318,6 +306,12 @@ void CrashpadClient::DumpWithoutCrash(NativeCPUContext* context) {
|
||||
siginfo.si_signo, &siginfo, reinterpret_cast<void*>(context));
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashpadClient::CrashWithoutDump(const std::string& message) {
|
||||
LaunchAtCrashHandler::Disable();
|
||||
LOG(FATAL) << message;
|
||||
}
|
||||
|
||||
// static
|
||||
void CrashpadClient::SetFirstChanceExceptionHandler(
|
||||
FirstChanceHandler handler) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user