diff --git a/debuggerd/libdebuggerd/test/tombstone_test.cpp b/debuggerd/libdebuggerd/test/tombstone_test.cpp index 325210d94..6be59e7ac 100644 --- a/debuggerd/libdebuggerd/test/tombstone_test.cpp +++ b/debuggerd/libdebuggerd/test/tombstone_test.cpp @@ -220,21 +220,21 @@ TEST_F(TombstoneTest, multiple_maps) { map.start = 0xa434000; map.end = 0xa435000; map.offset = 0x1000; - map.load_base = 0xd000; + map.load_bias = 0xd000; map.flags = PROT_WRITE; map_mock_->AddMap(map); map.start = 0xa534000; map.end = 0xa535000; map.offset = 0x3000; - map.load_base = 0x2000; + map.load_bias = 0x2000; map.flags = PROT_EXEC; map_mock_->AddMap(map); map.start = 0xa634000; map.end = 0xa635000; map.offset = 0; - map.load_base = 0; + map.load_bias = 0; map.flags = PROT_READ | PROT_WRITE | PROT_EXEC; map.name = "/system/lib/fake.so"; map_mock_->AddMap(map); @@ -244,20 +244,20 @@ TEST_F(TombstoneTest, multiple_maps) { std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents)); - const char* expected_dump = \ -"\nmemory map:\n" + const char* expected_dump = + "\nmemory map:\n" #if defined(__LP64__) -" 00000000'0a234000-00000000'0a234fff --- 0 1000\n" -" 00000000'0a334000-00000000'0a334fff r-- f000 1000\n" -" 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load base 0xd000)\n" -" 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load base 0x2000)\n" -" 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; + " 00000000'0a234000-00000000'0a234fff --- 0 1000\n" + " 00000000'0a334000-00000000'0a334fff r-- f000 1000\n" + " 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load bias 0xd000)\n" + " 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; #else -" 0a234000-0a234fff --- 0 1000\n" -" 0a334000-0a334fff r-- f000 1000\n" -" 0a434000-0a434fff -w- 1000 1000 (load base 0xd000)\n" -" 0a534000-0a534fff --x 3000 1000 (load base 0x2000)\n" -" 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; + " 0a234000-0a234fff --- 0 1000\n" + " 0a334000-0a334fff r-- f000 1000\n" + " 0a434000-0a434fff -w- 1000 1000 (load bias 0xd000)\n" + " 0a534000-0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; #endif ASSERT_STREQ(expected_dump, tombstone_contents.c_str()); @@ -274,21 +274,21 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_before) { map.start = 0xa434000; map.end = 0xa435000; map.offset = 0x1000; - map.load_base = 0xd000; + map.load_bias = 0xd000; map.flags = PROT_WRITE; map_mock_->AddMap(map); map.start = 0xa534000; map.end = 0xa535000; map.offset = 0x3000; - map.load_base = 0x2000; + map.load_bias = 0x2000; map.flags = PROT_EXEC; map_mock_->AddMap(map); map.start = 0xa634000; map.end = 0xa635000; map.offset = 0; - map.load_base = 0; + map.load_bias = 0; map.flags = PROT_READ | PROT_WRITE | PROT_EXEC; map.name = "/system/lib/fake.so"; map_mock_->AddMap(map); @@ -304,18 +304,18 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_before) { std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents)); - const char* expected_dump = \ -"\nmemory map: (fault address prefixed with --->)\n" + const char* expected_dump = + "\nmemory map: (fault address prefixed with --->)\n" #if defined(__LP64__) -"--->Fault address falls at 00000000'00001000 before any mapped regions\n" -" 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load base 0xd000)\n" -" 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load base 0x2000)\n" -" 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; + "--->Fault address falls at 00000000'00001000 before any mapped regions\n" + " 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load bias 0xd000)\n" + " 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; #else -"--->Fault address falls at 00001000 before any mapped regions\n" -" 0a434000-0a434fff -w- 1000 1000 (load base 0xd000)\n" -" 0a534000-0a534fff --x 3000 1000 (load base 0x2000)\n" -" 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; + "--->Fault address falls at 00001000 before any mapped regions\n" + " 0a434000-0a434fff -w- 1000 1000 (load bias 0xd000)\n" + " 0a534000-0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; #endif ASSERT_STREQ(expected_dump, tombstone_contents.c_str()); @@ -332,21 +332,21 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_between) { map.start = 0xa434000; map.end = 0xa435000; map.offset = 0x1000; - map.load_base = 0xd000; + map.load_bias = 0xd000; map.flags = PROT_WRITE; map_mock_->AddMap(map); map.start = 0xa534000; map.end = 0xa535000; map.offset = 0x3000; - map.load_base = 0x2000; + map.load_bias = 0x2000; map.flags = PROT_EXEC; map_mock_->AddMap(map); map.start = 0xa634000; map.end = 0xa635000; map.offset = 0; - map.load_base = 0; + map.load_bias = 0; map.flags = PROT_READ | PROT_WRITE | PROT_EXEC; map.name = "/system/lib/fake.so"; map_mock_->AddMap(map); @@ -362,18 +362,18 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_between) { std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents)); - const char* expected_dump = \ -"\nmemory map: (fault address prefixed with --->)\n" + const char* expected_dump = + "\nmemory map: (fault address prefixed with --->)\n" #if defined(__LP64__) -" 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load base 0xd000)\n" -"--->Fault address falls at 00000000'0a533000 between mapped regions\n" -" 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load base 0x2000)\n" -" 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; + " 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load bias 0xd000)\n" + "--->Fault address falls at 00000000'0a533000 between mapped regions\n" + " 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; #else -" 0a434000-0a434fff -w- 1000 1000 (load base 0xd000)\n" -"--->Fault address falls at 0a533000 between mapped regions\n" -" 0a534000-0a534fff --x 3000 1000 (load base 0x2000)\n" -" 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; + " 0a434000-0a434fff -w- 1000 1000 (load bias 0xd000)\n" + "--->Fault address falls at 0a533000 between mapped regions\n" + " 0a534000-0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; #endif ASSERT_STREQ(expected_dump, tombstone_contents.c_str()); @@ -390,21 +390,21 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_in_map) { map.start = 0xa434000; map.end = 0xa435000; map.offset = 0x1000; - map.load_base = 0xd000; + map.load_bias = 0xd000; map.flags = PROT_WRITE; map_mock_->AddMap(map); map.start = 0xa534000; map.end = 0xa535000; map.offset = 0x3000; - map.load_base = 0x2000; + map.load_bias = 0x2000; map.flags = PROT_EXEC; map_mock_->AddMap(map); map.start = 0xa634000; map.end = 0xa635000; map.offset = 0; - map.load_base = 0; + map.load_bias = 0; map.flags = PROT_READ | PROT_WRITE | PROT_EXEC; map.name = "/system/lib/fake.so"; map_mock_->AddMap(map); @@ -420,16 +420,16 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_in_map) { std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents)); - const char* expected_dump = \ -"\nmemory map: (fault address prefixed with --->)\n" + const char* expected_dump = + "\nmemory map: (fault address prefixed with --->)\n" #if defined(__LP64__) -" 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load base 0xd000)\n" -"--->00000000'0a534000-00000000'0a534fff --x 3000 1000 (load base 0x2000)\n" -" 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; + " 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load bias 0xd000)\n" + "--->00000000'0a534000-00000000'0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n"; #else -" 0a434000-0a434fff -w- 1000 1000 (load base 0xd000)\n" -"--->0a534000-0a534fff --x 3000 1000 (load base 0x2000)\n" -" 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; + " 0a434000-0a434fff -w- 1000 1000 (load bias 0xd000)\n" + "--->0a534000-0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n"; #endif ASSERT_STREQ(expected_dump, tombstone_contents.c_str()); @@ -446,21 +446,21 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_after) { map.start = 0xa434000; map.end = 0xa435000; map.offset = 0x1000; - map.load_base = 0xd000; + map.load_bias = 0xd000; map.flags = PROT_WRITE; map_mock_->AddMap(map); map.start = 0xa534000; map.end = 0xa535000; map.offset = 0x3000; - map.load_base = 0x2000; + map.load_bias = 0x2000; map.flags = PROT_EXEC; map_mock_->AddMap(map); map.start = 0xa634000; map.end = 0xa635000; map.offset = 0; - map.load_base = 0; + map.load_bias = 0; map.flags = PROT_READ | PROT_WRITE | PROT_EXEC; map.name = "/system/lib/fake.so"; map_mock_->AddMap(map); @@ -480,18 +480,18 @@ TEST_F(TombstoneTest, multiple_maps_fault_address_after) { std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents)); - const char* expected_dump = \ -"\nmemory map: (fault address prefixed with --->)\n" + const char* expected_dump = + "\nmemory map: (fault address prefixed with --->)\n" #if defined(__LP64__) -" 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load base 0xd000)\n" -" 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load base 0x2000)\n" -" 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n" -"--->Fault address falls at 00001234'5a534040 after any mapped regions\n"; + " 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load bias 0xd000)\n" + " 00000000'0a534000-00000000'0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 00000000'0a634000-00000000'0a634fff rwx 0 1000 /system/lib/fake.so\n" + "--->Fault address falls at 00001234'5a534040 after any mapped regions\n"; #else -" 0a434000-0a434fff -w- 1000 1000 (load base 0xd000)\n" -" 0a534000-0a534fff --x 3000 1000 (load base 0x2000)\n" -" 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n" -"--->Fault address falls at 0f534040 after any mapped regions\n"; + " 0a434000-0a434fff -w- 1000 1000 (load bias 0xd000)\n" + " 0a534000-0a534fff --x 3000 1000 (load bias 0x2000)\n" + " 0a634000-0a634fff rwx 0 1000 /system/lib/fake.so\n" + "--->Fault address falls at 0f534040 after any mapped regions\n"; #endif ASSERT_STREQ(expected_dump, tombstone_contents.c_str()); @@ -508,7 +508,7 @@ TEST_F(TombstoneTest, multiple_maps_getsiginfo_fail) { map.start = 0xa434000; map.end = 0xa435000; map.offset = 0x1000; - map.load_base = 0xd000; + map.load_bias = 0xd000; map.flags = PROT_WRITE; map_mock_->AddMap(map); @@ -520,12 +520,12 @@ TEST_F(TombstoneTest, multiple_maps_getsiginfo_fail) { std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(android::base::ReadFdToString(log_.tfd, &tombstone_contents)); - const char* expected_dump = \ -"\nmemory map:\n" + const char* expected_dump = + "\nmemory map:\n" #if defined(__LP64__) -" 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load base 0xd000)\n"; + " 00000000'0a434000-00000000'0a434fff -w- 1000 1000 (load bias 0xd000)\n"; #else -" 0a434000-0a434fff -w- 1000 1000 (load base 0xd000)\n"; + " 0a434000-0a434fff -w- 1000 1000 (load bias 0xd000)\n"; #endif ASSERT_STREQ(expected_dump, tombstone_contents.c_str()); diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index 996d7146c..011313149 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -466,11 +466,11 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p line += " (BuildId: " + build_id + ")"; } } - if (it->load_base != 0) { + if (it->load_bias != 0) { if (space_needed) { line += ' '; } - line += StringPrintf(" (load base 0x%" PRIxPTR ")", it->load_base); + line += StringPrintf(" (load bias 0x%" PRIxPTR ")", it->load_bias); } _LOG(log, logtype::MAPS, "%s\n", line.c_str()); } diff --git a/libbacktrace/Backtrace.cpp b/libbacktrace/Backtrace.cpp index e46d35389..81f5e32cc 100644 --- a/libbacktrace/Backtrace.cpp +++ b/libbacktrace/Backtrace.cpp @@ -84,10 +84,8 @@ std::string Backtrace::FormatFrameData(size_t frame_num) { } std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { - uintptr_t relative_pc; std::string map_name; if (BacktraceMap::IsValid(frame->map)) { - relative_pc = BacktraceMap::GetRelativePc(frame->map, frame->pc); if (!frame->map.name.empty()) { map_name = frame->map.name.c_str(); if (map_name[0] == '[' && map_name[map_name.size() - 1] == ']') { @@ -99,10 +97,9 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { } } else { map_name = ""; - relative_pc = frame->pc; } - std::string line(StringPrintf("#%02zu pc %" PRIPTR " ", frame->num, relative_pc)); + std::string line(StringPrintf("#%02zu pc %" PRIPTR " ", frame->num, frame->rel_pc)); line += map_name; // Special handling for non-zero offset maps, we need to print that // information. diff --git a/libbacktrace/UnwindCurrent.cpp b/libbacktrace/UnwindCurrent.cpp index 3c509e61a..2c87fa837 100644 --- a/libbacktrace/UnwindCurrent.cpp +++ b/libbacktrace/UnwindCurrent.cpp @@ -133,6 +133,11 @@ bool UnwindCurrent::UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucon backtrace_frame_data_t* prev = &frames_.at(num_frames-1); prev->stack_size = frame->sp - prev->sp; } + if (BacktraceMap::IsValid(frame->map)) { + frame->rel_pc = frame->pc - frame->map.start + frame->map.load_bias; + } else { + frame->rel_pc = frame->pc; + } num_frames++; } else { num_ignore_frames--; diff --git a/libbacktrace/UnwindMap.cpp b/libbacktrace/UnwindMap.cpp index af7956246..0b8232b2f 100644 --- a/libbacktrace/UnwindMap.cpp +++ b/libbacktrace/UnwindMap.cpp @@ -57,7 +57,7 @@ bool UnwindMapRemote::GenerateMap() { map.start = unw_map.start; map.end = unw_map.end; map.offset = unw_map.offset; - map.load_base = unw_map.load_base; + map.load_bias = unw_map.load_base; map.flags = unw_map.flags; map.name = unw_map.path; @@ -106,7 +106,7 @@ bool UnwindMapLocal::GenerateMap() { map.start = unw_map.start; map.end = unw_map.end; map.offset = unw_map.offset; - map.load_base = unw_map.load_base; + map.load_bias = unw_map.load_base; map.flags = unw_map.flags; map.name = unw_map.path; diff --git a/libbacktrace/UnwindPtrace.cpp b/libbacktrace/UnwindPtrace.cpp index 42ac1bc07..87282ef8c 100644 --- a/libbacktrace/UnwindPtrace.cpp +++ b/libbacktrace/UnwindPtrace.cpp @@ -135,6 +135,11 @@ bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { } FillInMap(frame->pc, &frame->map); + if (BacktraceMap::IsValid(frame->map)) { + frame->rel_pc = frame->pc - frame->map.start + frame->map.load_bias; + } else { + frame->rel_pc = frame->pc; + } frame->func_name = GetFunctionName(frame->pc, &frame->func_offset, &frame->map); diff --git a/libbacktrace/backtrace_offline_test.cpp b/libbacktrace/backtrace_offline_test.cpp index 465b3f985..16b1d791c 100644 --- a/libbacktrace/backtrace_offline_test.cpp +++ b/libbacktrace/backtrace_offline_test.cpp @@ -167,9 +167,9 @@ TEST(libbacktrace, DISABLED_generate_offline_testdata) { // 2. Dump maps for (auto it = map->begin(); it != map->end(); ++it) { testdata += android::base::StringPrintf( - "map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR - " load_base: %" PRIxPTR " flags: %d name: %s\n", - it->start, it->end, it->offset, it->load_base, it->flags, it->name.c_str()); + "map: start: %" PRIxPTR " end: %" PRIxPTR " offset: %" PRIxPTR " load_bias: %" PRIxPTR + " flags: %d name: %s\n", + it->start, it->end, it->offset, it->load_bias, it->flags, it->name.c_str()); } // 3. Dump registers testdata += android::base::StringPrintf("registers: %zu ", sizeof(arg.unw_context)); @@ -246,9 +246,9 @@ bool ReadOfflineTestData(const std::string offline_testdata_path, OfflineTestDat backtrace_map_t& map = testdata->maps.back(); int pos; sscanf(line.c_str(), - "map: start: %" SCNxPTR " end: %" SCNxPTR " offset: %" SCNxPTR - " load_base: %" SCNxPTR " flags: %d name: %n", - &map.start, &map.end, &map.offset, &map.load_base, &map.flags, &pos); + "map: start: %" SCNxPTR " end: %" SCNxPTR " offset: %" SCNxPTR " load_bias: %" SCNxPTR + " flags: %d name: %n", + &map.start, &map.end, &map.offset, &map.load_bias, &map.flags, &pos); map.name = android::base::Trim(line.substr(pos)); } else if (android::base::StartsWith(line, "registers:")) { size_t size; @@ -392,8 +392,8 @@ TEST(libbacktrace, offline_unwind_mix_eh_frame_and_arm_exidx) { // The last frame is outside of libart.so ASSERT_EQ(testdata.symbols.size() + 1, backtrace->NumFrames()); for (size_t i = 0; i + 1 < backtrace->NumFrames(); ++i) { - uintptr_t vaddr_in_file = backtrace->GetFrame(i)->pc - testdata.maps[0].start + - testdata.maps[0].load_base; + uintptr_t vaddr_in_file = + backtrace->GetFrame(i)->pc - testdata.maps[0].start + testdata.maps[0].load_bias; std::string name = FunctionNameForAddress(vaddr_in_file, testdata.symbols); ASSERT_EQ(name, testdata.symbols[i].name); } diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp index fb463b021..1ec6a45cc 100644 --- a/libbacktrace/backtrace_test.cpp +++ b/libbacktrace/backtrace_test.cpp @@ -784,6 +784,7 @@ TEST(libbacktrace, format_test) { backtrace_frame_data_t frame; frame.num = 1; frame.pc = 2; + frame.rel_pc = 2; frame.sp = 0; frame.stack_size = 0; frame.func_offset = 0; @@ -799,9 +800,10 @@ TEST(libbacktrace, format_test) { // Check map name empty, but exists. frame.pc = 0xb0020; + frame.rel_pc = 0x20; frame.map.start = 0xb0000; frame.map.end = 0xbffff; - frame.map.load_base = 0; + frame.map.load_bias = 0; #if defined(__LP64__) EXPECT_EQ("#01 pc 0000000000000020 ", #else @@ -813,7 +815,7 @@ TEST(libbacktrace, format_test) { frame.pc = 0xc0020; frame.map.start = 0xc0000; frame.map.end = 0xcffff; - frame.map.load_base = 0; + frame.map.load_bias = 0; frame.map.name = "[anon:thread signal stack]"; #if defined(__LP64__) EXPECT_EQ("#01 pc 0000000000000020 [anon:thread signal stack:00000000000c0000]", @@ -824,6 +826,7 @@ TEST(libbacktrace, format_test) { // Check relative pc is set and map name is set. frame.pc = 0x12345679; + frame.rel_pc = 0x12345678; frame.map.name = "MapFake"; frame.map.start = 1; frame.map.end = 1; @@ -852,9 +855,10 @@ TEST(libbacktrace, format_test) { #endif backtrace->FormatFrameData(&frame)); - // Check func_name is set, func offset is non-zero, and load_base is non-zero. + // Check func_name is set, func offset is non-zero, and load_bias is non-zero. + frame.rel_pc = 0x123456dc; frame.func_offset = 645; - frame.map.load_base = 100; + frame.map.load_bias = 100; #if defined(__LP64__) EXPECT_EQ("#01 pc 00000000123456dc MapFake (ProcFake+645)", #else @@ -1737,9 +1741,13 @@ static void UnwindThroughSignal(bool use_action) { FinishRemoteProcess(pid); } -TEST(libbacktrace, unwind_remote_through_signal_using_handler) { UnwindThroughSignal(false); } +TEST(libbacktrace, unwind_remote_through_signal_using_handler) { + UnwindThroughSignal(false); +} -TEST(libbacktrace, unwind_remote_through_signal_using_action) { UnwindThroughSignal(true); } +TEST(libbacktrace, unwind_remote_through_signal_using_action) { + UnwindThroughSignal(true); +} #if defined(ENABLE_PSS_TESTS) #include "GetPss.h" diff --git a/libbacktrace/include/backtrace/Backtrace.h b/libbacktrace/include/backtrace/Backtrace.h index 4f73a658c..b919e81c6 100644 --- a/libbacktrace/include/backtrace/Backtrace.h +++ b/libbacktrace/include/backtrace/Backtrace.h @@ -55,6 +55,7 @@ enum BacktraceUnwindError : uint32_t { struct backtrace_frame_data_t { size_t num; // The current fame number. uintptr_t pc; // The absolute pc. + uintptr_t rel_pc; // The relative pc. uintptr_t sp; // The top of the stack. size_t stack_size; // The size of the stack, zero indicate an unknown stack size. backtrace_map_t map; // The map associated with the given pc. diff --git a/libbacktrace/include/backtrace/BacktraceMap.h b/libbacktrace/include/backtrace/BacktraceMap.h index 8ab0dfabb..02a50f738 100644 --- a/libbacktrace/include/backtrace/BacktraceMap.h +++ b/libbacktrace/include/backtrace/BacktraceMap.h @@ -41,7 +41,7 @@ struct backtrace_map_t { uintptr_t start = 0; uintptr_t end = 0; uintptr_t offset = 0; - uintptr_t load_base = 0; + uintptr_t load_bias = 0; int flags = 0; std::string name; }; @@ -95,14 +95,6 @@ public: return map.end > 0; } - static uintptr_t GetRelativePc(const backtrace_map_t& map, uintptr_t pc) { - if (IsValid(map)) { - return pc - map.start + map.load_base; - } else { - return pc; - } - } - protected: BacktraceMap(pid_t pid);