summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris2017-12-01 23:37:37 -0600
committerChristopher Ferris2017-12-05 15:12:47 -0600
commitb7de5f542925216dbb8b7124260d2915570598d1 (patch)
tree2126153a21557204dd60a05605c4aa0445155b11 /debuggerd
parentebca57adecb3521d78e4e1e5c220df897f84e336 (diff)
downloadplatform-system-core-b7de5f542925216dbb8b7124260d2915570598d1.tar.gz
platform-system-core-b7de5f542925216dbb8b7124260d2915570598d1.tar.xz
platform-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 'debuggerd')
-rw-r--r--debuggerd/libdebuggerd/tombstone.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp
index 725c42cad..a0ba81b68 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -417,7 +417,7 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p
417 "memory map (%zu entr%s):", 417 "memory map (%zu entr%s):",
418 map->size(), map->size() == 1 ? "y" : "ies"); 418 map->size(), map->size() == 1 ? "y" : "ies");
419 if (print_fault_address_marker) { 419 if (print_fault_address_marker) {
420 if (map->begin() != map->end() && addr < map->begin()->start) { 420 if (map->begin() != map->end() && addr < (*map->begin())->start) {
421 _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n", 421 _LOG(log, logtype::MAPS, "\n--->Fault address falls at %s before any mapped regions\n",
422 get_addr_string(addr).c_str()); 422 get_addr_string(addr).c_str());
423 print_fault_address_marker = false; 423 print_fault_address_marker = false;
@@ -429,49 +429,50 @@ static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, p
429 } 429 }
430 430
431 std::string line; 431 std::string line;
432 for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { 432 for (auto it = map->begin(); it != map->end(); ++it) {
433 const backtrace_map_t* entry = *it;
433 line = " "; 434 line = " ";
434 if (print_fault_address_marker) { 435 if (print_fault_address_marker) {
435 if (addr < it->start) { 436 if (addr < entry->start) {
436 _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n", 437 _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n",
437 get_addr_string(addr).c_str()); 438 get_addr_string(addr).c_str());
438 print_fault_address_marker = false; 439 print_fault_address_marker = false;
439 } else if (addr >= it->start && addr < it->end) { 440 } else if (addr >= entry->start && addr < entry->end) {
440 line = "--->"; 441 line = "--->";
441 print_fault_address_marker = false; 442 print_fault_address_marker = false;
442 } 443 }
443 } 444 }
444 line += get_addr_string(it->start) + '-' + get_addr_string(it->end - 1) + ' '; 445 line += get_addr_string(entry->start) + '-' + get_addr_string(entry->end - 1) + ' ';
445 if (it->flags & PROT_READ) { 446 if (entry->flags & PROT_READ) {
446 line += 'r'; 447 line += 'r';
447 } else { 448 } else {
448 line += '-'; 449 line += '-';
449 } 450 }
450 if (it->flags & PROT_WRITE) { 451 if (entry->flags & PROT_WRITE) {
451 line += 'w'; 452 line += 'w';
452 } else { 453 } else {
453 line += '-'; 454 line += '-';
454 } 455 }
455 if (it->flags & PROT_EXEC) { 456 if (entry->flags & PROT_EXEC) {
456 line += 'x'; 457 line += 'x';
457 } else { 458 } else {
458 line += '-'; 459 line += '-';
459 } 460 }
460 line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, it->offset, it->end - it->start); 461 line += StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, entry->offset, entry->end - entry->start);
461 bool space_needed = true; 462 bool space_needed = true;
462 if (it->name.length() > 0) { 463 if (entry->name.length() > 0) {
463 space_needed = false; 464 space_needed = false;
464 line += " " + it->name; 465 line += " " + entry->name;
465 std::string build_id; 466 std::string build_id;
466 if ((it->flags & PROT_READ) && elf_get_build_id(backtrace, it->start, &build_id)) { 467 if ((entry->flags & PROT_READ) && elf_get_build_id(backtrace, entry->start, &build_id)) {
467 line += " (BuildId: " + build_id + ")"; 468 line += " (BuildId: " + build_id + ")";
468 } 469 }
469 } 470 }
470 if (it->load_bias != 0) { 471 if (entry->load_bias != 0) {
471 if (space_needed) { 472 if (space_needed) {
472 line += ' '; 473 line += ' ';
473 } 474 }
474 line += StringPrintf(" (load bias 0x%" PRIxPTR ")", it->load_bias); 475 line += StringPrintf(" (load bias 0x%" PRIxPTR ")", entry->load_bias);
475 } 476 }
476 _LOG(log, logtype::MAPS, "%s\n", line.c_str()); 477 _LOG(log, logtype::MAPS, "%s\n", line.c_str());
477 } 478 }