summaryrefslogtreecommitdiff
path: root/libbacktrace/UnwindStackMap.cpp
AgeCommit message (Collapse)Author
2020-10-16Remove libprocinfo, libbacktrace, libunwindstackBaligh Uddin
These projects have moved to a different location. platform/system/core [libprocinfo] -> platform/system/libprocinfo platform/system/core [libbacktrace] -> platform/system/unwinding [libbacktrace] platform/system/core [libunwindstack] -> platform/system/unwinding [libunwindstack] BUG: 163786882 Test: Local build + TH Change-Id: Id6d278d917236df0ffd40b5c32593856e112cb5b
2019-06-11Internalize subclasses of MemoryCasey Dahlin
There are many subclasses of the Memory class and the overwhelming majority of them don't need to be exposed externally. We move all of them to internal headers except MemoryOfflineBuffer, which moves to a separate header. This dramatically reduces the exposed API surface and makes the code more modular. Also, remove the Offline code from libbacktrace. It's not used any where. Test: Unit tests pass, clean tree still builds Change-Id: I55dacdf080daba0bfe65c1ad53a4b326bb482e83
2019-04-05Revert "Check for data races when reading JIT/DEX entries."David Srbecky
This reverts commit 85b5fecec920208ec43b42488f08d4c2e5aaeda2. Reason for revert: Breaks ART tests, reverting to investigate. Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
2019-03-29Check for data races when reading JIT/DEX entries.David Srbecky
Update the entries only when the list is modified by the runtime. Check that the list wasn't concurrently modified when being read. Bug: 124287208 Test: libunwindstack_test Test: art/test.py -b --host -r -t 137-cfi Change-Id: I87ba70322053a01b3d5be1fdf6310e1dc21bb084
2019-03-05Fix copy / move behaviour of Maps object.Florian Mayer
Currently, moving or copying a Maps object leads to double free of MapInfo. Even moving a Maps object did not prevent this, as after a move the object only has to be in an "unspecified but valid state", which can be the original state for a vector of raw pointers (but not for a vector of unique_ptrs). Changing to unique_ptrs is the most failsafe way to make sure we never accidentally destruct MapInfo. Test: atest libuwindstack_test Failed LocalUnwinderTest#unwind_after_dlopen which also fails at master. Change-Id: Id1c9739b334da5c1ba532fd55366e115940a66d3
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-04-03Add a MemoryOfflineBuffer object.Christopher Ferris
Use this for offline stack data so that it's not necessary to copy any data around. Add unit tests for the new object. Bug: 77258731 Bug: 74354410 Test: Ran libunwindstack/libbacktrace unit tests. Change-Id: I9b0f25d9520c96e64aedef5f295423c60ddb3488
2018-02-23Modify the offline handling interface.Christopher Ferris
- Add a new function Backtrace::UnwindOffline that takes the stack data. - Modify BacktraceMap::CreateOffline so it doesn't take the stack data. This makes it easier to reuse the map object created this way. Reusing the map object increases simpleperf speed (unwinds per second) by 50%. Test: backtrace_test libunwindstack_test Change-Id: I90cfbae9e50d95d8a0e3cd394b33ba36d65d45f7
2018-02-02Load dex files from ART-specific data structure.Christopher Ferris
Fixes cdex which was recently changed to have shared data section, which means the DEX PC cannot be used to find the right symbol, as the bytecode is no longer within the dex file, and in-fact, we might have to scan multiple dex files to find the method. Bug: 72520014 Test: testrunner.py --host --cdex-none -t 137 Test: testrunner.py --host --cdex-fast -t 137 Test: All unit tests pass. Change-Id: I80265d05ad69dd9cefbe3f8a75e4cd349002af5e
2018-01-31Move dex pc frame creation into libunwindstack.Christopher Ferris
Test: Compiles, all unit tests pass. Test: Ran 137-cfi art test in interpreter and verified interpreter Test: frames still show up. Change-Id: Icea90194986faa733a873e8cf467fc2513eb5573
2018-01-29Use new unwinder for offline in libbacktrace.Christopher Ferris
libbbacktrace changes: - Completely rewrite the BacktraceOffline class to use the new unwinder. - Modify the test data to save ucontext_t data instead of unw_context data. - Convert the previous tests from unw_context data to ucontext_t data. Bug: 65682279 Test: New unit tests pass in libunwindstack. Test: All offline tests continue to pass. Change-Id: I540345c304b20199d46deeb0349a0638a0f3ab2f
2018-01-23Add extra frame when dex_pc is non-zero.Christopher Ferris
Use the art dex file library to read the dex data. Add unit tests for the UnwindDexFile code. Bug: 72070049 Test: All unit tests continue to pass. Test: Dumped the backtrace of the 137-cfi test while running in interpreter Test: mode and verified that the stack trace is correct. Did this on host Test: and for arm/arm64. Change-Id: Ia6f343318c5dd6968a954015a7d59fdf101575b0
2018-01-18Change all uintptr_t to uint64_t in API.Christopher Ferris
In order to support the offline unwinding properly, get rid of the usage of non-fixed type uintptr_t from all API calls. In addition, completely remove the old local and remote unwinding code that used libunwind. The next step will be to move the offline unwinding to the new unwinder. Bug: 65682279 Test: Ran unit tests for libbacktrace/debuggerd. Test: Ran debuggerd -b on a few arm and arm64 processes. Test: Ran crasher and crasher64 and verified tombstones look correct. Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33
2018-01-12Add ability to read jit gdb data.Christopher Ferris
Changes: - New JitDebug class to handle all of the jit gdb interface. - Add unit tests for all, along with new offline test using debug data. - Add new Memory type called MemoryOfflineParts that has multiple MemoryOffline objects to support the offline test. - Update the tools to use the JitDebug object. - Modify libbacktrace to use the JitDebug, but only looking in libart.so and libartd.so. - Change the Format32Bits to Is32Bit since it's more accurate and I use it in a different context where original name didn't make sense. - Add a new function to find global variables in an elf file (GetGlobalVariable). - Add a new function to determine if a pc is valid for this elf (IsValidPc). Bug: 68396769 Test: Ran new unit tests. Added new offline test that uses jit debug data. Test: Ran art test that generates jit data and verified a crash unwinds Test: through the jit data. Change-Id: I6e7ee2f5bab2242028a06feece156dff21c0a974
2017-12-05Demand read load bias for a map.Christopher Ferris
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
2017-11-28Allow multiple threads sharing a map to unwind.Christopher Ferris
Add a mutex in MapInfo, and a mutex in Elf. Lock the creation of an Elf file using the MapInfo mutex, and lock when calling Step, GetFunctionName, or GetSoname since they can modify information in the object. It might be beneficial to use a fine grained lock in the future. Change the Maps object to contain a vector of MapInfo pointers rather than the total objects. This avoids copying this data around. Add a test to libbacktrace to verify that sharing a map while doing unwinds in different threads works. Add concurrency tests in libunwindstack to verify the locking works. Add always inline to the RegsGetLocal arm and aarch64 functions. I had a case where clang did not inline the code, so make sure this is specified. Bug: 68813077 Test: New unit tests to cover the case. Passes all unit tests. Test: Ran a monkey test while dumping bugreports and verified that Test: no crashes in libunwind. Test: Remove the locking and verified that all of the concurrenty tests fail. Change-Id: I769e728c676f6bdae9e64ce4cdc03b6749beae03
2017-10-30Switch libbacktrace new unwinder.Christopher Ferris
Update the backtrace leak tests to share a map since this is the most common way it will be used, and it runs much faster. Remove the CreateNew functions, and references to them. Remove benchmarks of CreateNew functions. Test: Builds, ran new unit tests, ran art tests. Change-Id: I4a25a412f1a74c6d43aebbebbf32ead20ead8f94
2017-10-20libbacktrace: expose BacktraceMap's unwindstack::Memory.Josh Gao
Test: mma Change-Id: Icd2b891b121b90d55e3ac45037a59c24221a2496
2017-10-20libunwindstack: expose UnwindStackMap::GetFunctionName.Josh Gao
Test: mma Change-Id: I8736ff5c2ed7c5e64eb68df5f4eccfed614612c7
2017-09-05Add a method to share the process memory object.Christopher Ferris
New function to create the process memory object. This allows for a future where different remote process memory objects could be created depending on the way remote memory can be created. Even different local memory objects that access memory without doing any checks. It also allows MemoryRange objects to share one single process memory object and could help if the process memory object caches data. Small changes to MapInfo::CreateMemory to when some errors are detected. - Always check if the map is a device map, instead of only if the name is not empty. - Check if a memory map is readable before creating the memory from process memory. Bug: 23762183 Test: Ran unit tests, unwound on device using the new code. Change-Id: I12a93c2dc19639689a528ec41c67bfac74d431b3
2017-08-03Add support for the new unwind method.Christopher Ferris
Also add a comment to the GetElf function to indicate that it never returns nullptr. Also needed to add this library to the a million and one places that the vndk has hard-coded this data. Bug: 23762183 Test: Built, nothing uses the new code. Test: However, I did run backtrace_test using this code, and all tests pass. Change-Id: Ib270665dcb7a7607075e36d88be76dbde6e2faa8 (cherry picked from commit dc4104b720c7fd2014ccfa9fa621d02df58a43c4)
2017-08-02Revert "Add support for the new unwind method."Christopher Ferris
This reverts commit 5b460d13a4c383fa6c9a416d64502430ab065209. Reason for revert: Strange sailfish boot problem. Change-Id: Ibde9375405cca4343c262335647dac120aab4d73
2017-07-31Add support for the new unwind method.Christopher Ferris
Also add a comment to the GetElf function to indicate that it never returns nullptr. Bug: 23762183 Test: Built, nothing uses the new code. Test: However, I did run backtrace_test using this code, and all tests pass. Change-Id: I252b9c2497e2d3d94347dd6e506170bf50cbfe16