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
This commit is contained in:
benchan@chromium.org
2012-02-23 18:50:08 +00:00
parent 7caf87236a
commit 907f95c5bd
5 changed files with 116 additions and 20 deletions

View File

@@ -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());