mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-08 21:26:04 +00:00
ios: Cleanup API for chromium integration.
Bug: crashpad: 31 Change-Id: I9149879b2f6886ea17ca828dd60d37eb187ba88e Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2665887 Commit-Queue: Justin Cohen <justincohen@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
ee563696c3
commit
2cb83e491e
@ -47,6 +47,7 @@ crashpad_static_library("client") {
|
||||
sources += [
|
||||
"crash_report_database_mac.mm",
|
||||
"crashpad_client_ios.cc",
|
||||
"simulate_crash_ios.h",
|
||||
]
|
||||
}
|
||||
|
||||
@ -90,7 +91,6 @@ crashpad_static_library("client") {
|
||||
|
||||
deps = [ "../third_party/mini_chromium:chromeos_buildflags" ]
|
||||
|
||||
|
||||
if (crashpad_is_win) {
|
||||
libs = [ "rpcrt4.lib" ]
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
|
@ -459,9 +459,13 @@ class CrashpadClient {
|
||||
//!
|
||||
//! This method is only defined on iOS.
|
||||
//!
|
||||
//! TODO(justincohen): This method will need to take database, metrics_dir,
|
||||
//! url and annotations eventually.
|
||||
void StartCrashpadInProcessHandler();
|
||||
//! \param[in] database The path to a Crashpad database.
|
||||
//! \param[in] url The URL of an upload server.
|
||||
//! \param[in] annotations Process annotations to set in each crash report.
|
||||
void StartCrashpadInProcessHandler(
|
||||
const base::FilePath& database,
|
||||
const std::string& url,
|
||||
const std::map<std::string, std::string>& annotations);
|
||||
|
||||
// TODO(justincohen): This method is purely for bringing up iOS interfaces.
|
||||
//! \brief Requests that the handler capture a dump even though there hasn't
|
||||
|
@ -210,7 +210,10 @@ CrashpadClient::CrashpadClient() {}
|
||||
|
||||
CrashpadClient::~CrashpadClient() {}
|
||||
|
||||
void CrashpadClient::StartCrashpadInProcessHandler() {
|
||||
void CrashpadClient::StartCrashpadInProcessHandler(
|
||||
const base::FilePath& database,
|
||||
const std::string& url,
|
||||
const std::map<std::string, std::string>& annotations) {
|
||||
InstallObjcExceptionPreprocessor();
|
||||
|
||||
CrashHandler* crash_handler = CrashHandler::Get();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/scoped_temp_dir.h"
|
||||
#include "testing/platform_test.h"
|
||||
|
||||
namespace crashpad {
|
||||
@ -29,8 +30,9 @@ using CrashpadIOSClient = PlatformTest;
|
||||
|
||||
TEST_F(CrashpadIOSClient, DumpWithoutCrash) {
|
||||
CrashpadClient client;
|
||||
client.StartCrashpadInProcessHandler();
|
||||
|
||||
ScopedTempDir database_dir;
|
||||
client.StartCrashpadInProcessHandler(
|
||||
base::FilePath(database_dir.path()), "", {});
|
||||
NativeCPUContext context;
|
||||
CaptureContext(&context);
|
||||
client.DumpWithoutCrash(&context);
|
||||
@ -42,7 +44,9 @@ TEST_F(CrashpadIOSClient, DumpWithoutCrash) {
|
||||
// during development only.
|
||||
TEST_F(CrashpadIOSClient, DISABLED_ThrowNSException) {
|
||||
CrashpadClient client;
|
||||
client.StartCrashpadInProcessHandler();
|
||||
ScopedTempDir database_dir;
|
||||
client.StartCrashpadInProcessHandler(
|
||||
base::FilePath(database_dir.path()), "", {});
|
||||
[NSException raise:@"GoogleTestNSException" format:@"ThrowException"];
|
||||
}
|
||||
|
||||
@ -52,7 +56,9 @@ TEST_F(CrashpadIOSClient, DISABLED_ThrowNSException) {
|
||||
// during development only.
|
||||
TEST_F(CrashpadIOSClient, DISABLED_ThrowException) {
|
||||
CrashpadClient client;
|
||||
client.StartCrashpadInProcessHandler();
|
||||
ScopedTempDir database_dir;
|
||||
client.StartCrashpadInProcessHandler(
|
||||
base::FilePath(database_dir.path()), "", {});
|
||||
std::vector<int> empty_vector;
|
||||
empty_vector.at(42);
|
||||
}
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_APPLE)
|
||||
#if defined(OS_MAC)
|
||||
#include "client/simulate_crash_mac.h"
|
||||
#elif defined(OS_IOS)
|
||||
#include "client/simulate_crash_ios.h"
|
||||
#elif defined(OS_WIN)
|
||||
#include "client/simulate_crash_win.h"
|
||||
#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
||||
|
31
client/simulate_crash_ios.h
Normal file
31
client/simulate_crash_ios.h
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2021 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.
|
||||
|
||||
#ifndef CRASHPAD_CLIENT_SIMULATE_CRASH_IOS_H_
|
||||
#define CRASHPAD_CLIENT_SIMULATE_CRASH_IOS_H_
|
||||
|
||||
#include "client/crashpad_client.h"
|
||||
#include "util/misc/capture_context.h"
|
||||
|
||||
//! \file
|
||||
|
||||
//! \brief Captures the CPU context and captures a dump without an exception.
|
||||
#define CRASHPAD_SIMULATE_CRASH() \
|
||||
do { \
|
||||
crashpad::NativeCPUContext cpu_context; \
|
||||
crashpad::CaptureContext(&cpu_context); \
|
||||
crashpad::CrashpadClient::DumpWithoutCrash(&cpu_context); \
|
||||
} while (false)
|
||||
|
||||
#endif // CRASHPAD_CLIENT_SIMULATE_CRASH_IOS_H_
|
@ -40,7 +40,7 @@
|
||||
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
|
||||
// Start up crashpad.
|
||||
crashpad::CrashpadClient client;
|
||||
client.StartCrashpadInProcessHandler();
|
||||
client.StartCrashpadInProcessHandler(base::FilePath(), "", {});
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
[self.window makeKeyAndVisible];
|
||||
|
Loading…
x
Reference in New Issue
Block a user