#include "components/crash/core/app/crashpad.h"
#include <pthread.h>
#include <sys/prctl.h>
#include <limits>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/linux_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/posix/global_descriptors.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "build/branding_buildflags.h"
#include "build/chromeos_buildflags.h"
#include "components/crash/core/app/crash_reporter_client.h"
#include "components/crash/core/app/crash_switches.h"
#include "content/public/common/content_descriptors.h"
#include "sandbox/linux/services/namespace_sandbox.h"
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
#include "third_party/crashpad/crashpad/client/crashpad_info.h"
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
#include <sys/types.h>
#include <unistd.h>
#include <utility>
#include "base/at_exit.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "third_party/cros_system_api/constants/crash_reporter.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/build_time.h"
#endif
namespace crash_reporter {
namespace {
bool (*g_first_chance_handler)(int, siginfo_t*, void*);
bool FirstChanceHandlerHelper(int signo,
siginfo_t* siginfo,
ucontext_t* context) { … }
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
base::FilePath GetCrashpadReadyFilename() {
pid_t pid = getpid();
base::FilePath path(crash_reporter::kCrashpadReadyDirectory);
return path.Append(base::NumberToString(pid));
}
void InformCrashReporterThatCrashpadIsReady() {
base::FilePath path = GetCrashpadReadyFilename();
base::File file(path, base::File::FLAG_CREATE | base::File::FLAG_WRITE);
if (!file.IsValid()) {
LOG(ERROR) << "Could not create " << path << ": "
<< base::File::ErrorToString(file.error_details());
}
base::AtExitManager::RegisterTask(base::BindOnce(&DeleteCrashpadIsReadyFile));
}
#endif
}
void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*)) { … }
bool GetHandlerSocket(int* fd, pid_t* pid) { … }
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
void DeleteCrashpadIsReadyFile() {
base::DeleteFile(GetCrashpadReadyFilename());
}
#endif
namespace internal {
bool PlatformCrashpadInitialization(
bool initial_client,
bool browser_process,
bool embedded_handler,
const std::string& user_data_dir,
const base::FilePath& exe_path,
const std::vector<std::string>& initial_arguments,
base::FilePath* database_path) { … }
}
}