summaryrefslogtreecommitdiffstats
path: root/libbacktrace
Commit message (Collapse)AuthorAgeFilesLines
* Fix pc/function name for signal handler frame.Christopher Ferris2019-04-153-0/+8
| | | | | | | | | | | | | | | | | 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 Merged-In: I3fb9b00c02d2cf2cc5911541bba0346c6f39b8e6 (cherry picked from commit d11ed86d65e870c5ea0d4918693376d474dbfe7d)
* Revert "Check for data races when reading JIT/DEX entries."David Srbecky2019-04-123-0/+32
| | | | | | | | | | | | This reverts commit 85b5fecec920208ec43b42488f08d4c2e5aaeda2. Reason for revert: Breaks ART tests, reverting to investigate. Exempt-From-Owner-Approval: Revert. (cherry picked from commit b9cc4fbb268652744c812415cb2e5d1fbe04879a) Bug: 130406806 Change-Id: I634e37060b97484d627fc544e3b406fd90aaa784
* Check for data races when reading JIT/DEX entries.David Srbecky2019-03-293-32/+0
| | | | | | | | | | | 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
* [libbacktrace] Modernize code to use override keywordYi Kong2019-03-251-1/+1
| | | | | | | Generated by clang-tidy. Test: m checkbuild Change-Id: I4506a9624002250117148413ea6990749cc1a4da
* Fix copy / move behaviour of Maps object.Florian Mayer2019-03-051-1/+1
| | | | | | | | | | | | | | | | | 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
* procinfo: Read inode number from /proc/<pid>/mapsSandeep Patil2019-02-111-17/+17
| | | | | | | | | | | | Adjust all callbacks to include the inode number as well. Fixes: 123532375 Test: libprocinfo_test Test: libdmabufinfo_test Test: libmeminfo_test Change-Id: I71fd75d90d5ee44585011c5ae654a1dd7e185458 Signed-off-by: Sandeep Patil <sspatil@google.com>
* Fix offsets when shared lib split across maps.Christopher Ferris2018-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | The linker was modified so that a shared library has a read-only map, then a read-execute map to represent the whole shared library. When backtraces are created, then the offsets are set incorrectly for backtraces. For example, all backtraces wind up with an offset now, and a shared library loaded out of an apk shows the wrong offset. Changes: - Fix the FormatFrame function which was putting the offset before the map name. - Refactor the Maps and MapInfo classes to keep track of the previous map instead of all maps. This was the only map that was ever needed. - Modify the unwind_for_offline tool to capture both the read-only and read-execute map when using the read-only segment option. Bug: 120981155 Test: Updated unit tests pass. Test: Unwinds on device don't show the offsets everywhere any more. Change-Id: I75b3727221be9c20316dfdcd7a1c6d242d7ce948
* [libbacktrace] Fix sign-compare warningYi Kong2018-12-171-1/+1
| | | | | | | static_cast GetThreadId result to pid_t. Test: m checkbuild Change-Id: Id3f541c1cb6cad9471e0cedf2ca49ce0fc38df38
* Verify that the elf matches the expected arch.Christopher Ferris2018-10-293-1/+18
| | | | | | | | | 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
* Always init gnu_debugdata interface if it exists.Christopher Ferris2018-10-231-1/+1
| | | | | | | | 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
* Implement support for linker rosegment option.Christopher Ferris2018-10-031-4/+0
| | | | | | | | | | | | | | | | | | | The rosegment linker option results in two maps containing the elf data existing. One is an execute map where the code lives, and the other is the read-only segment which contains the elf header information. If the file backing a shared library in memory is not readable, then the new code will attempt to find the read-only map that has the same name as the current execute segment, and that is at offest zero in the file. Add new unit tests for this functionality. Add the missing MapInfoCreateMemoryTest.cpp to the list of tests. Bug: 109657296 Test: Pass new unit tests. Test: All unit libbacktrace/libunwindstack tests pass with rosegment enabled. Change-Id: If8f69e4a067d77b3f2a7c31e2e5cd989a0702a8c
* Load libbacktrace_test.so explicitly.Christopher Ferris2018-10-036-260/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | This guarantees that the shared library is loaded separately. It allows this test to be run without depending on the shared library being somewhere in the system path since the library is now treated as a file to be dlopen'd. This also fixes some bugs in the deleted shared library test code. The previous test was passing when it was really failing. This new test no longer passes incorrectly. Specifically, the original testlib library only had a debug_frame on 32 bit host, which is not mapped into memory. Adding the exceptions option causes a full eh_frame to be generated. Due to the new dlopen code, also, switching to the new isolated test runner. Also, changing the memory leak checker to use mallinfo since the new unwinder allocates everything using the normal allocator. The use of the isolated runner causes the PSS checker to fail because processes come and go which changes the PSS distribution to the process doing the PSS check. Bug: 109876814 Test: All unit tests pass. Change-Id: I1b77a783979a8beaae0c0b12823267f363e07977
* Remove unused ART build dependenciesOrion Hodson2018-08-311-16/+0
| | | | | Test: m Change-Id: I58e7c6ecb74d565d109012cc23a38083a60f3c52
* bionic supplies PR_SET_VMA now.Elliott Hughes2018-08-221-6/+3
| | | | | | Bug: N/A Test: builds Change-Id: I8254711543cbf11bdf905ea441655ca1c1e82aac
* Revert^2 "Prepare to fail in RefBase destructor if count is untouched"Hans Boehm2018-08-081-0/+1
| | | | | | | | | | This reverts commit b9d0753d2ba88cc60947823e68bb3bed60268361. Reason for revert: Re-land with MacOS workaround. Test: Build (on Linux) and boot AOSP, with weak symbols enabled and disabled. Change-Id: I5150cd90367178f3b039761dca3bccc9c2987df1
* Revert "Prepare to fail in RefBase destructor if count is untouched"Hans Boehm2018-08-071-1/+0
| | | | | | | | This reverts commit 9d3146af22588e0c23e110be13a515f5347bf687. Reason for revert: It appears that weak symbols don't work as expected on MacOS, breaking the MacOS aapt build. Change-Id: Ica0955106485a7bf2e2c3f09ff7910e230eb4139
* Prepare to fail in RefBase destructor if count is untouchedHans Boehm2018-08-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move towards crashing if a normally configured RefBase object is destroyed without ever incrementing the reference count. We've been threatening to do this for a long time. The previously last known violation had been fixed. This also fixes stack trace printing from RefBase, which had previously been broken, and which we found necessary to track down further violations of this rule. Unfortunately, we found several more violations with the aid of that fix. After existing CLs are submitted, there are still some failures, but they are no longer numerous. Thus this CL doesn't actually crash in the event of a violation, but does log a verbose stack trace if it encounters one. Bugs have been filed against the remaining known RefBase client offenders. We plan to enable crashing on usage violations once those are fixed. The fix for the stack trace printing breakage unfortunately requires the use of weak symbols in order to avoid a circular build dependency. We expect to eventually replace this with execinfo.h functionality. Some random reformatting, driven by consistency with current formatting requirements. Add missing include to BacktraceMap.h. Bug: 79112958 Bug: 30292291 Test: Boot AOSP, Master Change-Id: I8151c54560c3b6f75ffc4c48229f0388a2066958
* [libutils] Modernize codebase by replacing NULL with nullptrYi Kong2018-07-161-4/+4
| | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I5e89ec8c42151875439d2656475a8739ab9cb7dc
* Move libbacktrace off cutils.Elliott Hughes2018-07-1111-91/+21
| | | | | | | | | | | There's still <cutils/atomic.h> in a test, but I don't understand why that isn't just std::atomic. Also add a shared tgkill wrapper to libbase. Bug: N/A Test: ran tests Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
* Merge "Build adbd for recovery"Treehugger Robot2018-05-251-2/+5
|\
| * Build adbd for recoveryJiyong Park2018-05-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | adbd (and its dependencies) are marked as recovery_available:true so that recovery version of the binary is built separately from the one for system partition. This allows us to stop copying the system version to the recovery partition and also opens up the way to enable shared libraries in the recovery partition. Then we can also build adbd as a dynamic executable. Bug: 79146551 Test: m -j adbd.recovery Change-Id: Ib95614c7435f9d0afc02a0c7d5ae1a94e439e32a
* | Change tests to use a temporary dir for files.Christopher Ferris2018-05-241-42/+45
|/ | | | | | | | | | | Avoid using hard-coded paths for generated files. This can cause problems if the tests are run in parallel. Also fix a potential race condition in the unwind_through_unreadable_elf_remote test. Test: Ran tests in parallel and normally. Change-Id: Ib42522de49499766a29bda5bfffe737b56715e3f
* Merge "Mark as recovery_available: true"Treehugger Robot2018-05-221-0/+1
|\
| * Mark as recovery_available: trueJiyong Park2018-05-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Libraries that are direct or indirect dependencies of modules installed to recovery partition (e.g. toybox) are marked as recovery_available: true. This allows a recovery variant of the lib is created when it is depended by other recovery or recovery_available modules. Bug: 67916654 Bug: 64960723 Test: m -j Change-Id: Ie59155c08890e96ce1893fa3687afcf763d7aea3
* | libprocinfo: add functions reading process map file.Yabin Cui2018-05-143-27/+20
|/ | | | | | | | | | | | | | | | Add test and benchmark. Also switch libbacktrace, libunwindstack, libmemunreachable to use libprocinfo for map file reading. The benchmark shows using libprocinfo speeds up map file reading in libbacktrace and libunwindstack 18% - 36% on walleye. Bug: http://b/79118393 Test: run procinfo_test. Test: run libunwindstack_test. Test: run libbacktrace_test. Test: run memunreachable_test. Change-Id: Icf281c352f4103fc8d4ba6732c5c07b943330ca1
* Merge "Remove unnecessary references to libunwind."Christopher Ferris2018-05-031-6/+0
|\
| * Remove unnecessary references to libunwind.Christopher Ferris2018-05-031-6/+0
| | | | | | | | | | | | | | | | Bug: 79209464 Test: Builds. Change-Id: I79f7b0123bc802e3e12d218e888c30dedf5204dc
* | Tell the build system about APCT's requirements.Elliott Hughes2018-05-031-0/+3
|/ | | | | | Bug: N/A Test: N/A Change-Id: I8a67e1ce5acc4142387878ba0bb542da0861e700
* Add test_suites lines.Elliott Hughes2018-04-271-0/+1
| | | | | | Bug: N/A Test: builds Change-Id: Ic5e2b9206bcfcb53c774989013b5db6aab462e42
* Add a MemoryOfflineBuffer object.Christopher Ferris2018-04-032-7/+9
| | | | | | | | | | | | | 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
* Method to avoid skipping frames for local unwinds.Christopher Ferris2018-03-233-3/+48
| | | | | | | | | | | | | In cases where there might be a crash in the unwind library itself, we need a method to avoid skipping these frames or we won't be able to see the actual crash. Added unit test for this behavior. Bug: 74121887 Test: Ran unit tests on host and target. Change-Id: I45825020c174016af39dd8ffdc67acb72a24ad4d
* Support a map that represents gdb jit elf data.Yabin Cui2018-03-211-0/+4
| | | | | | | | | | | | | Changes: - Add a new flag to the libbacktrace and libunwindstack map data. - Modify the unwinder to handle this map to use the raw pc when stepping. - Add new unit tests for this case. Bug: http://b/73127105 Test: Run simpleperf to unwind through jit symfiles. Test: Run new unit tests. Test: Run 137-cfi test on host. Change-Id: I10bc0410680accc6d35fe51e9f1098911f667e01
* Modify the offline handling interface.Christopher Ferris2018-02-235-17/+39
| | | | | | | | | | | - 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
* Add ability to skip function name resolution.Christopher Ferris2018-02-202-0/+9
| | | | | | | Bug: 73558129 Test: New unit tests pass. Change-Id: I3a6b17d2590aacb367ab3e3a51cc85be73ad64eb
* bpfmt.Elliott Hughes2018-02-161-7/+6
| | | | | | Bug: N/A Test: builds Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
* Fix darwin buildChristopher Tate2018-02-161-0/+3
| | | | | | | Darwin needs libbase too. Test: 'm' Change-Id: I9d50face92b7d5a4399dbcebd39d4062477b3a2c
* Include the map name when dumping memory around a register.Elliott Hughes2018-02-153-4/+15
| | | | | | Bug: http://b/19590178 Test: ran tests, ran crasher Change-Id: Ib9afa34c860d8732ef1943eb4decd0b7c8fb55fd
* Load dex files from ART-specific data structure.Christopher Ferris2018-02-021-1/+1
| | | | | | | | | | | | | 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
* Move dex pc frame creation into libunwindstack.Christopher Ferris2018-01-317-629/+23
| | | | | | | | 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
* Use new unwinder for offline in libbacktrace.Christopher Ferris2018-01-2926-1513/+424
| | | | | | | | | | | | | 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
* Fix frame numbering regression.Christopher Ferris2018-01-261-4/+4
| | | | | Test: All unit tests now pass. Change-Id: I280dfbbed3f835c826788b80ff4abb22bea7dc59
* Emit the frame for DEX PC before the frame for native PC.David Srbecky2018-01-251-15/+21
| | | | | | | | This results in more natural backtrace. Test: ART's 137-cfi test Change-Id: Ic472db2733a330f8dbc722887809273b77d9dfb5
* Add extra frame when dex_pc is non-zero.Christopher Ferris2018-01-238-5/+650
| | | | | | | | | | | | | | | 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
* Fix null ptr dereference if jit debug not enabled.Christopher Ferris2018-01-221-1/+3
| | | | | Test: No crash when a jit debug object is not instantiated. Change-Id: Ic4350a10258459ead7c5679ceb84372f1084f0ad
* Merge "Change all uintptr_t to uint64_t in API."Christopher Ferris2018-01-1923-599/+144
|\
| * Change all uintptr_t to uint64_t in API.Christopher Ferris2018-01-1823-599/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Add support for getting a dex pc.Christopher Ferris2018-01-172-0/+2
|/ | | | | | | | | | | | | | | | | | | | Changes: - Change the register type from int16_t to uint32_t for the location data and the Eval processing. This is because the special dex pc is > 65535. - Add the ability for Dwarf register location information to point to a register that is itself a Dwarf location register. - Add dex_pc to the frame information. - Modify the unwind tool to print the dex pc if non-zero. This does not implement the printing of the dex information in anything but the unwind tool. It's not the final form of this printing. Bug: 72070049 Test: Ran new unit tests. Test: Dumped stack while in interpreter running 137-cfi art test and Test: verified dex pc is set to non-zero. Change-Id: I6ce8a6b577fb4f92abacbd433b1f68977e272542
* Add ability to read jit gdb data.Christopher Ferris2018-01-123-0/+12
| | | | | | | | | | | | | | | | | | | | | | | 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
* libBacktraceOffline: improve unwinding callchains.Yabin Cui2017-12-187-32/+325
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Extend MAX_BACKTRACE_FRAMES to 256, as we can have callchains with length near 256 when recording Android applications. 2. .eh_frame and .ARM.exidx doesn't know how to unwind from instructions setting up or destroying stack frames. It can lead to wrong callchains, which may contain pcs outside executable mapping areas. Stop unwinding once this is detected. 3. Some CIE entries in .eh_frame/.debug_frame suggest unwinder reading personality routine from memory. However, that is not available in offline unwinding, and leads to ACCESS_MEM_FAILED error. Work around this by returning all zero data when failed to read data for some addresses. 4. Some libraries have empty .eh_frame_hdr but valid .eh_frame. Work around this by building eh_frame_hdr manually. 5. Prefer to use .debug_frame than .eh_frame. Because the former can unwind instructions setting up and destroying stack frames. Bug: http://b/69383534 Test: run backtrace_test. Test: run simpleperf on some apps. Change-Id: I62dddda3865dd567c6be150ce5527dc2d3516256
* libbacktrace: export offline unwinding failures.Yabin Cui2017-12-1510-68/+126
| | | | | | | | This is to help debugging different offline unwiding failures. Bug: http://b/69383534 Test: run backtrace_test. Change-Id: I5ed4837027a9f17d032925e97e9f5927161444b3