diff options
| author | Christopher Ferris <cferris@google.com> | 2019-04-11 19:45:35 -0700 |
|---|---|---|
| committer | Christopher Ferris <cferris@google.com> | 2019-04-15 14:14:56 -0700 |
| commit | 82866421b8b357b18c71e2b560c81c95ab925934 (patch) | |
| tree | b30925b10e3417d5d21a6012a52c81b724ee3c3d /libunwindstack/tests | |
| parent | 1dd53f763b4deb122215d5d426b794da02bc2ac3 (diff) | |
| download | system_core-82866421b8b357b18c71e2b560c81c95ab925934.tar.gz system_core-82866421b8b357b18c71e2b560c81c95ab925934.tar.bz2 system_core-82866421b8b357b18c71e2b560c81c95ab925934.zip | |
Fix pc/function name for signal handler frame.
This refactors the step function slightly to split it up into
distinct pieces since the code needs to handle a signal handler
versus normal step slightly differently.
Add a new error for an invalid elf.
Modify libbacktrace code to handle new error code.
Bug: 130302288
Test: libbacktrace/libunwindstack unit tests.
Change-Id: I3fb9b00c02d2cf2cc5911541bba0346c6f39b8e6
Merged-In: I3fb9b00c02d2cf2cc5911541bba0346c6f39b8e6
(cherry picked from commit d11ed86d65e870c5ea0d4918693376d474dbfe7d)
Diffstat (limited to 'libunwindstack/tests')
| -rw-r--r-- | libunwindstack/tests/ElfTest.cpp | 13 | ||||
| -rw-r--r-- | libunwindstack/tests/UnwindOfflineTest.cpp | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/libunwindstack/tests/ElfTest.cpp b/libunwindstack/tests/ElfTest.cpp index 23c9cf860..c432d6d4f 100644 --- a/libunwindstack/tests/ElfTest.cpp +++ b/libunwindstack/tests/ElfTest.cpp @@ -132,8 +132,12 @@ TEST_F(ElfTest, elf_invalid) { uint64_t func_offset; ASSERT_FALSE(elf.GetFunctionName(0, &name, &func_offset)); + ASSERT_FALSE(elf.StepIfSignalHandler(0, nullptr, nullptr)); + EXPECT_EQ(ERROR_INVALID_ELF, elf.GetLastErrorCode()); + bool finished; - ASSERT_FALSE(elf.Step(0, 0, nullptr, nullptr, &finished)); + ASSERT_FALSE(elf.Step(0, nullptr, nullptr, &finished)); + EXPECT_EQ(ERROR_INVALID_ELF, elf.GetLastErrorCode()); } TEST_F(ElfTest, elf32_invalid_machine) { @@ -295,9 +299,8 @@ TEST_F(ElfTest, step_in_signal_map) { } elf.FakeSetValid(true); - bool finished; - ASSERT_TRUE(elf.Step(0x3000, 0x1000, ®s, &process_memory, &finished)); - EXPECT_FALSE(finished); + ASSERT_TRUE(elf.StepIfSignalHandler(0x3000, ®s, &process_memory)); + EXPECT_EQ(ERROR_NONE, elf.GetLastErrorCode()); EXPECT_EQ(15U, regs.pc()); EXPECT_EQ(13U, regs.sp()); } @@ -336,7 +339,7 @@ TEST_F(ElfTest, step_in_interface) { EXPECT_CALL(*interface, Step(0x1000, ®s, &process_memory, &finished)) .WillOnce(::testing::Return(true)); - ASSERT_TRUE(elf.Step(0x1004, 0x1000, ®s, &process_memory, &finished)); + ASSERT_TRUE(elf.Step(0x1000, ®s, &process_memory, &finished)); } TEST_F(ElfTest, get_global_invalid_elf) { diff --git a/libunwindstack/tests/UnwindOfflineTest.cpp b/libunwindstack/tests/UnwindOfflineTest.cpp index 02ba9c8fa..6c64c4097 100644 --- a/libunwindstack/tests/UnwindOfflineTest.cpp +++ b/libunwindstack/tests/UnwindOfflineTest.cpp @@ -1215,7 +1215,7 @@ TEST_F(UnwindOfflineTest, offset_arm) { " #02 pc 0032bff3 libunwindstack_test (SignalOuterFunction+2)\n" " #03 pc 0032fed3 libunwindstack_test " "(unwindstack::SignalCallerHandler(int, siginfo*, void*)+26)\n" - " #04 pc 00026528 libc.so\n" + " #04 pc 0002652c libc.so (__restore)\n" " #05 pc 00000000 <unknown>\n" " #06 pc 0032c2d9 libunwindstack_test (InnerFunction+736)\n" " #07 pc 0032cc4f libunwindstack_test (MiddleFunction+42)\n" @@ -1243,7 +1243,7 @@ TEST_F(UnwindOfflineTest, offset_arm) { EXPECT_EQ(0xf43d2ce8U, unwinder.frames()[2].sp); EXPECT_EQ(0x2e59ed3U, unwinder.frames()[3].pc); EXPECT_EQ(0xf43d2cf0U, unwinder.frames()[3].sp); - EXPECT_EQ(0xf4136528U, unwinder.frames()[4].pc); + EXPECT_EQ(0xf413652cU, unwinder.frames()[4].pc); EXPECT_EQ(0xf43d2d10U, unwinder.frames()[4].sp); EXPECT_EQ(0U, unwinder.frames()[5].pc); EXPECT_EQ(0xffcc0ee0U, unwinder.frames()[5].sp); @@ -1326,7 +1326,7 @@ TEST_F(UnwindOfflineTest, shared_lib_in_apk_arm64) { " #00 pc 000000000014ccbc linker64 (__dl_syscall+28)\n" " #01 pc 000000000005426c linker64 " "(__dl__ZL24debuggerd_signal_handleriP7siginfoPv+1128)\n" - " #02 pc 00000000000008bc vdso.so\n" + " #02 pc 00000000000008c0 vdso.so (__kernel_rt_sigreturn)\n" " #03 pc 00000000000846f4 libc.so (abort+172)\n" " #04 pc 0000000000084ad4 libc.so (__assert2+36)\n" " #05 pc 000000000003d5b4 ANGLEPrebuilt.apk!libfeature_support_angle.so (offset 0x4000) " @@ -1338,7 +1338,7 @@ TEST_F(UnwindOfflineTest, shared_lib_in_apk_arm64) { EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[0].sp); EXPECT_EQ(0x7e82b5726cULL, unwinder.frames()[1].pc); EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[1].sp); - EXPECT_EQ(0x7e82b018bcULL, unwinder.frames()[2].pc); + EXPECT_EQ(0x7e82b018c0ULL, unwinder.frames()[2].pc); EXPECT_EQ(0x7df8ca3da0ULL, unwinder.frames()[2].sp); EXPECT_EQ(0x7e7eecc6f4ULL, unwinder.frames()[3].pc); EXPECT_EQ(0x7dabf3db60ULL, unwinder.frames()[3].sp); @@ -1366,7 +1366,7 @@ TEST_F(UnwindOfflineTest, shared_lib_in_apk_memory_only_arm64) { " #00 pc 000000000014ccbc linker64 (__dl_syscall+28)\n" " #01 pc 000000000005426c linker64 " "(__dl__ZL24debuggerd_signal_handleriP7siginfoPv+1128)\n" - " #02 pc 00000000000008bc vdso.so\n" + " #02 pc 00000000000008c0 vdso.so (__kernel_rt_sigreturn)\n" " #03 pc 00000000000846f4 libc.so (abort+172)\n" " #04 pc 0000000000084ad4 libc.so (__assert2+36)\n" " #05 pc 000000000003d5b4 ANGLEPrebuilt.apk (offset 0x21d5000)\n" @@ -1377,7 +1377,7 @@ TEST_F(UnwindOfflineTest, shared_lib_in_apk_memory_only_arm64) { EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[0].sp); EXPECT_EQ(0x7e82b5726cULL, unwinder.frames()[1].pc); EXPECT_EQ(0x7df8ca3bf0ULL, unwinder.frames()[1].sp); - EXPECT_EQ(0x7e82b018bcULL, unwinder.frames()[2].pc); + EXPECT_EQ(0x7e82b018c0ULL, unwinder.frames()[2].pc); EXPECT_EQ(0x7df8ca3da0ULL, unwinder.frames()[2].sp); EXPECT_EQ(0x7e7eecc6f4ULL, unwinder.frames()[3].pc); EXPECT_EQ(0x7dabf3db60ULL, unwinder.frames()[3].sp); |
