summaryrefslogtreecommitdiffstats
path: root/libbacktrace
Commit message (Collapse)AuthorAgeFilesLines
* 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
* libBacktraceOffline: try both .debug_frame and .ARM.exidx on arm.Yabin Cui2017-12-106-52/+39
| | | | | | | | | | | | | Currently, libBacktraceOffline doesn't try .ARM.exidx if a function appears in .debug_frame. This make it can't unwind through functions appear in both .debug_frame and .ARM.exidx, but having dwarf instructions not accepted by libunwind. This patch fixes this by trying first .debug_frame then .ARM.exidx on arm. Bug: http://b/69383534 Test: run libbacktrace_test on arm. Change-Id: Ib95dd56d5cc123a20948e880b51b28ddc04b4a6e
* Make sure at least XX maps are created.Christopher Ferris2017-12-081-4/+5
| | | | | | | | Rather than expect exactly one set of maps, make sure there are at least XX number of maps. Test: Ran the 32 bit and 64 bit variants of the benchmarks. Change-Id: I34184eab3810e92e7f246aa810ddb18fab443c9a
* Merge "Add method to detect remote read function to use."Christopher Ferris2017-12-085-3/+210
|\
| * Add method to detect remote read function to use.Christopher Ferris2017-12-075-3/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The process_vm_read function is much faster than ptrace, but sometimes that will not work on a remote process. Modify the libunwindstack MemoryRemote object to figure out which one it can use. Wrote new unit test to verify this checking behavior. Modify libbacktrace so that the read from libunwind is used instead of using the default ptrace calls. Add some benchmarks to libbacktrace to compare the two different methods. Test: Ran unit tests libbacktrace/libunwindstack/debuggerd. Test: Ran debuggerd -b <SYSTEM_SERVER_PID> Test: Ran debuggerd -b <MEDIACODEC PID> Test: Ran debuggerd -b <RANDOM_PID> Test: Used crasher to create tombstones and verified stack data is Test: dumped properly. Change-Id: If75ca238289532dd8e1de430d569cabb2523380a
* | Merge "Add OWNERS."Elliott Hughes2017-12-071-0/+2
|\ \ | |/ |/|
| * Add OWNERS.Elliott Hughes2017-12-071-0/+2
| | | | | | | | | | | | Bug: N/A Test: N/A Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
* | Merge "Split arch data into separate files."Christopher Ferris2017-12-071-4/+2
|\ \
| * | Split arch data into separate files.Christopher Ferris2017-12-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an ArchEnum to express the arch of the Elf objects and Reg objects. Split out the regs code into per arch pieces and generic parts. Also, split out the header files for each arch. Do not break out the test code yet, there isn't enough and it doesn't help to maintain the tests. Test: libunwindstack/libbacktrace/debuggerd unit tests pass. Test: Running debuggerd -b <PIDS> yields valid data on bullhead. Change-Id: If61f6c730c9ff2249f986b41de8c4d62f7158325
* | | Merge "libBacktraceOffline: fix using debug frame with load bias."Yabin Cui2017-12-074-1/+58
|\ \ \ | |/ / |/| |
| * | libBacktraceOffline: fix using debug frame with load bias.Yabin Cui2017-12-064-1/+58
| |/ | | | | | | | | | | Bug: http://b/69383534 Test: run backtrace_test. Change-Id: I295d9dc8f3e5b628f179b2eaeac21fa93de130b0
* / Demand read load bias for a map.Christopher Ferris2017-12-056-23/+113
|/ | | | | | | | | | | | | | | | | | | 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
* Allow multiple threads sharing a map to unwind.Christopher Ferris2017-11-282-49/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Only skip frames for local unwinds.Christopher Ferris2017-11-022-6/+8
| | | | | | | | | | | | | | | When doing a remote unwind, and there is a crash in the unwind stack code or in libbacktrace, the old version would skip those frames. This makes debugging crashes in those libraries a bit difficult. Bug: 68820611 Test: Ran unit tests. Test: kill -3 a zygote process and verify no frames in Test: libunwindstack.so/libbacktrace.so. Test: Forced a crash in libunwindstack.so and verified the tombstone Test: contains the full crash. Change-Id: I297e5b3775c87c0dddf57ebb423bd72ba1baf193
* Switch libbacktrace new unwinder.Christopher Ferris2017-10-307-166/+7
| | | | | | | | | | | | | 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
* libbacktrace: remove exit time destructors.Josh Gao2017-10-262-1/+5
| | | | | | | | | | | | | If libbacktrace is statically linked into a library that interposes libc, exit-time destructors can lead to a segfault upon exit if static variables are used after their destruction. Remove the one use of a static variable (with inconsequential performance impact of less than 1us per backtrace), and enable -Wexit-time-destructors to ensure this stays fixed in the future. Test: mma Change-Id: Icdaf1cf1c1f166cf501d9ecd1983c44e4305f7e9
* libbacktrace: add benchmarks for Backtrace::Create, CreateNew.Josh Gao2017-10-262-0/+24
| | | | | Test: backtrace_benchmarks Change-Id: I80ba5adb31d446314060edd00149f09e14e6815e
* libbacktrace: let the benchmark library decide iteration count.Josh Gao2017-10-261-10/+7
| | | | | | | | | | | Manually doing 1000 iterations of the benchmark doesn't seem to add any significant amount of precision, and it makes the benchmark take forever and obfuscates the results. Just let benchmark figure out the time (with the option of using command line flags to increase the number of iterations). Test: backtrace_benchmarks64 Change-Id: I8de912c1b3c904755c8e2ac4175ff70176544ba3
* libbacktrace: correctly number frames when skipping.Josh Gao2017-10-262-1/+17
| | | | | | | | Correct for the number of skipped frames when unwinding with libunwindstack. Test: backtrace_test32 --gtest_filter="unwind_frame_skip_*" Change-Id: I9528977104fde3c4ec792a6db1ada24ed571b867
* Merge "Add an interface for stopping in certain maps."Christopher Ferris2017-10-252-4/+11
|\
| * Add an interface for stopping in certain maps.Christopher Ferris2017-10-242-4/+11
| | | | | | | | | | | | | | | | | | Also, change the std::set parameters to std::vector. As jmgao points out, a small std::set is not really the best choice for performance reasons. Test: All unit tests pass, enabled the new unwinder and did a kill -3 on Test: an android process. Change-Id: I81227d7b79a9b7cf1d54fb0e3331d3cf4d4d3c4f
* | Remove PauseTiming/ResumeTiming calls.Christopher Ferris2017-10-241-3/+0
|/ | | | | | | | | | These calls can only be used after the call to state.KeepRunning(), which handles the start/stop itself. Bug: 68170209 Test: Ran the benchmark and got reasonable results. Change-Id: Ie12eb3a983f6fe60c85d6dfc90957eedc16b5526
* Merge changes I8f33830f,Icd2b891b,I8736ff5c,Iae6e342aTreehugger Robot2017-10-245-28/+49
|\ | | | | | | | | | | | | | | * changes: libunwindstack: add method to iterate across registers. libbacktrace: expose BacktraceMap's unwindstack::Memory. libunwindstack: expose UnwindStackMap::GetFunctionName. libbacktrace: expose libunwindstack Unwind routine.
| * libbacktrace: expose BacktraceMap's unwindstack::Memory.Josh Gao2017-10-203-0/+10
| | | | | | | | | | Test: mma Change-Id: Icd2b891b121b90d55e3ac45037a59c24221a2496
| * libunwindstack: expose UnwindStackMap::GetFunctionName.Josh Gao2017-10-204-24/+28
| | | | | | | | | | Test: mma Change-Id: I8736ff5c2ed7c5e64eb68df5f4eccfed614612c7
| * libbacktrace: expose libunwindstack Unwind routine.Josh Gao2017-10-202-4/+11
| | | | | | | | | | Test: backtrace_test32/64 on hikey960 Change-Id: Iae6e342a8ffd13b4d5f76b39dd434c827f7a4d9e
* | Fix demangle of function names.Christopher Ferris2017-10-182-31/+32
|/ | | | | | | | Also move the Backtrace::CreateNew function into the same place as ::Create in preparation for the switch to the new unwinder as the base. Test: Verify that names are demangled properly. Change-Id: I6274cd43ea52210523e1e1ce23af5b22f62f4573
* Merge "libbacktrace is not directly available to vendors"Treehugger Robot2017-10-191-1/+1
|\
| * libbacktrace is not directly available to vendorsJiyong Park2017-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This lib becomes VNDK-SP just because libutils, which is VNDK-SP, is depending on it. Since libutils provide android::CallStack class for collecting and printing the callstack, there is no need for vendors to use the internal libbacktrace library. Thus the lib is marked as vendor_available: false. Bug: 64730695 Test: build 2017 pixel device Change-Id: I4ad91e3a6747bb0ae88d32cd26dfba32239c5b93
* | Use target.linux for all linux kernel based targetsDan Willemsen2017-10-161-31/+3
|/ | | | | | | | | | Now in Android.bp files, target.linux applies to all targets running a linux kernel (android, linux_glibc, linux_bionic). So common flags/sources/etc can be combined instead of copying them to each target. Test: m Change-Id: If7ad138ea1c540c160731f86b6ccc0daa5c69b83
* Merge "Update the Unwinder object and add tests."Christopher Ferris2017-10-051-120/+30
|\
| * Update the Unwinder object and add tests.Christopher Ferris2017-10-041-120/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: - Remove unused GetReturnAddressFromDefault function and tests. - Modify the unwinder to stop when a pc/sp in a device map. - Modify the unwinder to skip initial frames based on map names. - Unit tests that exercise all of the paths in the unwinder code. - Move the test Elf/ElfInterface objects into their own file. - Update RegsFake to handle extra cases. - Modify libbacktrace code to use this unwinder. The new unwinder does not implement the ignore frame functionality since this is not used very often and is better implemented using a skip frames in named libraries functionality. Test: Ran new unit tests, ran backtrace tests. Change-Id: Ifd65e9acd66ac5e2d0e04bd32a9ad870b54610ff
* | Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]Dan Willemsen2017-10-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the future, target.linux will apply to all targets running a linux kernel (android, linux_glibc, linux_bionic). So move all current users to the specific linux_glibc. There will be another cleanup pass later that will move some instances back to target.linux if the properties should be shared with target.android and target.linux_bionic, but target.linux needs to be removed first. Test: out/soong/build.ninja identical before/after Change-Id: I72ef34689c60ce547cab2898e354b027e335f6a1 Exempt-From-Owner-Approval: build system cleanup
* | Remove default librariesDan Willemsen2017-09-291-5/+0
| | | | | | | | | | | | | | | | | | | | libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on Linux. Test: m host Change-Id: I0b3c147b00a8ab6ff289b85db55b88836c905f5c Exempt-From-Owner-Approval: build system cleanup