summaryrefslogtreecommitdiffstats
path: root/libbacktrace/UnwindStackMap.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-12-01 21:37:37 -0800
committerChristopher Ferris <cferris@google.com>2017-12-05 13:12:47 -0800
commitb7de5f542925216dbb8b7124260d2915570598d1 (patch)
tree2126153a21557204dd60a05605c4aa0445155b11 /libbacktrace/UnwindStackMap.cpp
parentebca57adecb3521d78e4e1e5c220df897f84e336 (diff)
downloadsystem_core-b7de5f542925216dbb8b7124260d2915570598d1.tar.gz
system_core-b7de5f542925216dbb8b7124260d2915570598d1.tar.bz2
system_core-b7de5f542925216dbb8b7124260d2915570598d1.zip
Demand read load bias for a map.
Add a static GetLoadBias method to the Elf object that only reads just enough to get the load bias. Add a method to MapInfo that gets the load bias. First attempt to get it if the elf object already exists. If no elf object was created, use the new static method to get the load bias. In BacktraceMap, add a custom iterator so that when code dereferences a map element, that's when the load bias will be retrieved if it hasn't already been set. Bug: 69871050 Test: New unit tests, verify tombstones have non-zero load bias values for Test: libraries with a non-zero load bias. Change-Id: I125f4abc827589957fce2f0df24b0f25d037d732
Diffstat (limited to 'libbacktrace/UnwindStackMap.cpp')
-rw-r--r--libbacktrace/UnwindStackMap.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/libbacktrace/UnwindStackMap.cpp b/libbacktrace/UnwindStackMap.cpp
index 9ac0a0b54..836a774b9 100644
--- a/libbacktrace/UnwindStackMap.cpp
+++ b/libbacktrace/UnwindStackMap.cpp
@@ -71,8 +71,19 @@ void UnwindStackMap::FillIn(uintptr_t addr, backtrace_map_t* map) {
if (map_info == nullptr) {
return;
}
- unwindstack::Elf* elf = map_info->GetElf(process_memory_, true);
- map->load_bias = elf->GetLoadBias();
+ map->load_bias = map_info->GetLoadBias(process_memory_);
+}
+
+uint64_t UnwindStackMap::GetLoadBias(size_t index) {
+ if (index >= stack_maps_->Total()) {
+ return 0;
+ }
+
+ unwindstack::MapInfo* map_info = stack_maps_->Get(index);
+ if (map_info == nullptr) {
+ return 0;
+ }
+ return map_info->GetLoadBias(process_memory_);
}
std::string UnwindStackMap::GetFunctionName(uintptr_t pc, uintptr_t* offset) {