#include "client/crashpad_client.h"
#include <dlfcn.h>
#include <setjmp.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include "base/check_op.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "client/annotation.h"
#include "client/annotation_list.h"
#include "client/crash_report_database.h"
#include "client/crashpad_info.h"
#include "client/simulate_crash.h"
#include "gtest/gtest.h"
#include "snapshot/annotation_snapshot.h"
#include "snapshot/minidump/process_snapshot_minidump.h"
#include "snapshot/sanitized/sanitization_information.h"
#include "test/errors.h"
#include "test/multiprocess.h"
#include "test/multiprocess_exec.h"
#include "test/scoped_temp_dir.h"
#include "test/test_paths.h"
#include "util/file/file_io.h"
#include "util/file/filesystem.h"
#include "util/linux/exception_handler_client.h"
#include "util/linux/exception_information.h"
#include "util/linux/socket.h"
#include "util/misc/address_sanitizer.h"
#include "util/misc/address_types.h"
#include "util/misc/from_pointer_cast.h"
#include "util/misc/memory_sanitizer.h"
#include "util/posix/scoped_mmap.h"
#include "util/posix/signals.h"
#include "util/thread/thread.h"
#if BUILDFLAG(IS_ANDROID)
#include <android/set_abort_message.h>
#include "dlfcn_internal.h"
extern "C" void android_set_abort_message(const char* msg)
__attribute__((weak));
#endif
namespace crashpad {
namespace test {
namespace {
enum class CrashType : uint32_t { … };
struct StartHandlerForSelfTestOptions { … };
class StartHandlerForSelfTest
: public testing::TestWithParam<
std::tuple<bool, bool, bool, bool, bool, bool, CrashType>> { … };
bool InstallHandler(CrashpadClient* client,
bool start_at_crash,
const base::FilePath& handler_path,
const base::FilePath& database_path,
const std::vector<base::FilePath>& attachments) { … }
constexpr char kTestAnnotationName[] = …;
constexpr char kTestAnnotationValue[] = …;
constexpr char kTestAttachmentName[] = …;
constexpr char kTestAttachmentContent[] = …;
#if BUILDFLAG(IS_ANDROID)
constexpr char kTestAbortMessage[] = "test abort message";
#endif
void ValidateAttachment(const CrashReportDatabase::UploadReport* report) { … }
void ValidateExtraMemory(const StartHandlerForSelfTestOptions& options,
const ProcessSnapshotMinidump& minidump) { … }
void ValidateDump(const StartHandlerForSelfTestOptions& options,
const CrashReportDatabase::UploadReport* report) { … }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winfinite-recursion"
#if defined(COMPILER_GCC)
__attribute__((noinline))
#endif
#if defined(__clang__)
__attribute__((optnone))
#endif
int RecurseInfinitely(int* ptr) { … }
#pragma clang diagnostic pop
sigjmp_buf do_crash_sigjmp_env;
bool HandleCrashSuccessfully(int, siginfo_t*, ucontext_t*) { … }
bool HandleCrashSuccessfullyAfterReporting(int, siginfo_t*, ucontext_t*) { … }
void DoCrash(const StartHandlerForSelfTestOptions& options,
CrashpadClient* client) { … }
class ScopedAltSignalStack { … };
class CrashThread : public Thread { … };
CRASHPAD_CHILD_TEST_MAIN(StartHandlerForSelfTestChild) { … }
class StartHandlerForSelfInChildTest : public MultiprocessExec { … };
TEST_P(StartHandlerForSelfTest, StartHandlerInChild) { … }
INSTANTIATE_TEST_SUITE_P(…);
class StartHandlerForClientTest { … };
class StartHandlerForChildTest : public Multiprocess { … };
TEST(CrashpadClient, StartHandlerForChild) { … }
TEST(CrashpadClient, SanitizedChild) { … }
}
}
}