Merge "Add load base to map for relocation packing." into mnc-dev
This commit is contained in:
commit
5cffd97199
5 changed files with 26 additions and 6 deletions
|
|
@ -379,6 +379,9 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p
|
||||||
line += " (BuildId: " + build_id + ")";
|
line += " (BuildId: " + build_id + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (it->load_base != 0) {
|
||||||
|
line += android::base::StringPrintf(" (load base 0x%" PRIxPTR ")", it->load_base);
|
||||||
|
}
|
||||||
_LOG(log, logtype::MAPS, "%s\n", line.c_str());
|
_LOG(log, logtype::MAPS, "%s\n", line.c_str());
|
||||||
}
|
}
|
||||||
if (print_fault_address_marker) {
|
if (print_fault_address_marker) {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ struct backtrace_map_t {
|
||||||
|
|
||||||
uintptr_t start;
|
uintptr_t start;
|
||||||
uintptr_t end;
|
uintptr_t end;
|
||||||
|
uintptr_t load_base;
|
||||||
int flags;
|
int flags;
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
@ -82,6 +83,14 @@ public:
|
||||||
return map.end > 0;
|
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:
|
protected:
|
||||||
BacktraceMap(pid_t pid);
|
BacktraceMap(pid_t pid);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,7 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) {
|
||||||
map_name = "<unknown>";
|
map_name = "<unknown>";
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t relative_pc;
|
uintptr_t relative_pc = BacktraceMap::GetRelativePc(frame->map, frame->pc);
|
||||||
if (BacktraceMap::IsValid(frame->map)) {
|
|
||||||
relative_pc = frame->pc - frame->map.start;
|
|
||||||
} else {
|
|
||||||
relative_pc = frame->pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string line(StringPrintf("#%02zu pc %" PRIPTR " %s", frame->num, relative_pc, map_name));
|
std::string line(StringPrintf("#%02zu pc %" PRIPTR " %s", frame->num, relative_pc, map_name));
|
||||||
if (!frame->func_name.empty()) {
|
if (!frame->func_name.empty()) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ bool UnwindMap::GenerateMap() {
|
||||||
|
|
||||||
map.start = unw_map.start;
|
map.start = unw_map.start;
|
||||||
map.end = unw_map.end;
|
map.end = unw_map.end;
|
||||||
|
map.load_base = unw_map.load_base;
|
||||||
map.flags = unw_map.flags;
|
map.flags = unw_map.flags;
|
||||||
map.name = unw_map.path;
|
map.name = unw_map.path;
|
||||||
|
|
||||||
|
|
@ -91,6 +92,7 @@ bool UnwindMapLocal::GenerateMap() {
|
||||||
|
|
||||||
map.start = unw_map.start;
|
map.start = unw_map.start;
|
||||||
map.end = unw_map.end;
|
map.end = unw_map.end;
|
||||||
|
map.load_base = unw_map.load_base;
|
||||||
map.flags = unw_map.flags;
|
map.flags = unw_map.flags;
|
||||||
map.name = unw_map.path;
|
map.name = unw_map.path;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -771,6 +771,7 @@ TEST(libbacktrace, format_test) {
|
||||||
// Check map name empty, but exists.
|
// Check map name empty, but exists.
|
||||||
frame.map.start = 1;
|
frame.map.start = 1;
|
||||||
frame.map.end = 1;
|
frame.map.end = 1;
|
||||||
|
frame.map.load_base = 0;
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
EXPECT_EQ("#01 pc 0000000000000001 <unknown>",
|
EXPECT_EQ("#01 pc 0000000000000001 <unknown>",
|
||||||
#else
|
#else
|
||||||
|
|
@ -806,6 +807,16 @@ TEST(libbacktrace, format_test) {
|
||||||
EXPECT_EQ("#01 pc 0000000012345678 MapFake (ProcFake+645)",
|
EXPECT_EQ("#01 pc 0000000012345678 MapFake (ProcFake+645)",
|
||||||
#else
|
#else
|
||||||
EXPECT_EQ("#01 pc 12345678 MapFake (ProcFake+645)",
|
EXPECT_EQ("#01 pc 12345678 MapFake (ProcFake+645)",
|
||||||
|
#endif
|
||||||
|
backtrace->FormatFrameData(&frame));
|
||||||
|
|
||||||
|
// Check func_name is set, func offset is non-zero, and load_base is non-zero.
|
||||||
|
frame.func_offset = 645;
|
||||||
|
frame.map.load_base = 100;
|
||||||
|
#if defined(__LP64__)
|
||||||
|
EXPECT_EQ("#01 pc 00000000123456dc MapFake (ProcFake+645)",
|
||||||
|
#else
|
||||||
|
EXPECT_EQ("#01 pc 123456dc MapFake (ProcFake+645)",
|
||||||
#endif
|
#endif
|
||||||
backtrace->FormatFrameData(&frame));
|
backtrace->FormatFrameData(&frame));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue