summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/DwarfSectionImplTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove libprocinfo, libbacktrace, libunwindstackBaligh Uddin2020-10-161-624/+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: don't save pseudoregisters while evaluating DwarfTamas Zsoldos2020-08-181-0/+35
| | | | | | | | | | | | | | | | Currently, while evaluating a Dwarf section, even pseudoregisters are saved in regs_info. Since pseudoregisters are stored separately from ordinary registers, trying to read them the usual way will result in an out-of-bounds read. There's no memory corruption as regs_info is big enough to store all existing pseudoregisters. With this patch, pseudoregisters are simply not saved in regs_info. Added new unit tests to cover the pseudo register cases. Test: libunwindstack_test Change-Id: If21b2a79f2fcca85644eec430f3d22e354b001ec
* libunwindstack: support for Armv8.3-A Pointer AuthenticationTamas Petz2020-07-141-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add a name for all test suitesHaibo Huang2019-12-111-1/+1
| | | | | | | (for the new googletest Test: run tests Change-Id: I3856a4a8f3ed23bcfcc59bec7624595e91740be0
* Handle when bias is different in elf headers.Christopher Ferris2019-10-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Switch case to suite to follow new gtest naming.Christopher Ferris2019-06-201-12/+12
| | | | | | | Bug: 135528735 Test: All unit tests pass. Change-Id: I1f3dc6fe381ec557b6b7bc5cb1c58d210efa63da
* Refactor the DwarfSection classes.Christopher Ferris2018-06-271-369/+43
| | | | | | | | | | | | | | | | | | | | Modify the code for the no header sections because it turns out that it is not okay to assume that the fdes are non-overlapping. It's necessary to read the fdes in order and match as you go. Modify the code so that it only reads until it finds the given pc rather than reading all of the cie/fde entries at once. Rewrote the tests to verify the new behavior. Bug: 68998033 Bug: 110235461 Test: Ran libbacktrace/libunwindstack unit tests. Test: Unwind the mediaserver process on a walleye and verify it Test: unwinds properly. Change-Id: I7bb59d1db72c13fa34caa9735ec34c1a60e20ed2
* Fix handling of load bias values.Christopher Ferris2018-06-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that for the dwarf information, if a FDE indicates it's pc relative, then pc has to be incremented by the load bias. If not, then it should not be incremented. Previously, the code always subtracted load bias values from pcs, and assumed that all fdes were incremented by load bias values. The new code actually reads the fdes and adjusted the pcs in the fde and in the eh frame hdr so that load bias values are already handled properly. In addition, add dumping of arm exidx values in unwind_reg_info. This allowed verifying that the debug frame in those elf files was being handled properly. Added a new unit test that only has a debug frame that has a non-zero load bias and has fde entries that do not have pc relative encoding. Fix a couple of other small bugs. Bug: 109824792 Test: All libbacktrace/libunwindstack unit tests pass. Test: Ran ART 137-cfi test and 004-ThreadStress. Test: Verify that displaying the fde start and end pc actually match the Test: real data for fde that have pc relative set, and that don't. Test: Verified that the unwind information for arm exidx matches the Test: debug frame data. Change-Id: I707555286b5cb05df9f25489e8c5ede753cfe0fb
* Cache DWARF location rules for a given pc.David Srbecky2018-03-291-1/+2
| | | | | | | | | | | | | | Decoding the DWARF opcodes is expensive so make sure we cache it. This speeds unwinding in simpleperf by over a factor of 3x. Add unit tests for this new behavior. Bug: 77258731 Test: libbacktrace/libunwindstack unit tests on host and target. Test: Ran debuggerd -b on various processes on target. Change-Id: Ia516c0fa5d3e5f76746190bb4b6fdf49fd1c9388
* Always set the sp reg to the cfa for DWARF.Yabin Cui2018-03-161-22/+22
| | | | | | | | | | | | | | There are a few places where it is assumed that this register is set to the cfa value when interpreting DWARF information. Add a testcase for unwinding art_quick_osr_stub on ARM. Bug: 73954823 Test: Ran libunwindstack/libbacktrace unit tests. Test: Random debuggerd -b of process on a hikey. Test: Ran the 137 art test on host. Change-Id: Ida6ccdc38c3cfeea6b57fe861a0cc127b150b790
* Don't implicitly dereference DW_CFA_def_cfa_expression.David Srbecky2018-03-081-7/+5
| | | | | | | | The specification isn't entirely clear. Follow the gdb interpretation. Bug: 73954823 Test: libunwindstack_test Change-Id: If72717f54eed84e442f43af19e615143a9796b68
* Implement new DEX PC lookup scheme.Christopher Ferris2018-02-131-8/+9
| | | | | | | | | | | | | | | GDB wasn't handling the old one gracefully. - Create a RegsInfo structure that can be used to properly eval expression data. - Remove the versions on Dwarf ops. It doesn't work the in the real world and doesn't add useful information. - Fix dex pc frame number bug. Test: testrunner.py -j40 --host --cdex-fast -t 137 Test: libunwindstack_test Test: All unit tests pass. Change-Id: Iac4fea651b81cb6087fd237a9a5027a352a49245
* Add error propagation into Unwinder/Elf objects.Christopher Ferris2018-01-241-20/+25
| | | | | | | | | | | | | | The backtrace offline code uses these error codes to diagnose errors. In addtion, I've had cases where seeing these errors would help diagnose failures. This also allows us to add a few features to indicate why an unwind terminated (such as max frames exceeded). Bug: 65682279 Test: Updated unit tests pass. Change-Id: If82b5092698e8a194016d670efff1320f9b44d50
* Add support for getting a dex pc.Christopher Ferris2018-01-171-9/+63
| | | | | | | | | | | | | | | | | | | | 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 support for only a .eh_frame.Christopher Ferris2017-11-071-21/+7
| | | | | | | | | | | | | | Static executables only have a .eh_frame section and no .eh_frame_hdr section. Add support for this by rearranging the class hierarchy and creating a DwarfEhFrameWithHdr class and a DwarfEhFrame class to handle the different cases. Add new unit tests for DwarfEhFrame and for the new functionality. Bug: 68820189 Test: Passes new unit tests, unwinds static executables. Change-Id: I63d7cb8c52a686e96579a2266e18c0d06bbb6e63
* Move sp/pc not changing check into Unwinder.Christopher Ferris2017-10-311-19/+3
| | | | | | | | | | | | Remove this check from the DwarfSection class. Rather than have every step function make the check, doing it at the top level avoids having every function do the same check. Bug: 68167269 Test: New unit tests, ran debuggerd -b on processes. Change-Id: I23b7c799faaf26c93c1b72848df18c78de6c42fb
* If the pc is set to zero, the unwind is done.Christopher Ferris2017-10-231-1/+18
| | | | | | | | Bug: 68047085 Test: Ran new unit tests, verified new unwinder does not show an Test: extra pc zero frame for arm 32 bit processes. Change-Id: Ic6532e56fbb786a8b7d41638abae777c2d0f1d59
* Update the Unwinder object and add tests.Christopher Ferris2017-10-041-19/+19
| | | | | | | | | | | | | | | | | | 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
* Add a new unwind method on error.Christopher Ferris2017-09-221-22/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a function crashes by jumping into unexecutable code, the old method could not unwind through that. Add a fallback method to set the pc from the default return address location. In addition, add a new finished check for steps. This will provide a method to indicate that this step is the last step. This prevents cases where the fallback method might be triggered incorrectly. Update the libbacktrace code to unwind using the new methodology. Update the unwind tool to use the new unwind methodology. Add a new option to crasher that calls through a null function. Create a new object, Unwinder, that encapsulates the a basic unwind. For now, libbacktrace will still use the custom code. Added new unit tests to cover the new cases. Also add a test that crashes calling a nullptr as a function, and then has call frames in the signal stack. Bug: 65842173 Test: Pass all unit tests, verify crasher dumps properly. Change-Id: Ia18430ab107e9f7bdf0e14a9b74710b1280bd7f4
* Make the library usable as a library.Christopher Ferris2017-07-141-1/+8
| | | | | | | | | | | | | | | | | | | - Add namespace unwindstack everywhere so that it's easier for other code to use the library. - Move some of the header files into include/unwindstack so that they can be exposed. - Modify the headers so that only a limited number need to be exposed. - Update the tools to use the new headers. - Add a GetLoadBias() call on the Elf object. This prevents the need to get the interface object out of the Elf object. - Move the GetRelPc() call out of the Reg class, to the Elf class. It's not always the case that a Reg object will be around when you want to get a relative pc. The tests for this moved to ElfTest.cpp. Bug: 23762183 Test: Unit tests pass. Change-Id: Iac609dac1dd90ed83d1a1e24ff2579c96c023bc3
* Add DwarfSection classes.Christopher Ferris2017-06-011-0/+832
Bug: 23762183 Test: Ran new unit tests. Change-Id: Icca2a73c50d467718ba4ac41e1c8f541488620dd