From 907f95c5bda4144de54778769b7d51814b32c82a Mon Sep 17 00:00:00 2001 From: "benchan@chromium.org" Date: Thu, 23 Feb 2012 18:50:08 +0000 Subject: Modify CrashGenerator::CreateChildCrash to copy proc files. This patch is taken from the downstream version of breakpad in Chromium OS: https://gerrit.chromium.org/gerrit/15148 LinuxCoreDumperTest previously assumes the proc files of the child process created by CrashGenerator::CreateChildCrash() have the same content as its parent process, which may not be true. This CL modifies CrashGenerator to copy the proc files of the child process, created by CreateChildCrash(), before crashing that process. BUG=chromium-os:25252 TEST=Verified the following: TEST=Tested the following: 1. Build on 32-bit and 64-bit Linux with gcc 4.4.3 and gcc 4.6. 2. Build on Mac OS X 10.6.8 with gcc 4.2 and clang 3.0 (with latest gmock). 3. All unit tests pass. Review URL: https://breakpad.appspot.com/353001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@925 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../minidump_writer/linux_core_dumper_unittest.cc | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/client/linux/minidump_writer') 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 e335413b..1fb26ede 100644 --- a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc @@ -63,7 +63,7 @@ TEST(LinuxCoreDumperTest, BuildProcPath) { TEST(LinuxCoreDumperTest, VerifyDumpWithMultipleThreads) { CrashGenerator crash_generator; if (!crash_generator.HasDefaultCorePattern()) { - fprintf(stderr, "LinuxCoreDumperTest.VerifyDumpWithMultipleThreads test" + fprintf(stderr, "LinuxCoreDumperTest.VerifyDumpWithMultipleThreads test " "is skipped due to non-default core pattern\n"); return; } @@ -76,23 +76,15 @@ TEST(LinuxCoreDumperTest, VerifyDumpWithMultipleThreads) { // CrashGenerator is identified and fixed. if (!crash_generator.CreateChildCrash(kNumOfThreads, kCrashThread, kCrashSignal, &child_pid)) { - fprintf(stderr, "LinuxCoreDumperTest.VerifyDumpWithMultipleThreads test" + fprintf(stderr, "LinuxCoreDumperTest.VerifyDumpWithMultipleThreads test " "is skipped due to no core dump generated\n"); return; } pid_t pid = getpid(); - const char* core_file = crash_generator.GetCoreFilePath().c_str(); - - // Since CrashGenerator::CreateChildCrash() simply crashed a fork of - // this process, we expect that those proc files, which are used by - // LinuxCoreDumper, of crashed child process have the same content of - // this process. So we simply pass the proc files of this process to - // LinuxCoreDumper. - char procfs_path[NAME_MAX]; - snprintf(procfs_path, NAME_MAX, "/proc/%d", pid); - - LinuxCoreDumper dumper(child_pid, core_file, procfs_path); + const string core_file = crash_generator.GetCoreFilePath(); + const string procfs_path = crash_generator.GetDirectoryOfProcFilesCopy(); + LinuxCoreDumper dumper(child_pid, core_file.c_str(), procfs_path.c_str()); dumper.Init(); EXPECT_TRUE(dumper.IsPostMortem()); -- cgit v1.2.1