summaryrefslogtreecommitdiff
path: root/libunwindstack/LocalUnwinder.cpp
AgeCommit message (Collapse)Author
2021-10-28Maps contains shared_ptr MapInfo objects now.Christopher Ferris
In order to make it easier to change the map data, make the individual MapInfo objects shared_ptr objects. This also changes the LocalUpdatableMaps object so that all of the reparsing is in the object itself. This means this object can be used with the normal unwinder unchanged and I can delete the LocalUnwinder completely in a future cl. Add a method to share a maps object between ThreadUnwinder objects. Add new unit tests to cover the changes. Bug: 120606663 Test: Unit tests pass. Test: Did a performance run before and after to verify no Test: performance issues. Change-Id: I074dc925c8e5ff8b3d75779052aefe4801b2c7bf Merged-In: I074dc925c8e5ff8b3d75779052aefe4801b2c7bf (cherry picked from commit bf98d2a784c8181ba508f978e123459e9a8c610b)
2021-05-13MapInfo: Add get accessors for the fieldsDavid Srbecky
Test: libunwindstack_unit_test Change-Id: I070f81301763abd36d0eb704e4ec319a3d80c394
2021-05-13MapInfo: Add "_" suffix to fields.David Srbecky
Follow the naming convention for private fields. (the accessors will be added in followup CL) Test: libunwindstack_unit_test Change-Id: I597844977372c6d5d34a18687392b23cc411f635
2021-04-15Add a MemoryThreadCache object.Christopher Ferris
The new object will work with all local unwinds, and speeds up these unwinds by at least 2x. This means that the same process memory object can be shared to unwind any thread in the current process without worry about the cache being stale. Modified the normal cached process memory to be thread safe. It's unlikely multiple threads will try and use it at the same time, but this makes it consistent with all process memory objects. Added/modified benchmarks for cached unwinds. Added remote unwind and thread benchmarks. Since some of the benchmarks were caching a bit too much, the new benchmarks show up as slightly slower than before, but everything is more accurate than before. Specifically, using using the normal cached object for a local unwind, it will potentially cache data from a previous run which might change between unwinds. Added new unit tests to verify that unwinds of multiple threads at once work using the new object. This change does clear the cache before each unwind which changes some of the unwind benchmarks. However, it is almost never correct for the cache to be reused when starting a new unwind. We can add support for caching between unwinds if there is a real use of this. Test: All unit tests pass. Test: Ran benchmarks on device. Change-Id: I8bc464cdd27811c1ee6c1e0c004a8bc9ff63a2d0
2021-03-31Allow Unwinder object to be used for local unwinds.Christopher Ferris
This is the first step to delete the LocalUnwinder object, which does not operate the same as the Unwinder object. This moves all of the updatable part of a local unwind into the LocalUpdatableMaps object so that it is not necessary to have the LocalUnwinder object. Added unit tests to verify the new use of LocalUpdatableMaps works when the threads are created after the map data is read. Test: libbacktrace unit tests, libunwindstack unit tests Change-Id: I72361d8d2fd9ae7a994c1a391a80d7262bf6e323
2021-03-23Add shared symbol name cache.David Srbecky
The symbol name related reads and memory operations take about half of the symbol name reading cost now. This CL adds ref-counted read-only shared string cache, which essentially eliminates all of the costs. BM_symbol_find_single_many_times is >10% faster on ARM. (which is 20% if we exclude the fixed ELF loading cost) Real-world profiles seem even more encouraging. The extra memory cost is negligible (by definition, a small fraction of the decompressed mini-debug-info: specifically, the subset of strtab for hit functions). Furthermore, this effectively dedups strings when consecutive unwinds hit similar set of functions. (perfetto might keep several unwind results live) Test: m libunwindstack_unit_test Change-Id: I5cf600bb972fdb9d0f3a57ed0997bead2efa38f4
2020-10-02libunwindstack: Support signal frame CIEs.Ryan Prichard
Mark a CIE with a S in its augmentation string as signal frame. This allows the code to properly handle signal frame data if none of the signal frame pattern matchers work. For a signal frame, DwarfSectionImpl<AddressType>::Eval needs to continue the unwinding even if PC is zero. A zero PC means that the program has crashed, and we should try to recover the real PC using the return address on the stack or LR. This behavior is tested by UnwindOffline.signal_{x86,x86_64}, which modify the libc.so files so that the signal frame pattern matcher fails and the CIE/FDE data is used instead. Test: libunwindstack_test Change-Id: I4655b070028fd984345311a5e743796f8c30ed36
2020-03-19Make GetPcAdjustment a free function.Peter Collingbourne
We're now using it in contexts that don't have all of the registers available, such as GWP-ASan and soon MTE, so it doesn't make sense to have it be a member function of Regs. Bug: 135772972 Change-Id: I18b104ea0adb78588d7e475d0624cefc701ba52c
2019-04-12Fix pc/function name for signal handler frame.Christopher Ferris
This refactors the step function slightly to split it up into distinct pieces since the code needs to handle a signal handler versus normal step slightly differently. Add a new error for an invalid elf. Modify libbacktrace code to handle new error code. Bug: 130302288 Test: libbacktrace/libunwindstack unit tests. Change-Id: I3fb9b00c02d2cf2cc5911541bba0346c6f39b8e6
2018-10-29Verify that the elf matches the expected arch.Christopher Ferris
To avoid a case where a malicious app might try and trick the system to create an elf and register object that mismatches, always verify that they are the same arch. Test: Ran unit tests. Change-Id: I66978e9e02f8e4f396856912e7019528ead4838e
2018-10-23Always init gnu_debugdata interface if it exists.Christopher Ferris
Every real call always sets the value to true to init the gnu_debugdata interface, so remove this parameter. Test: Builds, unit tests pass. Change-Id: I07fb3adbbd5b65b51c0dc7608561e820a5095051
2018-05-23Add a specialized LocalUnwinder object.Christopher Ferris
This object is for doing many local unwinds across different threads at any point during a program's execution. Also add LocalUpdatableMaps that will re-read the maps data under certain circumstances. This first version does not support jit or dex pc data. Bug: 74361929 Test: Ran unit tests. Change-Id: I790662366d3fed677f31b3288182950c494de9ad