summaryrefslogtreecommitdiff
path: root/libunwindstack
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix handling of possible bad gnu_debugdata_size.Christopher Ferris2019-12-195-22/+76
| | | | | | | | | | | | | | | | Rather than use a std::vector for backing memory, allocate the memory using a new with nothrow, and in MemoryBuffer use realloc. Since the size field is coming from the elf, it could be corrupted or intentionally crafted to cause problems. In addition, add some other protections to make sure that overflows don't occur. Bug: 146215949 Test: Ran unit tests with jemalloc and scudo to verify that they Test: both behave the same way. Change-Id: If14243ce382ba5403a6bacd0ec673452c6b7c3be
* Merge "Add a name for all test suites"Treehugger Robot2019-12-129-9/+9
|\
| * Add a name for all test suitesHaibo Huang2019-12-119-9/+9
| | | | | | | | | | | | | | (for the new googletest Test: run tests Change-Id: I3856a4a8f3ed23bcfcc59bec7624595e91740be0
* | Merge "unwindstack: fix dangling pointer in LocalUpdatableMaps."Treehugger Robot2019-12-061-0/+3
|\ \
| * | unwindstack: fix dangling pointer in LocalUpdatableMaps.Josh Gao2019-11-141-0/+3
| |/ | | | | | | | | | | | | | | | | | | Previously, when reparsing /proc/self/maps, we would remove duplicate MapInfo entries, but leave the following entry's prev_map pointing toward the soon-to-be-deleted MapInfo, leading to explosions. Test: libunwindstack_test Test: booted with libfdtrack.so preloaded Change-Id: Ibfb7a8712540fe3aaadc10e9c31938f6ecddf17b
* | Use elf offset in signal step check.Christopher Ferris2019-12-0423-23/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0313-184/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-204-16/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-193-0/+4
|\ \ | |/ |/|
| * Include PSTATE in tombstones on arm64.Peter Collingbourne2019-11-183-0/+4
| | | | | | | | | | | | | | | | | | 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 build with new googletestHaibo Huang2019-11-101-1/+1
| | | | | | | | | | | | | | The new googletest requires prefix to be non-empty. Exempt-From-Owner-Approval: fix test Change-Id: Ic039cb657b455919e429a3ec2107893b1734e8a1
* | Fix potential bad info in eh_frame_hdr.Christopher Ferris2019-10-298-126/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix handling of PT_GNU_EH_FRAME.Christopher Ferris2019-10-2111-2/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bias for the PT_GNU_EH_FRAME was using the paddr instead of vaddr. This doesn't match the way the load bias is calculated, which always use vaddr - offset, so change to use vaddr. Found on an old x86 device that has a vdso that sets vaddr differently from paddr. Add a new offline test to catch this case and update the elf interface unit tests. Also, fix a small bug in the unwind_for_offline tool. Bug: 142365899 Test: Unit tests pass. Change-Id: I5f0bf062dd8ee45aa8553189ba493ec962e0b059
* | Add document of changes between Android versions.Christopher Ferris2019-10-151-0/+116
| | | | | | | | | | | | | | | | | | | | | | | | This document does not list every change in the unwinder between Android versions. Instead it attempts to only include information that someone building an app targeting a specific version of Android might need to know to make sure their app can unwind properly. It also tries to describe the way that stacktraces might be displayed differently between Android versions. Test: NA Change-Id: I4029053f763f3471f7ddb5da9b1de2d325ead455
* | Replace MOCK_METHODN with MOCK_METHOD macro.Christopher Ferris2019-10-112-12/+13
| | | | | | | | | | Test: Builds and unit tests pass. Change-Id: I64e0034359c213f37c098d1c97be260bd955ca0f
* | Merge "Continue without DEX support if libdexfile_external.so fails to load."Martin Stjernholm2019-10-091-0/+24
|\ \
| * | Continue without DEX support if libdexfile_external.so fails to load.Martin Stjernholm2019-10-081-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libunwindstack may be used in situations where we cannot guarantee that libdexfile_external.so is available, e.g. from libc_malloc_debug.so in the bootstrap Bionic, or in APEXes with incomplete linker configs. Test: atest libunwindstack_unit_test Test: atest --host libunwindstack_unit_test Test: rm -f out/host/linux-x86/lib*/libdexfile_external.so && \ out/host/linux-x86/nativetest64/libunwindstack_unit_test/libunwindstack_unit_test (check that DexFile(s)Test tests fail without abort) Bug; 139408016 Change-Id: I7eeee77ab363d9d39412ece2038ce786394bb34f
* | | Handle when bias is different in elf headers.Christopher Ferris2019-10-0831-237/+651
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix static GetLoadBias function.Christopher Ferris2019-10-023-2/+132
| | | | | | | | | | | | | | | | | | | | The load bias value set in ReadProgramHeaders is out of sync with the algorithm used in the static GetLoadBias function. Sync the two and add tests to verify that they stay in sync. Test: Unit tests pass. Change-Id: I20ac0104970a22a92a5314a41dcadad0c9c22e64
* | Further document MapInfo::elf_offset.Florian Mayer2019-09-301-2/+5
| | | | | | | | Change-Id: I291d8a61cb400fdf5795a85c4e9a65406124717e
* | Fix LocalUpdatableMapsDavid Srbecky2019-09-164-2/+278
| | | | | | | | | | | | | | | | | | | | 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 mapping to run the libunwind tests.Christopher Ferris2019-09-033-7/+30
| | | | | | | | | | | | | | | | | | | | | | | | Created a special target, libunwindstack_unit_test, that doesn't include the test that dlopen's a shared library. It appears atest doesn't understand how to handle the require keyword. Also, move the shared library into the libunwindstack_test directory itself. Test: Ran atest libunwindstack_unit_test. Change-Id: I967919b1d74a08669b61d0363d80861685725609
* | Add test of undefined return address.Christopher Ferris2019-08-304-5/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix unwind_reg_info tool.Christopher Ferris2019-08-271-5/+17
| | | | | | | | | | | | | | | | | | | | | | I was using the pc as the offest into the elf. That is obviously not correct. Added an optional OFFSET argument like in unwind_info along with this change. Test: Verified that with no offest works, verified with a zero offset Test: works, verified with a non-zero offset results in a bad elf Test: on an elf without an offset. Change-Id: I4b6d02609627288e9f8a0eb26988d03adf95cb1f
* | Merge "Move to isolated testing."Christopher Ferris2019-07-183-11/+33
|\ \
| * | Move to isolated testing.Christopher Ferris2019-07-173-11/+33
| | | | | | | | | | | | | | | | | | | | | Modify the MapInfoCreateMemoryTest to work in the isolated mode. Test: Ran unit tests on host/target. Change-Id: I84e01d96e852acd813e0f203b4a207cfaf8ca556
* | | Move to the libc++ demangler.Christopher Ferris2019-07-173-11/+19
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous versions of the libc++ demangler crashed on bad input. However, the new version passes a fuzzer and has a lot of tests. Since it's more complete than the local demangler, use it instead. Modified the expected output of an offline test since the new demangler handles a case that didn't work before. Verified that the time it takes for the check_for_leak tests did not change after this. Bug: 136138882 Test: Ran the unit tests. Test: Verified the __cxa_demangle function passes the fuzzer when run for Test: hours. Both the 32 bit and 64 bit version of __cxa_demangle were Test: fuzzed using external/libcxxabi/fuzz. Change-Id: I10c06b589d57c36d89dbecba020b1ef2da69634a
* | Fix missing load bias.Florian Mayer2019-07-099-3/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are binaries that have non-executable LOAD with p_offset=0. E.g., Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000040 0x0000000000400040 0x0000000000400040 0x0002a0 0x0002a0 R 0x8 INTERP 0x0002e0 0x00000000004002e0 0x00000000004002e0 0x00001c 0x00001c R 0x1 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x0059e0 0x0059e0 R 0x1000 LOAD 0x006000 0x0000000000406000 0x0000000000406000 0x10f2b05 0x10f2b05 R E 0x1000 LOAD 0x10f9000 0x00000000014f9000 0x00000000014f9000 0x70f634 0x70f634 R 0x1000 LOAD 0x1808f18 0x0000000001c09f18 0x0000000001c09f18 0x089fc8 0x0a7ab8 RW 0x1000 DYNAMIC 0x1864ce0 0x0000000001c65ce0 0x0000000001c65ce0 0x000240 0x000240 RW 0x8 NOTE 0x0002fc 0x00000000004002fc 0x00000000004002fc 0x000020 0x000020 R 0x4 TLS 0x1808f18 0x0000000001c09f18 0x0000000001c09f18 0x000010 0x000010 R 0x8 GNU_EH_FRAME 0x11abde8 0x00000000015abde8 0x00000000015abde8 0x14484c 0x14484c R 0x4 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x10 GNU_RELRO 0x1808f18 0x0000000001c09f18 0x0000000001c09f18 0x05c0e8 0x05c0e8 R 0x1 Test: host libunwindstack_test passes. Test: Modified unit tests and new offline test. Change-Id: I3992f712be238c7d4109556580b5dcc71175fe19
* | Switch case to suite to follow new gtest naming.Christopher Ferris2019-06-2015-71/+73
| | | | | | | | | | | | | | Bug: 135528735 Test: All unit tests pass. Change-Id: I1f3dc6fe381ec557b6b7bc5cb1c58d210efa63da
* | Fix potential race condition.Christopher Ferris2019-06-191-1/+1
|/ | | | | | | Found when I noticed that the unit tests segfaulted every once in a while. Test: Ran all unit tests 1000 times. The crash usually happens before 100 runs. Change-Id: I1c8d2e3637400dc80f273f3677f4c94b0dbeac9d
* Internalize subclasses of MemoryCasey Dahlin2019-06-1128-200/+448
| | | | | | | | | | | | | 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
* Set elf_start_offset for invalid elf maps.Christopher Ferris2019-06-105-21/+56
| | | | | | | | | Add new unit tests to cover this case. Bug: 133495043 Test: New unit tests pass. Change-Id: I9ded5732c3c40197ebfddee3dcacc4aa07541ac0
* Display offsets for dex frames.Christopher Ferris2019-06-042-1/+52
| | | | | | | | | | | | | | | | | | | | | | When adding a dex frame, no offset is ever printed even if the dex data is coming from a non-zero offset map. Fixed so an offset is printed in this case. Previous the line looked like this: #17 pc 0000000000500d7a /product/app/GoogleCamera/GoogleCamera.apk (com.google.android.libraries.camera.async.AndroidPriorityThread.run+10) Now looks like: #17 pc 0000000000500d7a /product/app/GoogleCamera/GoogleCamera.apk (offset 0x11d0000) (com.google.android.libraries.camera.async.AndroidPriorityThread.run+10) Add new unit test for this case. Bug: 134420076 Test: Wrote new unit test, and verified a non-zero offset for dex file Test: data results in a frame with a non-zero offset. Change-Id: I58c134fda4fad5456ca0f1723192667a1ca5d509
* Ignore memory from elf on /memfd:Christopher Ferris2019-05-032-1/+38
| | | | | | | | | | | | In ART, some of the maps are /memfd:/jit-cache and it triggers the warning about unreadable elf files. Do not set the elf from memory not file flag in this case. Bug: 131909548 Test: New unit tests pass. Test: No warnings dumping stacks with this change done. Change-Id: Ifba5e65da609525ded75430da173c614f6e4801e
* Add indicator that an elf is memory backed.Christopher Ferris2019-04-186-0/+168
| | | | | | | | | | | | | | | | 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-128-58/+74
| | | | | | | | | | | | | | | 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
* Merge "Revert "Check for data races when reading JIT/DEX entries.""Treehugger Robot2019-04-0620-561/+619
|\
| * Revert "Check for data races when reading JIT/DEX entries."David Srbecky2019-04-0520-561/+619
| | | | | | | | | | | | | | | | This reverts commit 85b5fecec920208ec43b42488f08d4c2e5aaeda2. Reason for revert: Breaks ART tests, reverting to investigate. Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
* | Fix off by one reading build id.Christopher Ferris2019-04-033-19/+47
| | | | | | | | | | | | | | | | | | | | Update unit tests and add new build id displaying in offline unwinds. Bug: 129873279 Test: All unit tests pass. Test: Verify that debuggerd displays build id properly. Change-Id: I97f4a204842447a20c812f535a458155b937d5e1
* | Merge "Check for data races when reading JIT/DEX entries."David Srbecky2019-04-0320-619/+561
|\|
| * Check for data races when reading JIT/DEX entries.David Srbecky2019-03-2920-619/+561
| | | | | | | | | | | | | | | | | | | | | | 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 minimal support for Dwarf 5.Christopher Ferris2019-04-012-7/+24
| | | | | | | | | | | | | | | | | | | | | | | | This is not full support for dwarf 5, this merely treats a Dwarf 5 version as Dwarf 4. There are new dwarf ops that are not supported yet, but this minimally support should allow unwinding to work if those ops are not present. Bug: 127355724 Test: New Unit tests pass. Change-Id: I35b24fbcb15a64acd49e1e0b6890dff4456ee6fd
* | Remove sequential search from DwarfEhFrameWithHdr.Christopher Ferris2019-03-293-200/+44
|/ | | | | | | | | | | | | Since there has never been a time that a sequential search has been necessary, simply remove the sequential code and allow the DwarfEhFrame object to be used in that case. If this does come up regularly, I'm not sure that it wouldn't be more performant to use the DwarfEhFrame object regardless. Bug: 129550015 Test: libunwindstack unit tests, libbacktrace unit tests. Change-Id: I738e81accb9bc1e182168cddc9c0c22823e3369b
* Add BuildId to frame information.Christopher Ferris2019-03-264-31/+78
| | | | | | | | | | | 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-1318-78/+167
| | | | | | | | | | | | | | | 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
* Fix missing offset for apk.Christopher Ferris2019-03-129-3/+94
| | | | | | | | | | | The elf_start_offset field in a map_info was not set in one path. Added new offline test for this, and update a few unit tests. Bug: 128442792 Test: New unit tests pass. Change-Id: I2c6ac1b5271a99aa0e8c4b6342a5970199185112
* 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-056-49/+65
| | | | | | | | | | | | | | | | | 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
* Fix libdexfile dependencies to avoid direct dependency on libdexfile_external.Martin Stjernholm2019-02-241-3/+0
| | | | | | | | | | | | | | It should be dlopen'ed lazily by libdexfile_support now. Also change debuggerd_test to not link libunwindstack and its dependencies statically - the static libs can overlap with the dynamic ones. Test: mmma system/core/debuggerd/ Test: atest debuggerd_test Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests (cannot get atest to work) Bug: 124827589 Bug: 123186083 Change-Id: I9e7bf9bcbae499af4e1be4c9854bce441e2a7b55