summaryrefslogtreecommitdiffstats
path: root/libunwindstack
Commit message (Collapse)AuthorAgeFilesLines
* Fix bug when doing signal handler lookup.Christopher Ferris2018-05-2113-62/+202
| | | | | | | | | | | | | | | | | | | | The new lld linker uses all non-zero offset executable maps. There was a bug when trying to find if the stack is in a signal handler that caused the code to read the wrong place in the elf. Fixed by not adding the elf offset to the relative pc. Also fixed the unwind_for_offline tool to dump multiple stacks if necessary. Added new offline unit test that would have failed with the old code. Bug: 79936827 Test: Ran unit tests and libbacktrace unit tests. Test: Dumped backtraces of system pids. Test: Ran 137-cfi art test. Change-Id: Iaca8c18c2a314902e64c3f72831234297e8dcb1b Merged-In: Iaca8c18c2a314902e64c3f72831234297e8dcb1b (cherry picked from commit 239425b9fa91ae13d18cf8158b31663876d07acf)
* libunwindstack: add Regs::Clone.Josh Gao2018-04-2315-0/+77
| | | | | | | | | Add a way to copy a Regs object. Bug: http://b/77296294 Test: libunwindstack_test Change-Id: I28aff510aa3e1b677d5ae46dc3bfe7652817ce52 (cherry picked from commit 2f37a15472945194fed528cb8d3104aa4865fc4c)
* Add a MemoryOfflineBuffer object.Christopher Ferris2018-04-044-0/+132
| | | | | | | | | | | | | | 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 (cherry picked from commit 6633b0ca090dd3da45b8936d587a1316401e46ba)
* Cache DWARF location rules for a given pc.David Srbecky2018-03-296-15/+111
| | | | | | | | | | | | | | | 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 (cherry picked from commit 3386ebade2d28fd3ef68c576bb0375bd226a1320)
* Fix null pointer dereference in RegsArm.Christopher Ferris2018-03-288-86/+99
| | | | | | | | | | | | | | | | | | | Fix RegsArm::GetPcAdjustment to check for an invalid elf before trying to read memory. Modify the tests for this so it crashes without this change. Also modify the GetPcAdjustment for all different architectures so that unless the relative pc is too small, it will return the minimum amount that should be adjusted. This is to handle cases where we still want to adjust the pc but it's in an invalid elf. Mostly this is for handling cases when the pc is in jit gdb debug code so that we use the right unwind information. Bug: 77233204 Test: Passes unit tests for libbacktrace/libunwindstack. Change-Id: Id73609adaf3b80a583584441de228156fec3afa7 (cherry picked from commit 6dbc28ece3ab7cadd0087b4dc31ba9a2986545f0)
* Always set the sp reg to the cfa for DWARF.Yabin Cui2018-03-1936-254/+417
| | | | | | | | | | | | | | | 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 (cherry picked from commit 11e96fe48a74e6ab97d4de899684d3a61a9d1129)
* Handle ARM thumb function symbols.Christopher Ferris2018-03-154-4/+19
| | | | | | | | | | | | | | | | ARM thumb functions will have the zero bit set to one, which can cause function name lookups to fail. Add an ARM special GetFunctionName that handles this condition. Fix a couple of the function offsets in unit tests. Bug: 74844137 Test: Ran unit tests. Test: Ran debuggerd -b on processes on a bullhead device. Change-Id: Ibd407db34eaaa641f91fdb4f589c44a0dcc0216a (cherry picked from commit 704ec9adbac6f7f265afe0d727e685b92f7726d0)
* Don't implicitly dereference DW_CFA_def_cfa_expression.David Srbecky2018-03-124-18/+13
| | | | | | | | | The specification isn't entirely clear. Follow the gdb interpretation. Bug: 73954823 Test: libunwindstack_test Change-Id: If72717f54eed84e442f43af19e615143a9796b68 (cherry picked from commit 3692f251990ecb063bb9a3f8af1f820782be9973)
* Remove leftover commented out code.Christopher Ferris2018-03-061-1/+0
| | | | | | Test: Compiles. Change-Id: Icf1cf1640e76450d5327395eb94dbd87d2faac36 (cherry picked from commit 81744ac69f0f196f40e1d2821693cbfb40281004)
* Merge "Adjust DEX file reading to follow layout changes in ART."David Srbecky2018-02-232-18/+32
|\
| * Adjust DEX file reading to follow layout changes in ART.David Srbecky2018-02-162-18/+32
| | | | | | | | | | | | | | | | | | | | I have changed the root DEX debug descriptor in ART to more closely follow the JIT debug descriptor. Add the appropriate offsets to correctly fetch the linked list head for DEX files. Test: testrunner.py -t 137 Test: libunwindstack_test Change-Id: I90402befc88fec42658f7330d51ee79756a7f872
* | Change the GetAdjustedRelPc to GetPcAdjustment.Christopher Ferris2018-02-2118-132/+453
| | | | | | | | | | | | | | | | | | | | | | | | This cleans up a bit of the Unwinder code to make it clear what's going on. Modify the offline unit tests to verify the pc and sp to make sure that those values get computed correctly. Test: Passes unit tests. Test: Passes 137-cfi art tests. Change-Id: I0787a1d77b8726d3defd08f31c7476f6798f8d0d
* | Add ability to skip function name resolution.Christopher Ferris2018-02-203-1/+72
| | | | | | | | | | | | | | Bug: 73558129 Test: New unit tests pass. Change-Id: I3a6b17d2590aacb367ab3e3a51cc85be73ad64eb
* | Merge "bpfmt."Treehugger Robot2018-02-201-2/+8
|\ \
| * | bpfmt.Elliott Hughes2018-02-161-2/+8
| | | | | | | | | | | | | | | | | | Bug: N/A Test: builds Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
* | | Modify elf cache to handle elf_offsets properly.Christopher Ferris2018-02-164-22/+116
|/ / | | | | | | | | | | | | | | Bug: 73498823 Test: All unit tests pass. Test: Simpleperf run that previously failed, passes now. Change-Id: Iff3a1f2f641a46ab9a0326579af3649f0c76fc65
* / Fix soname reading code.Christopher Ferris2018-02-156-133/+127
|/ | | | | | | | | | | | | | | The dynamic section contained an address, not an offset into the elf file to indicate where the soname exists. Changed to use the strtab entries in the section headers to map this address to the actual offset. Refactor the soname test a bit to make it easier to verify the code. Bug: 73499044 Test: Passes new unit tests. Test: Ran unwind_info on the failing shared elf and verified the soinfo Test: is correct. Change-Id: I16ba148389bcb9aadd3566fb442dac27f89fe894
* Move libdexfile out of runtimeDavid Sehr2018-02-141-0/+1
| | | | | | | | | | Move the files out of runtime, leaving unfortunate dependences still there on runtime/base (for the moment). Also separates the build logic into two Android.bp files. Bug: 22322814 Test: make -j 50 test-art-host Change-Id: I54b06f035034e7564480cd5d4c33c4f62785682d
* Implement new DEX PC lookup scheme.Christopher Ferris2018-02-138-577/+490
| | | | | | | | | | | | | | | 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
* Fix computation of pc.Christopher Ferris2018-02-122-1/+73
| | | | | | | | | | | | | Fix the case where a non-zero load bias or a non-zero elf offset causes the pc to be set incorrectly. Add unit tests for these cases. Bug: 73172903 Test: Ran unit tests. Test: Ran the unit tests from the simpleperf CL that detected the failure. Change-Id: Id8802c00b34c66875edd4926a20c5fccd2bb7d72
* Merge "Fix off by 4 error handling eh_frame hdr."Christopher Ferris2018-02-1210-325/+450
|\
| * Fix off by 4 error handling eh_frame hdr.Christopher Ferris2018-02-1010-325/+450
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add a new tool that can dump the register information given a pc. - Add a new offline unwinder test that fails without this change. - Update unit tests. - Refactor offline unwind tests to make it easier to add tests. Bug: 73048324 Test: Passes new unit tests. Test: Passes libbacktrace unit tests. Test: Ran debuggerd -b on random processes. Change-Id: If6c70a044299505c2274ae6888b35bf9ac34b74b
* | Clear dex pc to avoid duplicate frames.Christopher Ferris2018-02-122-0/+60
|/ | | | | | | Bug: 73228466 Test: Passes new unit tests, fails without change. Change-Id: I3660bfd16cbf2d5cf96490ca7714bc5f97914884
* Expose per arch headers.Christopher Ferris2018-02-0832-66/+56
| | | | | | | Bug: 73013352 Test: Compiles. Change-Id: Ic05660db7d7858a9857143ee5e58cdaddcf52a35
* Remove dependency on -no_art variantDavid Sehr2018-02-072-2/+2
| | | | | | | | | Remove an external dependency on a shim I used to protect against renaming. Bug: 22322814 Test: make -j 50 Change-Id: I7e6eaee7d82a1a42d4c37daa74803cefc7bb68ce
* Check that dex pc is in a valid map.Christopher Ferris2018-02-064-13/+105
| | | | | | | | | | Add new unit tests for dex pc being non-zero. Bug: 73004673 Test: Ran unit tests. Test: Ran art 137-cfi test on host for interpreter. Change-Id: I09bbf96d0ed65fc1e5896e4ab2bc67867e3b7fdb
* Merge "Fix in-memory loading of cdex files with shared data."David Srbecky2018-02-061-5/+4
|\
| * Fix in-memory loading of cdex files with shared data.David Srbecky2018-02-051-5/+4
| | | | | | | | | | | | | | | | Several cdex files may share the same data for de-duplication. Bug: 72520014 Test: Disable DexFileFromFile and then run ART's 137 test. Change-Id: Icfe04255cc20a302f844c2e3e3016578856e1f82
* | Small test clean up.Christopher Ferris2018-02-0561-12/+12
|/ | | | | | | | | | Shrink a few files that are huge by removing all of the .debug_XXX sections except .debug_frame since they aren't used. Rename all of the arm32 to arm and x86_32 to x86. Test: All unit tests pass. Change-Id: Ia0f0baadf2a7fbc42a544aff2f14d5ed5f9287b7
* Load dex files from ART-specific data structure.Christopher Ferris2018-02-0212-98/+605
| | | | | | | | | | | | | 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
* Fix symbol resolution within a dex file.David Srbecky2018-02-013-7/+8
| | | | | | | Fixes the ART 137-cfi test, currently failing on buildbot. Test: testrunner.py -j40 --host --cdex-none -t 137 -b Change-Id: I16a007b291702207bbd003fd1e78e8e5ced7cd68
* Move dex pc frame creation into libunwindstack.Christopher Ferris2018-01-319-7/+745
| | | | | | | | 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
* Merge "Add a global elf cache."Christopher Ferris2018-01-2611-30/+313
|\
| * Add a global elf cache.Christopher Ferris2018-01-2511-30/+313
| | | | | | | | | | | | | | Bug: 65682279 Test: Ran new unit tests. Change-Id: I19c64614b2b11a27f58204d4cc34913c02e04c36
* | Remove DwarfError.h that moved.Christopher Ferris2018-01-251-39/+0
|/ | | | | | | | | I think a rebase recreated this file, so deleting this now. Bug: 65682279 Test: Compiles. Change-Id: I1f885ed6254089ef50f293b4c407b110f8c878da
* Merge "Fix wrong mov instruction size."Treehugger Robot2018-01-251-6/+6
|\
| * Fix wrong mov instruction size.Chih-Hung Hsieh2018-01-251-6/+6
| | | | | | | | | | | | | | | | * New clang 7.0 assembler rejects mov with wrong length. Bug: 72412103 Test: build and boot in emulator Change-Id: If1a1affaa4a149265f8cc2b8bf463e58e71cc47a
* | Add error propagation into Unwinder/Elf objects.Christopher Ferris2018-01-2431-222/+630
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Small behavioral changes to the unwinder.Christopher Ferris2018-01-2418-20/+264
|/ | | | | | | | | | | | | | | | | | | | - Be a little more lenient when reading the cies/fdes. If next entry data winds up incorrect, don't fail, simply stop processing the entries. This only applies when reading all of the cies/fdes at once. - Fail to init an eh_frame with no entries and fallback to assuming the eh_frame has no header instead. - Change the step to always try debug_frame first which has the most accurate information. - Add small unit tests and a couple of offline unit tests to verify this behavior. These changes are needed to support offline unwinding since it depends on this new behavior. Bug: 65682279 Test: Ran new unit tests. Change-Id: I3529f1b0c8e14cd7409494e5de2f3c9e78d0855e
* Add support for getting a dex pc.Christopher Ferris2018-01-178-81/+189
| | | | | | | | | | | | | | | | | | | | 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
* Find first non-zero jit debug entry.Christopher Ferris2018-01-1629-8/+282
| | | | | | | | | | | | | | | | Sometimes a process will have multiple shared libraries loaded that have defined __jit_debug_descriptor. Specifically, art testing will load libart.so and libartd.so, which would have broken unwinding through jit'd code for art testing if libart.so winds up being found first. In order to avoid duplicating the code for the linker to figure out which one is live, change the algorithm to find the first non-zero first_entry_ set in __jit_debug_descriptor. Bug: 68396769 Test: Passes unit tests. Test: Verified this can unwind 137-cfi on arm/arm64. Change-Id: Ic4d403065d2c6f22476ef0171e7add17cd1464cd
* Add ability to read jit gdb data.Christopher Ferris2018-01-1249-24/+1613
| | | | | | | | | | | | | | | | | | | | | | | 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
* Add tool to save information from a process.Christopher Ferris2017-12-204-30/+336
| | | | | | | | | | Also, modify the ProcessVmRead function to allow arbitrarily large reads and add a test for it. Test: Run tool and verify the output can be used to do an offline Test: unwind. Test: Ran unit tests. Change-Id: I0974ddca4f5cf72b4c9fa29b597a0a669e223828
* Merge "unwindstack: add some perfunctory MemoryOffline tests."Treehugger Robot2017-12-182-0/+68
|\
| * unwindstack: add some perfunctory MemoryOffline tests.Josh Gao2017-12-152-0/+68
| | | | | | | | | | | | | | Add some tests for the behavior of MemoryOffline. Test: libunwindstack_test 32/64 on hikey960 Change-Id: Ib65a0fe5347b86062ffeaf0adaf9af57066edb76
* | Fix issues in libunwindstack.Christopher Ferris2017-12-1523-103/+183
|/ | | | | | | | | | | | | | | | | | - Add a load_bias field in MapInfo so that it can be loaded offline, and also so it can be cached. - Add an Add function to the Maps class so that it's possible to manually create a map. - Remove the OfflineMaps class since I haven't found a reason for this to exist. - Add a pointer to the gnu debugdata compressed section in the interface itself and modify the step path to try eh_frame, then debug_frame, then gnu_debugdata. This way arm can add exidx as the last step behind gnu_debugdata. Add an offline test to verify the order of unwind. - Fix x86_64_ucontext_t since it was a different size on 32 bit and 64 bit systems. Test: Pass new unit tests. Change-Id: I978b70d6c244bd307c62a29886d24c1a8cb2af23
* Add libunwindstack support for Mips and Mips64Douglas Leung2017-12-1123-12/+1256
| | | | | | | | | | This patch requires v3.18 kernel or above, because v3.10 kernel has a bug (as of 8/1/2017) in the ptrace(GETREGSET) function for mips and mips64. Change-Id: I004c1fa190193eebe1c84440b366289122a6bd8a Signed-off-by: Douglas Leung <douglas.leung@mips.com> Signed-off-by: Dejan Jovicevic <dejan.jovicevic@mips.com>
* Do not check arch for format check.Christopher Ferris2017-12-084-27/+77
| | | | | | | | Use a generic check if the address is 32 bits when using the default formating of a backtrace line instead of an arch check. Test: New unit tests pass. Change-Id: Id609abc037d7b437a02d52763aa91fbefe5f4d5b
* Merge "Add method to detect remote read function to use."Christopher Ferris2017-12-083-62/+136
|\
| * Add method to detect remote read function to use.Christopher Ferris2017-12-073-62/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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