diff options
author | Mike Frysinger <vapier@chromium.org> | 2019-03-02 02:37:25 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@chromium.org> | 2019-03-12 05:02:27 +0000 |
commit | 3ee9a0b27438910a8fcbc263fc0df8b901a78d71 (patch) | |
tree | 9c46c2ac14481fc7e932d58eb7c67aa11343530b /src/client/linux/minidump_writer/linux_core_dumper_unittest.cc | |
parent | linux_core_dumper: add a fallback definition for NT_SIGINFO (diff) | |
download | breakpad-3ee9a0b27438910a8fcbc263fc0df8b901a78d71.tar.xz |
linux_core_dumper: support setting exception_information
Many signals in Linux support additional metadata on a per-signal
basis. We can extract that from NT_SIGINFO and pass it through
in the exception_information fields.
The current core dumper logic doesn't set exception_information
at all, so this is an improvement.
Bug: google-breakpad:791
Change-Id: I38b78d6494e9bc682441750d98ac9be5b0656f5a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1497662
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/client/linux/minidump_writer/linux_core_dumper_unittest.cc')
-rw-r--r-- | src/client/linux/minidump_writer/linux_core_dumper_unittest.cc | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc index f5b299f8..927d5aa3 100644 --- a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc @@ -109,7 +109,7 @@ TEST(LinuxCoreDumperTest, VerifyDumpWithMultipleThreads) { EXPECT_TRUE(dumper.ThreadsSuspend()); EXPECT_TRUE(dumper.ThreadsResume()); - // LinuxCoreDumper cannot determine the crash address and thus it always + // Linux does not set the crash address with SIGABRT, so make sure it always // sets the crash address to 0. EXPECT_EQ(0U, dumper.crash_address()); EXPECT_EQ(kCrashSignal, dumper.crash_signal()); @@ -126,3 +126,48 @@ TEST(LinuxCoreDumperTest, VerifyDumpWithMultipleThreads) { EXPECT_EQ(getpid(), info.ppid); } } + +TEST(LinuxCoreDumperTest, VerifyExceptionDetails) { + CrashGenerator crash_generator; + if (!crash_generator.HasDefaultCorePattern()) { + fprintf(stderr, "LinuxCoreDumperTest.VerifyDumpWithMultipleThreads test " + "is skipped due to non-default core pattern\n"); + return; + } + + const unsigned kNumOfThreads = 2; + const unsigned kCrashThread = 1; + const int kCrashSignal = SIGSYS; + pid_t child_pid; + ASSERT_TRUE(crash_generator.CreateChildCrash(kNumOfThreads, kCrashThread, + kCrashSignal, &child_pid)); + + const string core_file = crash_generator.GetCoreFilePath(); + const string procfs_path = crash_generator.GetDirectoryOfProcFilesCopy(); + +#if defined(__ANDROID__) + struct stat st; + if (stat(core_file.c_str(), &st) != 0) { + fprintf(stderr, "LinuxCoreDumperTest.VerifyExceptionDetails test is " + "skipped due to no core file being generated"); + return; + } +#endif + + LinuxCoreDumper dumper(child_pid, core_file.c_str(), procfs_path.c_str()); + + EXPECT_TRUE(dumper.Init()); + + EXPECT_TRUE(dumper.IsPostMortem()); + + // Check the exception details. + EXPECT_NE(0U, dumper.crash_address()); + EXPECT_EQ(kCrashSignal, dumper.crash_signal()); + EXPECT_EQ(crash_generator.GetThreadId(kCrashThread), + dumper.crash_thread()); + + // We check the length, but not the actual fields. We sent SIGSYS ourselves + // instead of the kernel, so the extended fields are garbage. + const std::vector<uint64_t> info(dumper.crash_exception_info()); + EXPECT_EQ(2U, info.size()); +} |