summaryrefslogtreecommitdiff
path: root/libunwindstack/include
Commit message (Collapse)AuthorAgeFilesLines
* Remove libprocinfo, libbacktrace, libunwindstackBaligh Uddin2020-10-1644-3414/+0
| | | | | | | | | | | 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
* libunwindstack: Support signal frame CIEs.Ryan Prichard2020-10-024-3/+6
| | | | | | | | | | | | | | | | | 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
* Add arch member into Unwinder object.Christopher Ferris2020-09-245-22/+106
| | | | | | | | | | | | | | | This simplifies some of the logic and removes the need to pass an Arch value to functions that should already know about the arch it is operating on. Includes fixes for debuggerd/libbacktrace. Added new unit tests to cover new cases. Test: All unit tests pass. Test: Faked unwinder failing to verify debuggerd error messages display Test: properly in backtrace and tombstone. Change-Id: I439fcae0695befcfb1cb4c0a786cc74949d33425
* libunwindstack: expose static version of BuildFrameFromPcOnly.Josh Gao2020-08-281-0/+2
| | | | | | Bug: http://b/165206592 Test: unit tests and treehugger Change-Id: Ic357ee6160281c5986570de5536b3247b231bc6f
* Set warning for dex pc not in map.Florian Mayer2020-08-132-0/+9
| | | | | | | | | This way, the profilers will know they have to reparse maps. Bug: 163130539 Test: Verified updated unit tests pass. Change-Id: I88a801ffdda12811eab5e4833dcf472f2d75c09a
* libunwindstack: support for Armv8.3-A Pointer AuthenticationTamas Petz2020-07-145-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for handling return addresses signed with pointer authentication. It simply strips the authentication code without verifying its correctness, and thus works with both A and B keys and through key-change boundaries. Additons: * DW_CFA_AARCH64_negate_ra_state: new CFA operation. * RA_SIGN_STATE: new pseudo register. * Pass the arch to DwarfCfa so that the new op is only executed on aarch64. The stripping uses the xpaclri instruction. This is a hint space instruction which is compatible with pre Armv8.3-A devices. For cases where it cannot be used, a mask can be set instead. Test: libunwindstack_test Without this patch all UnwindTest.* testcases should fail if compiled with Pointer Authentication. The tests should be executed with both -mbranch-protection=pac-ret and pac-ret+leaf flags so that either some or all functions have pointer authentication instructions. Change-Id: Id7c3f1d0e2fc7fccb19bd1430826264405a9df7c
* Merge "Optimize Memory::ReadString"Christopher Ferris2020-04-201-1/+1
|\
| * Optimize Memory::ReadStringDavid Srbecky2020-04-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function is responsible for majority of CPU time in prefetto. Reduce the number of memory reads (don't read strings byte-by-byte). Update all calls of ReadString to include the third parameter to have a max read. Add an Elf creation benchmark since this function is on the elf creation path. Test: libunwindstack_unit_test Change-Id: Ia36e1f1a5ba76c9e9f13c43fb9e3691dde7897f2
* | libunwindstack: Add Memory::ReadTag() function for reading memory tags.Peter Collingbourne2020-04-161-0/+1
|/ | | | | | | | | | This uses an experimental Linux kernel API for reading the tags across processes using ptrace. Bug: 135772972 Test: Unit tests pass. Change-Id: Ib1a09d9219166011de80cf250b756bb8a4bcdb0a
* Avoid re-mapping dex file that's in local memory.Sim Sun2020-04-071-0/+2
| | | | | | | | | | | | | | | If the Dex file we're trying to examine is already within the unwinder's address space, we don't need to load it from disk or copy it across processes. This avoids using up virtual address space to map in dex files, and also should be a bit faster to read since it won't go out to the file. Patch by Chris Sarbora Test: Ran new unit tests. Test: Ran 137-cfi art test. Change-Id: I949457856f051cca11b9020e9da3a41bbf6e5c8e
* Move PC-only unwind frame generation to libunwindstack.Mitch Phillips2020-03-261-0/+7
| | | | | | | | | | | | | GWP-ASan uses frame-pointer based unwinding internally on allocation/deallocation to collect stack traces that are used when crashes are reported. This should be generic, so pull it out into libunwindstack so it can be used by MTE as well. Bug: 152412331 Test: atest debuggerd_test Change-Id: I27b32263aac63446f5fe398af108676b70cd3971
* Make GetPcAdjustment a free function.Peter Collingbourne2020-03-197-14/+2
| | | | | | | | | 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
* Remove mips build.Elliott Hughes2020-03-061-1/+1
| | | | | | | | | | | For now this leaves the ability to cross-unwind a mips process, but we should probably clean that up too. We need to remove the build remnants so that we can clean up the build system itself (otherwise it sees us talking about an architecture it doesn't know about, and assumes that something's wrong). Test: treehugger Change-Id: I2862c630cec95dbdd474e34c3568d0e1a6d44b16
* Properly handle empty map after read-only map.Christopher Ferris2020-01-221-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently, the maps for an elf in memory might show up looking like: f0000-f1000 0 r-- /system/lib/libc.so f1000-f2000 0 --- f2000-f3000 1000 r-x /system/lib/libc.so f3000-f4000 2000 rw- /system/lib/libc.so The problem is that there is logic in the code that assumed that the map before the execute map must be the read-only map. In the case above, this is not true. Add a new prev_real_map that will point to the previous map that is not one of these empty maps. This will fix the backtraces that look like this: #00 pc 0000000000050d58 /apex/com.android.runtime/lib64/bionic/libc.so!libc.so (offset 0x50000) (syscall+24) (BuildId: 5252408bf30e395d49ee270b54c77ca4) To get rid of the !libc.so and the offset value, which is not correct. Added new unit tests to verify this. Added new offline test which an empty map between read-only and execute map. Before this change, the backtraces had lines like libc.so!libc.so (offset XXX) would be present. Bug: 148075852 Test: Ran unit tests. Change-Id: Ie04bfc96b8f91ed885cb1e655cf1e346efe48a45
* Use elf offset in signal step check.Christopher Ferris2019-12-047-7/+7
| | | | | | | | | | | | | | | | | | | | The function StepIfSignalHandler assumed that the rel_pc passed to it was actually an elf offset. A new version of clang created a libc.so that has a load bias, so tests unwinding through a signal handler would fail on arm. On other ABIs, there is unwind information that could be used instead, so the unwind still worked. The fix is to subtract the load bias from the rel_pc to get an elf offset to pass to the Register StepIfSignalHandler functions. Change all of the Register funtions to make it clear what the first parameter means. Add a unit test for this new code. Also, add an offline test for this case. Bug: 145683525 Test: Ran unit tests using the new clang and the old clang. Change-Id: I3e249653b79bcad6d3a56411a7911fde4888e9d6
* Fix support finding global variables.Christopher Ferris2019-12-033-6/+13
| | | | | | | | | | | | | | The code was not properly getting the variable addresses and using the offset and address fields of the .data section. Fix all of that, and update the tests. Bug: 145162678 Test: Unit tests pass. Test: ./art/test/run-test --dex2oat-jobs 4 --host --prebuild --compact-dex-level fast --jit --no-relocate --runtime-option -Xcheck:jni 137-cfi Test: ./art/test/testrunner/testrunner.py -t 137 --host Change-Id: Ic61c4487334fd2273cda9c56eb1a3b525a03edb7
* Move the dexfile support to implementation.Christopher Ferris2019-11-201-6/+0
| | | | | | | | | | | | | | No longer require that NO_LIBDEXFILE_SUPPORT be defined or not defined when including the header files. Move all of the different behavior to the implementation, and keep all of the classes the exact same whether dexfiles are supported or not. Bug: 144470551 Test: Ran libunwindstack unit tests, libbacktrace unit tests, and Test: debuggerd unit tests. Test: Ran host art 137-cfi tests. Change-Id: I4a04cfbc5d4f1bf765ef154881046c85057006c8
* Merge "Include PSTATE in tombstones on arm64."Treehugger Robot2019-11-191-0/+1
|\
| * Include PSTATE in tombstones on arm64.Peter Collingbourne2019-11-181-0/+1
| | | | | | | | | | | | | | | | | | A thread's PSTATE can sometimes be critical for understanding a crash, especially with MTE and other new features that store per-thread state in PSTATE. Bug: 135772972 Change-Id: I1bee25bffe7eea395f04b6449dc9227298cf866e
* | Fix potential bad info in eh_frame_hdr.Christopher Ferris2019-10-291-33/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to a bug, an elf can have FDEs with a length of zero, while still having another FDE for the same pc with a non-zero length. The eh_frame_hdr can sometimes point to the zero length FDE, but it should have pointed to the non-zero length FDE. In order to fix this, if the eh_frame_hdr points at the zero length FDE then try and find the real FDE directly from eh_frame. The change cleans up and removes unused variables from DwarfEhFrameWithHdr and changes the objects so that all of the DwarfSection objects and DwarfEhFrameWithHdr object inherit from the same class. Add new unit tests to verify this functionality. Bug: 142483624 Test: Unit tests all pass. Change-Id: I128a916e3ba378931de7d44ee15e57e24d4073df
* | Handle when bias is different in elf headers.Christopher Ferris2019-10-085-27/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original code assumed that the load bias in the program headers would be exactly the same as in eh_frame/eh_frame_hdr/debug_frame. This isn't guaranteed, so add a section bias for use when creating a DwarfSection. In addtion, make the load bias and section bias a signed value. There is no reason that this value needs to be positive, so don't force it to be. Add a new offline test that has a different load bias in eh_frame than in the executable load. Add additional unit tests to verify the load bias values are set properly. Clean up the tests in ElfInterfaceTest, making all tests names follow the same convention. Bug: 141888859 Bug: 142094469 Test: New units and old unit tests pass on host and taimen. Change-Id: Ib878123ab5545f0f315c749cfe0d27b012d873ee
* | Further document MapInfo::elf_offset.Florian Mayer2019-09-301-2/+5
| | | | | | | | Change-Id: I291d8a61cb400fdf5795a85c4e9a65406124717e
* | Fix LocalUpdatableMapsDavid Srbecky2019-09-161-1/+1
| | | | | | | | | | | | | | | | | | | | Avoid accessing nullptr of already deleted entry. Add new unit tests that pass with the fix and fail without. Test: fixes unwinding in ART gcstress tests Test: All unit tests pass. Change-Id: Ideb00e2adc899904dd6aeb5dad3fb6fad150322d
* | Add test of undefined return address.Christopher Ferris2019-08-301-3/+3
|/ | | | | | | | | | | | | Add a specific test that __libc_init is the last frame in a stack when run on device. In addition, it verifies that the return address register is marked as undefined given the unwind. Bug: 140008396 Test: New unit test passes on arm/arm64 (taimen device). Test: New unit test passes on x86 (cuttlefish). Test: New unit test passes on x86_64 (modified bionic/tests/run-on-host.sh) Change-Id: Iefc151a7dbf52ab083c2bb78bad3d38b4e9e1254
* Internalize subclasses of MemoryCasey Dahlin2019-06-112-156/+5
| | | | | | | | | | | | | 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
* Add indicator that an elf is memory backed.Christopher Ferris2019-04-182-0/+8
| | | | | | | | | | | | | | | | Modify the unwinder library to indicate that at least one of the stack frames contains an elf file that is unreadable. Modify debuggerd to display a note about the unreadable frame and a possible way to fix it. Bug: 129769339 Test: New unit tests pass. Test: Ran an app that crashes and has an unreadable file and verified the Test: message is displayed. Then setenforce 0 and verify the message is Test: not displayed. Change-Id: Ibc4fe1d117e9b5840290454e90914ddc698d3cc2
* Fix pc/function name for signal handler frame.Christopher Ferris2019-04-123-4/+5
| | | | | | | | | | | | | | | 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
* Revert "Check for data races when reading JIT/DEX entries."David Srbecky2019-04-055-34/+131
| | | | | | | | This reverts commit 85b5fecec920208ec43b42488f08d4c2e5aaeda2. Reason for revert: Breaks ART tests, reverting to investigate. Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
* Check for data races when reading JIT/DEX entries.David Srbecky2019-03-295-131/+34
| | | | | | | | | | | 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
* Add BuildId to frame information.Christopher Ferris2019-03-261-1/+4
| | | | | | | | | | | Update debuggerd to print BuildId information by default. Bug: 120975492 Test: New unit tests pass. Test: debuggerd -b <PID> shows build id information. Test: tombstones include build id information. Change-Id: I019b031113d0b77385516223c63455b868924440
* Add support for displaying soname in an apk.Christopher Ferris2019-03-133-9/+11
| | | | | | | | | | | | | | | Changes: - Change GetSoname to always returns a std::string. - Added new unit tests for the soname printing. - Modify the GetElf() function to save the same elf when we see rosegment linkers that split the read-only and read-write across a map. This avoids creating multiple elf objects for each map. - Fixed a few offline unwind tests. Bug: 29218999 Test: Unit tests pass. Change-Id: Iad7c38b5c2957a8c5fd4ba94ebec335bafcad57d
* Add missing override keywordCasey Dahlin2019-03-111-1/+1
| | | | | | | Fuchsia builds with Clang, and it's a bit pickier about always using override when it's appropriate. Test: None
* Add unistd.h to includes in Regs.hCasey Dahlin2019-03-081-0/+1
| | | | | | | This is required to use pid_t, but by luck nobody noticed its absence until the Fuchsia build. Test: Code now builds inside Fuchsia
* Fix copy / move behaviour of Maps object.Florian Mayer2019-03-051-7/+16
| | | | | | | | | | | | | | | | | 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
* Merge "Allow to move frames out of Unwinder."Treehugger Robot2019-01-291-0/+6
|\
| * Allow to move frames out of Unwinder.Florian Mayer2019-01-281-0/+6
| | | | | | | | | | | | This saves a copy for every unwind we do in heapprofd. Change-Id: Ife7aa1ce68831729d96ccd4c3e54ca531f98b6bc
* | Add GetPrintableBuildID().Christopher Ferris2019-01-251-0/+4
| | | | | | | | | | | | | | | | | | | | The GetBuildID() function returns the raw build id data, so add a function to get the printable hex version of the data. Bug: 120606663 Test: New unit tests pass. Change-Id: Ia5aefc97457efb08bbd30ea96cbb2d47ae59f954
* | Fix memory leak in UnwinderFromPid object.Christopher Ferris2019-01-233-4/+4
|/ | | | | | | | | | | | Actually make the destructor virtual so that objects in UnwinderFromPid get freed. Also, explicitly make the DexFiles and JitDebug destructors virtual. Bug: 123099840 Test: Ran UnwindTest.local_from_pid thousands of times. Change-Id: I8bf11c0eb3587fa82f5f14f4723ea5c91da0fd46
* Add caching of build id in MapInfo object.Christopher Ferris2019-01-173-13/+23
| | | | | | | | | | | Change the GetBuildID function to return a std::string. Added benchmark to check how long it takes to get the build id from a file versus an elf object. Added a way to get an elf without passing in a valid process_memory and added tests for this. Test: New unit tests. Change-Id: I3029019767e0181c758d611fe635bc1bf72d6e8e
* Add support for UnwinderFromPid object.Christopher Ferris2019-01-162-3/+32
| | | | | | | | | | | | | This object is able to be easily used from other code and can be used to replace the libbacktrace calls in other parts of the platform. Also, demangle the function names when calling FormatFrame. Bug: 120606663 Test: Unit tests pass, debuggerd using this code directly passes unit Test: tests. Change-Id: Ifd8cf9bdd89174c1736810711d20e9f37f29b1bf
* Revert^2 "Use libdexfile external API in libunwindstack."Martin Stjernholm2018-12-191-1/+1
| | | | | | | | | | | | | | | | This reverts commit cacf5bf6bca7e9806739a27589d8b6101c567c32. Reason for revert: Re-apply with proper fix for VNDK visibility on marlin and sailfish. Test: Manual repro of http://b/121110092#comment1 on reported branch Test: atest CtsRenderscriptTestCases Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests Test: Make image, flash, and reboot device. Test: Forrest cts/art/gce-all: https://android-build.googleplex.com/builds/forrest/run/L00300000240828791 Test: Forrest cts/bionic/gce-all: https://android-build.googleplex.com/builds/forrest/run/L05600000240682947 (shows 27/2958 failed, but it doesn't pass on Blackbox either: http://screen/xbjioEf6UgR) Test: Forrest cts/renderscript/gce-all: https://android-build.googleplex.com/builds/forrest/run/L66200000240680523 Bug: 119632407 Change-Id: I601aa97eac8127e30d753405f8bc1fc4ae7f849f
* Merge "Fix offsets when shared lib split across maps."Treehugger Robot2018-12-192-18/+21
|\
| * Fix offsets when shared lib split across maps.Christopher Ferris2018-12-182-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Revert "Use libdexfile external API in libunwindstack."Martin Stjernholm2018-12-191-1/+1
|/ | | | | | | | | | | | | | | This reverts commit 444e23d2fc6d7c6f799ff9e2f69c1a82d2960c5b. The rest of the topic doesn't need to be reverted. Reason for revert: Breaks renderscript on marlin and sailfish. Test: Manual repro of http://b/121110092#comment1 on reported branch Test: "atest CtsRenderscriptTestCases" on that branch Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests Test: Make image, flash, and reboot device. Bug: 121110092, 119632407 Change-Id: If1976b19ce386c95bc5bd4fd6d523745c167de18
* Use libdexfile external API in libunwindstack.Martin Stjernholm2018-12-131-1/+1
| | | | | | | Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests Test: Make image, flash, and reboot device. Bug: 119632407 Change-Id: I370f089a1b20ba432e136818b4325d46f99df708
* Fix handling of ro segments for embedded libs.Christopher Ferris2018-12-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | When a shared library is loaded directly from an apk, the new way the linker splits a shared library into a read-only and execute segment broke unwinding. Modify the code to handle this case. Other changes: - Modify the algorithm for finding read-only map entries. Before, the code would search the entire map for the closest offset. Now it simply looks at the previous map. I did this because the old code was too lenient and might still work even if the linker changes. I want this to break if the linker behavior changes so that I can analyze the change. - Update the tools to use PTRACE_SEIZE instead of PTRACE_ATTACH since PTRACE_ATTACH doesn't work in all cases. - Small refactor of the GetFileMemory function. - Add new unit test cases and new offline unwind test cases. Bug: 120618231 Test: Ran new unit tests, ran original failing test. Change-Id: I4bade55cf33220d52f1d5e9b0cbbbcc8419669d4
* Merge "Read .note.gnu.build-id."Florian Mayer2018-12-062-0/+20
|\
| * Read .note.gnu.build-id.Florian Mayer2018-12-052-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This will be used by heapprofd to allow us to correlate build ids with memory leaks in libraries and binaries. Test: m Test: host libunwindstack_test Test: run unwind_info against my phone's libc.so (32/64) and compare to readelf Build ID output. Bug: 120186412 Change-Id: I3cefd6cce9a8733509bf35b7175eb0f967783477
* | Add support for caching small reads.Christopher Ferris2018-11-281-0/+22
|/ | | | | | | Add benchmarking to verify this is faster. Test: Ran unit tests. Change-Id: I1487114331f4581ec2368e56c4f18c6e3e6bcc7d
* Verify that the elf matches the expected arch.Christopher Ferris2018-10-295-11/+22
| | | | | | | | | 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