#include "components/crash/core/app/crashpad.h"
#include <stddef.h>
#include <string.h>
#include <algorithm>
#include <map>
#include <optional>
#include <string_view>
#include <vector>
#include "base/auto_reset.h"
#include "base/base_paths.h"
#include "base/check.h"
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/crash/core/app/crash_reporter_client.h"
#include "components/crash/core/common/crash_key.h"
#include "third_party/crashpad/crashpad/client/annotation.h"
#include "third_party/crashpad/crashpad/client/annotation_list.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
#include "third_party/crashpad/crashpad/client/crashpad_info.h"
#include "third_party/crashpad/crashpad/client/settings.h"
#include "third_party/crashpad/crashpad/client/simulate_crash.h"
#if BUILDFLAG(IS_POSIX)
#include <unistd.h>
#endif
#if BUILDFLAG(IS_WIN)
#include "components/crash/core/app/crash_export_thunks.h"
#endif
namespace crash_reporter {
#if BUILDFLAG(IS_IOS)
crashpad::StringAnnotation<24>& PlatformStorage() {
static crashpad::StringAnnotation<24> platform("platform");
return platform;
}
#endif
namespace {
base::FilePath* g_database_path;
crashpad::CrashReportDatabase* g_database;
void InitializeDatabasePath(const base::FilePath& database_path) { … }
bool InitializeCrashpadImpl(bool initial_client,
const std::string& process_type,
const std::string& user_data_dir,
const base::FilePath& exe_path,
const std::vector<std::string>& initial_arguments,
bool embedded_handler) { … }
}
bool InitializeCrashpad(bool initial_client, const std::string& process_type) { … }
#if BUILDFLAG(IS_WIN)
bool InitializeCrashpadWithEmbeddedHandler(bool initial_client,
const std::string& process_type,
const std::string& user_data_dir,
const base::FilePath& exe_path) {
return InitializeCrashpadImpl(initial_client, process_type, user_data_dir,
exe_path, std::vector<std::string>(),
true);
}
bool InitializeCrashpadWithDllEmbeddedHandler(
bool initial_client,
const std::string& process_type,
const std::string& user_data_dir,
const base::FilePath& exe_path,
const std::vector<std::string>& initial_arguments) {
return InitializeCrashpadImpl(initial_client, process_type, user_data_dir,
exe_path, initial_arguments,
true);
}
#endif
namespace {
crashpad::CrashpadClient* crashpad_client = …;
}
crashpad::CrashpadClient& GetCrashpadClient() { … }
void DestroyCrashpadClient() { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void SetUploadConsent(bool consent) { … }
#endif
#if !BUILDFLAG(IS_ANDROID)
void DumpWithoutCrashing() { … }
#if BUILDFLAG(IS_IOS)
void DumpWithoutCrashAndDeferProcessing() {
CRASHPAD_SIMULATE_CRASH_AND_DEFER_PROCESSING();
}
void DumpWithoutCrashAndDeferProcessingAtPath(const base::FilePath& path) {
CRASHPAD_SIMULATE_CRASH_AND_DEFER_PROCESSING_AT_PATH(path);
}
void OverridePlatformValue(const std::string& platform_value) {
PlatformStorage().Set(platform_value);
}
#endif
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
void CrashWithoutDumping(const std::string& message) { … }
#endif
void GetReports(std::vector<Report>* reports) { … }
void RequestSingleCrashUpload(const std::string& local_id) { … }
std::optional<base::FilePath> GetCrashpadDatabasePath() { … }
void ClearReportsBetween(const base::Time& begin, const base::Time& end) { … }
void GetReportsImpl(std::vector<Report>* reports) { … }
void RequestSingleCrashUploadImpl(const std::string& local_id) { … }
base::FilePath::StringType::const_pointer GetCrashpadDatabasePathImpl() { … }
void ClearReportsBetweenImpl(time_t begin, time_t end) { … }
namespace internal {
crashpad::CrashReportDatabase* GetCrashReportDatabase() { … }
void SetCrashReportDatabaseForTesting(
crashpad::CrashReportDatabase* database,
base::FilePath* database_path) { … }
}
}