Fix issues in libunwindstack.
- Add a load_bias field in MapInfo so that it can be loaded offline,
and also so it can be cached.
- Add an Add function to the Maps class so that it's possible to manually
create a map.
- Remove the OfflineMaps class since I haven't found a reason for this to
exist.
- Add a pointer to the gnu debugdata compressed section in the interface
itself and modify the step path to try eh_frame, then debug_frame, then
gnu_debugdata. This way arm can add exidx as the last step behind
gnu_debugdata. Add an offline test to verify the order of unwind.
- Fix x86_64_ucontext_t since it was a different size on 32 bit and 64 bit
systems.
Test: Pass new unit tests.
Change-Id: I978b70d6c244bd307c62a29886d24c1a8cb2af23
diff --git a/libunwindstack/MapInfo.cpp b/libunwindstack/MapInfo.cpp
index 51bce8e..89fe038 100644
--- a/libunwindstack/MapInfo.cpp
+++ b/libunwindstack/MapInfo.cpp
@@ -122,13 +122,21 @@
}
uint64_t MapInfo::GetLoadBias(const std::shared_ptr<Memory>& process_memory) {
+ uint64_t cur_load_bias = load_bias.load();
+ if (cur_load_bias != static_cast<uint64_t>(-1)) {
+ return cur_load_bias;
+ }
+
{
// Make sure no other thread is trying to add the elf to this map.
std::lock_guard<std::mutex> guard(mutex_);
if (elf != nullptr) {
if (elf->valid()) {
- return elf->GetLoadBias();
+ cur_load_bias = elf->GetLoadBias();
+ load_bias = cur_load_bias;
+ return cur_load_bias;
} else {
+ load_bias = 0;
return 0;
}
}
@@ -137,7 +145,9 @@
// Call lightweight static function that will only read enough of the
// elf data to get the load bias.
std::unique_ptr<Memory> memory(CreateMemory(process_memory));
- return Elf::GetLoadBias(memory.get());
+ cur_load_bias = Elf::GetLoadBias(memory.get());
+ load_bias = cur_load_bias;
+ return cur_load_bias;
}
} // namespace unwindstack