mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:26:06 +00:00
First steps at bringing up the crashpad_client on iOS. Also updates the XCUITest to trigger various crashes, with some swizzling necessary to allow crashes. Change-Id: I87dd36bed1c052b509d14bfa29679ed81e58a377 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2039470 Commit-Queue: Justin Cohen <justincohen@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Rohit Rao <rohitrao@chromium.org>
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
// Copyright 2020 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 "client/crashpad_client.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "base/logging.h"
|
|
#include "base/strings/stringprintf.h"
|
|
#include "client/client_argv_handling.h"
|
|
#include "util/posix/signals.h"
|
|
|
|
namespace crashpad {
|
|
|
|
namespace {
|
|
|
|
// A base class for Crashpad signal handler implementations.
|
|
class SignalHandler {
|
|
public:
|
|
// Returns the currently installed signal hander.
|
|
static SignalHandler* Get() {
|
|
static SignalHandler* instance = new SignalHandler();
|
|
return instance;
|
|
}
|
|
|
|
bool Install(const std::set<int>* unhandled_signals) {
|
|
return Signals::InstallCrashHandlers(
|
|
HandleSignal, 0, &old_actions_, unhandled_signals);
|
|
}
|
|
|
|
private:
|
|
SignalHandler() = default;
|
|
|
|
// The base implementation for all signal handlers, suitable for calling
|
|
// directly to simulate signal delivery.
|
|
void HandleCrash(int signo, siginfo_t* siginfo, void* context) {
|
|
// Do Something.
|
|
|
|
// Always call system handler.
|
|
Signals::RestoreHandlerAndReraiseSignalOnReturn(
|
|
siginfo, old_actions_.ActionForSignal(signo));
|
|
}
|
|
|
|
// The signal handler installed at OS-level.
|
|
static void HandleSignal(int signo, siginfo_t* siginfo, void* context) {
|
|
Get()->HandleCrash(signo, siginfo, context);
|
|
}
|
|
|
|
Signals::OldActions old_actions_ = {};
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SignalHandler);
|
|
};
|
|
|
|
} // namespace
|
|
|
|
CrashpadClient::CrashpadClient() {}
|
|
|
|
CrashpadClient::~CrashpadClient() {}
|
|
|
|
bool CrashpadClient::StartCrashpadInProcessHandler() {
|
|
return SignalHandler::Get()->Install(nullptr);
|
|
}
|
|
|
|
} // namespace crashpad
|