diff options
author | rmcilroy@chromium.org <rmcilroy@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2014-07-22 11:34:11 +0000 |
---|---|---|
committer | rmcilroy@chromium.org <rmcilroy@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2014-07-22 11:34:11 +0000 |
commit | 561f81873562d407ac1c39144b30e26163e0045d (patch) | |
tree | 7f2c072ddac47a40a34e46a36784dfcdd4fc411e /src/common/linux/memory_mapped_file_unittest.cc | |
parent | Both std::tr1::unordered_set and std::unordered_set are not allowed in (diff) | |
download | breakpad-561f81873562d407ac1c39144b30e26163e0045d.tar.xz |
Chrome on Android now supports loading the shared library directly from the APK file.
This patch makes two changes to breakpad to enable crash reporting to work correctly when the library is inside another file (an archive):
- Do not filter mappings which map an executable at a non-zero offset.
- If such an executable is mapped look in the ELF information for the
shared object name and use that name in the minidump.
Note this change doesn't care about the archive format and isn't Android
specific (though loading the shared library this way is currently only done on Android).
BUG=390618
R=thestig@chromium.org
Review URL: https://breakpad.appspot.com/7684002
Patch from Anton Carver <anton@chromium.org>.
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1355 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/linux/memory_mapped_file_unittest.cc')
-rw-r--r-- | src/common/linux/memory_mapped_file_unittest.cc | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/src/common/linux/memory_mapped_file_unittest.cc b/src/common/linux/memory_mapped_file_unittest.cc index 4fa50cf9..fad59f40 100644 --- a/src/common/linux/memory_mapped_file_unittest.cc +++ b/src/common/linux/memory_mapped_file_unittest.cc @@ -71,12 +71,12 @@ TEST_F(MemoryMappedFileTest, UnmapWithoutMap) { TEST_F(MemoryMappedFileTest, MapNonexistentFile) { { - MemoryMappedFile mapped_file("nonexistent-file"); + MemoryMappedFile mapped_file("nonexistent-file", 0); ExpectNoMappedData(mapped_file); } { MemoryMappedFile mapped_file; - EXPECT_FALSE(mapped_file.Map("nonexistent-file")); + EXPECT_FALSE(mapped_file.Map("nonexistent-file", 0)); ExpectNoMappedData(mapped_file); } } @@ -87,12 +87,12 @@ TEST_F(MemoryMappedFileTest, MapEmptyFile) { ASSERT_TRUE(WriteFile(test_file.c_str(), NULL, 0)); { - MemoryMappedFile mapped_file(test_file.c_str()); + MemoryMappedFile mapped_file(test_file.c_str(), 0); ExpectNoMappedData(mapped_file); } { MemoryMappedFile mapped_file; - EXPECT_TRUE(mapped_file.Map(test_file.c_str())); + EXPECT_TRUE(mapped_file.Map(test_file.c_str(), 0)); ExpectNoMappedData(mapped_file); } } @@ -109,7 +109,7 @@ TEST_F(MemoryMappedFileTest, MapNonEmptyFile) { ASSERT_TRUE(WriteFile(test_file.c_str(), data, data_size)); { - MemoryMappedFile mapped_file(test_file.c_str()); + MemoryMappedFile mapped_file(test_file.c_str(), 0); EXPECT_FALSE(mapped_file.content().IsEmpty()); EXPECT_TRUE(mapped_file.data() != NULL); EXPECT_EQ(data_size, mapped_file.size()); @@ -117,7 +117,7 @@ TEST_F(MemoryMappedFileTest, MapNonEmptyFile) { } { MemoryMappedFile mapped_file; - EXPECT_TRUE(mapped_file.Map(test_file.c_str())); + EXPECT_TRUE(mapped_file.Map(test_file.c_str(), 0)); EXPECT_FALSE(mapped_file.content().IsEmpty()); EXPECT_TRUE(mapped_file.data() != NULL); EXPECT_EQ(data_size, mapped_file.size()); @@ -145,13 +145,13 @@ TEST_F(MemoryMappedFileTest, RemapAfterMap) { ASSERT_TRUE(WriteFile(test_file2.c_str(), data2, data2_size)); { - MemoryMappedFile mapped_file(test_file1.c_str()); + MemoryMappedFile mapped_file(test_file1.c_str(), 0); EXPECT_FALSE(mapped_file.content().IsEmpty()); EXPECT_TRUE(mapped_file.data() != NULL); EXPECT_EQ(data1_size, mapped_file.size()); EXPECT_EQ(0, memcmp(data1, mapped_file.data(), data1_size)); - mapped_file.Map(test_file2.c_str()); + mapped_file.Map(test_file2.c_str(), 0); EXPECT_FALSE(mapped_file.content().IsEmpty()); EXPECT_TRUE(mapped_file.data() != NULL); EXPECT_EQ(data2_size, mapped_file.size()); @@ -159,16 +159,50 @@ TEST_F(MemoryMappedFileTest, RemapAfterMap) { } { MemoryMappedFile mapped_file; - EXPECT_TRUE(mapped_file.Map(test_file1.c_str())); + EXPECT_TRUE(mapped_file.Map(test_file1.c_str(), 0)); EXPECT_FALSE(mapped_file.content().IsEmpty()); EXPECT_TRUE(mapped_file.data() != NULL); EXPECT_EQ(data1_size, mapped_file.size()); EXPECT_EQ(0, memcmp(data1, mapped_file.data(), data1_size)); - mapped_file.Map(test_file2.c_str()); + mapped_file.Map(test_file2.c_str(), 0); EXPECT_FALSE(mapped_file.content().IsEmpty()); EXPECT_TRUE(mapped_file.data() != NULL); EXPECT_EQ(data2_size, mapped_file.size()); EXPECT_EQ(0, memcmp(data2, mapped_file.data(), data2_size)); } } + +TEST_F(MemoryMappedFileTest, MapWithOffset) { + // Put more data in the test file this time. Offsets can only be + // done on page boundaries, so we need a two page file to test this. + const int page_size = 4096; + char data1[2 * page_size]; + size_t data1_size = sizeof(data1); + for (size_t i = 0; i < data1_size; ++i) { + data1[i] = i & 0x7f; + } + + AutoTempDir temp_dir; + string test_file1 = temp_dir.path() + "/test_file1"; + ASSERT_TRUE(WriteFile(test_file1.c_str(), data1, data1_size)); + { + MemoryMappedFile mapped_file(test_file1.c_str(), page_size); + EXPECT_FALSE(mapped_file.content().IsEmpty()); + EXPECT_TRUE(mapped_file.data() != NULL); + EXPECT_EQ(data1_size - page_size, mapped_file.size()); + EXPECT_EQ( + 0, + memcmp(data1 + page_size, mapped_file.data(), data1_size - page_size)); + } + { + MemoryMappedFile mapped_file; + mapped_file.Map(test_file1.c_str(), page_size); + EXPECT_FALSE(mapped_file.content().IsEmpty()); + EXPECT_TRUE(mapped_file.data() != NULL); + EXPECT_EQ(data1_size - page_size, mapped_file.size()); + EXPECT_EQ( + 0, + memcmp(data1 + page_size, mapped_file.data(), data1_size - page_size)); + } +} |