From 66ed93eb73b04e7e6a91671912d0845c36b781f0 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Wed, 14 Mar 2018 21:30:25 +0000 Subject: Cache DWARF location rules for a given pc. Decoding the DWARF opcodes is expensive so make sure we cache it. This speeds unwinding in simpleperf by over a factor of 3x. Add unit tests for this new behavior. Bug: 77258731 Test: libbacktrace/libunwindstack unit tests on host and target. Test: Ran debuggerd -b on various processes on target. Change-Id: Ia516c0fa5d3e5f76746190bb4b6fdf49fd1c9388 --- libunwindstack/include/unwindstack/DwarfLocation.h | 10 +++++++++- libunwindstack/include/unwindstack/DwarfSection.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'libunwindstack/include') diff --git a/libunwindstack/include/unwindstack/DwarfLocation.h b/libunwindstack/include/unwindstack/DwarfLocation.h index 0881182..3d50ccf 100644 --- a/libunwindstack/include/unwindstack/DwarfLocation.h +++ b/libunwindstack/include/unwindstack/DwarfLocation.h @@ -23,6 +23,8 @@ namespace unwindstack { +struct DwarfCie; + enum DwarfLocationEnum : uint8_t { DWARF_LOCATION_INVALID = 0, DWARF_LOCATION_UNDEFINED, @@ -38,7 +40,13 @@ struct DwarfLocation { uint64_t values[2]; }; -typedef std::unordered_map dwarf_loc_regs_t; +struct DwarfLocations : public std::unordered_map { + const DwarfCie* cie; + // The range of PCs where the locations are valid (end is exclusive). + uint64_t pc_start = 0; + uint64_t pc_end = 0; +}; +typedef DwarfLocations dwarf_loc_regs_t; } // namespace unwindstack diff --git a/libunwindstack/include/unwindstack/DwarfSection.h b/libunwindstack/include/unwindstack/DwarfSection.h index da91fd0..209c54a 100644 --- a/libunwindstack/include/unwindstack/DwarfSection.h +++ b/libunwindstack/include/unwindstack/DwarfSection.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -112,6 +113,7 @@ class DwarfSection { std::unordered_map fde_entries_; std::unordered_map cie_entries_; std::unordered_map cie_loc_regs_; + std::map loc_regs_; // Single row indexed by pc_end. }; template -- cgit v1.2.3