summaryrefslogtreecommitdiff
path: root/libunwindstack/include
Commit message (Collapse)AuthorAgeFilesLines
...
* Always init gnu_debugdata interface if it exists.Christopher Ferris2018-10-232-2/+2
| | | | | | | | Every real call always sets the value to true to init the gnu_debugdata interface, so remove this parameter. Test: Builds, unit tests pass. Change-Id: I07fb3adbbd5b65b51c0dc7608561e820a5095051
* Fix which maps to search for globals.Christopher Ferris2018-10-173-8/+65
| | | | | | | | | | | | | | | | | | | | | If multiple threads are unwinding at the same time, new maps that contain the global variables for dex files and jit information are created. This leads to threads creating more new maps that then get searched, then more maps, then more searching until virtual address space exhaustion. Fix this so that we only search maps that have a corresponding rw map that could contain the global memory. Small refactor to combine the code to search for global variables into one class that both classes inherit from. Modify unit tests for the new pattern checking. Bug: 117761427 Test: Ran unit tests for libunwindstack/libbacktrace/simpleperf. Test: Ran art 004-ThreadStress that used to fail. Change-Id: I837ca6b9d0383100079de090bc7d019598e0cdfe
* Fix up the definition of Elf::GetInfo.Christopher Ferris2018-10-121-1/+1
| | | | | | | | | The function should have returned a bool, so now it does. Also use a different lighter weight function for validating the elf in one place that didn't need to keep the max size value. Test: Unit tests pass. Change-Id: Ibde674e608091ba04abf22fad2fdc4dbdb2c6e73
* Implement support for linker rosegment option.Christopher Ferris2018-10-032-8/+32
| | | | | | | | | | | | | | | | | | | The rosegment linker option results in two maps containing the elf data existing. One is an execute map where the code lives, and the other is the read-only segment which contains the elf header information. If the file backing a shared library in memory is not readable, then the new code will attempt to find the read-only map that has the same name as the current execute segment, and that is at offest zero in the file. Add new unit tests for this functionality. Add the missing MapInfoCreateMemoryTest.cpp to the list of tests. Bug: 109657296 Test: Pass new unit tests. Test: All unit libbacktrace/libunwindstack tests pass with rosegment enabled. Change-Id: If8f69e4a067d77b3f2a7c31e2e5cd989a0702a8c
* Allow to get raw register data on all platforms.Florian Mayer2018-08-081-6/+5
| | | | | | | | | | | | | No new test failures introduced. atest libunwindstack_test on aosp_walleye-userdebug: Without patch: Total: 800, Passed: 781, Failed: 19 With patch: Total: 800, Passed: 781, Failed: 19 Change-Id: I8853c3e1594799761b481464b75e2904b38c4830
* Be permissive about badly formed elf files.Christopher Ferris2018-08-031-2/+2
| | | | | | | | | | | | | | | | | | | | Here is the allowable issues with an elf file that will not result in an error: - The program headers/section headers offset points to unreadable memory. - Allow missing program header and/or section headers. - Allow a symbol table section header to point to invalid symbol table values. There is no real reason to require the elf file be perfect. Everything in the code has sane defaults, so any missing information won't cause any problems. This gets rid of the warning that occurs any time an elf is loaded from memory. In memory elf files never contain all of the section headers, and do not contain the symbol table data. Update tests to test these new cases. Test: Builds and unit tests all pass. Change-Id: Iaefe2cd6b6c965a01ed425a112d6afae339f3b78
* Remove Memory::ReadField.Christopher Ferris2018-07-122-13/+1
| | | | | | | | | | | | | | | In almost all cases, it is faster to read the entire structure rather than do multiple reads using ReadField. The only case where it would be slower is if doing a remote unwind and ptrace is the only way to read. In all other cases, it's a single system call. In the ptrace call, it will be multiple calls. Given that it is unusual to be forced to use ptrace, it's better to avoid it. It also reduces the code complexity to do a single read, and avoids issues where the code forgets to read the field it needs. Test: Unit tests pass on host and target. Change-Id: I7b3875b2c85d0d88115b1776e1be28521dc0b932
* Refactor the DwarfSection classes.Christopher Ferris2018-06-271-38/+59
| | | | | | | | | | | | | | | | | | | | 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 ARM program header values used for exidx.Christopher Ferris2018-06-221-1/+1
| | | | | | | | | | | | | | | | | | Before, I was using p_vaddr to get the offset into the elf file where the exidx frame starts. I changed that to use p_offset since this already has the load bias offset in it and some elf files do not set p_vaddr properly. Also, use p_filesz instead of p_memsz, since again, some elf files do not set p_memsz to the same as p_filesz. Bug: 110704153 Test: All libbacktrace/libunwindstack unit tests pass. Test: Randomly unwind process on a walleye. Test: Verified that this properly dumps and unwinds the shared Test: library that sets p_vaddr and p_memsz differently. Change-Id: Ic7b1e5d07439f4636fa02cd884a8727a5737372b
* Fix handling of load bias values.Christopher Ferris2018-06-112-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add a specialized LocalUnwinder object.Christopher Ferris2018-05-232-0/+99
| | | | | | | | | | | | | | | This object is for doing many local unwinds across different threads at any point during a program's execution. Also add LocalUpdatableMaps that will re-read the maps data under certain circumstances. This first version does not support jit or dex pc data. Bug: 74361929 Test: Ran unit tests. Change-Id: I790662366d3fed677f31b3288182950c494de9ad
* Fix bug when doing signal handler lookup.Christopher Ferris2018-05-171-2/+2
| | | | | | | | | | | | | | | | | | 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
* libprocinfo: add functions reading process map file.Yabin Cui2018-05-141-0/+7
| | | | | | | | | | | | | | | | Add test and benchmark. Also switch libbacktrace, libunwindstack, libmemunreachable to use libprocinfo for map file reading. The benchmark shows using libprocinfo speeds up map file reading in libbacktrace and libunwindstack 18% - 36% on walleye. Bug: http://b/79118393 Test: run procinfo_test. Test: run libunwindstack_test. Test: run libbacktrace_test. Test: run memunreachable_test. Change-Id: Icf281c352f4103fc8d4ba6732c5c07b943330ca1
* libunwindstack: add Regs::Clone.Josh Gao2018-04-207-0/+14
| | | | | | | | Add a way to copy a Regs object. Bug: http://b/77296294 Test: libunwindstack_test Change-Id: I28aff510aa3e1b677d5ae46dc3bfe7652817ce52
* Add a MemoryOfflineBuffer object.Christopher Ferris2018-04-031-0/+15
| | | | | | | | | | | | | 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
* Cache DWARF location rules for a given pc.David Srbecky2018-03-292-1/+11
| | | | | | | | | | | | | | 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
* Support a map that represents gdb jit elf data.Yabin Cui2018-03-211-0/+6
| | | | | | | | | | | | | Changes: - Add a new flag to the libbacktrace and libunwindstack map data. - Modify the unwinder to handle this map to use the raw pc when stepping. - Add new unit tests for this case. Bug: http://b/73127105 Test: Run simpleperf to unwind through jit symfiles. Test: Run new unit tests. Test: Run 137-cfi test on host. Change-Id: I10bc0410680accc6d35fe51e9f1098911f667e01
* Always set the sp reg to the cfa for DWARF.Yabin Cui2018-03-168-46/+55
| | | | | | | | | | | | | | 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
* Change the GetAdjustedRelPc to GetPcAdjustment.Christopher Ferris2018-02-218-8/+9
| | | | | | | | | | | | 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-201-0/+5
| | | | | | | Bug: 73558129 Test: New unit tests pass. Change-Id: I3a6b17d2590aacb367ab3e3a51cc85be73ad64eb
* Modify elf cache to handle elf_offsets properly.Christopher Ferris2018-02-161-2/+4
| | | | | | | | 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-151-0/+1
| | | | | | | | | | | | | | | 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
* Implement new DEX PC lookup scheme.Christopher Ferris2018-02-131-2/+4
| | | | | | | | | | | | | | | 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
* Expose per arch headers.Christopher Ferris2018-02-0818-0/+1068
| | | | | | | Bug: 73013352 Test: Compiles. Change-Id: Ic05660db7d7858a9857143ee5e58cdaddcf52a35
* Check that dex pc is in a valid map.Christopher Ferris2018-02-061-6/+6
| | | | | | | | | | 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
* Load dex files from ART-specific data structure.Christopher Ferris2018-02-021-3/+25
| | | | | | | | | | | | | 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-011-3/+3
| | | | | | | 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-312-1/+65
| | | | | | | | 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
* Add a global elf cache.Christopher Ferris2018-01-252-2/+16
| | | | | | | Bug: 65682279 Test: Ran new unit tests. Change-Id: I19c64614b2b11a27f58204d4cc34913c02e04c36
* Add error propagation into Unwinder/Elf objects.Christopher Ferris2018-01-246-3/+106
| | | | | | | | | | | | | | 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-174-1/+8
| | | | | | | | | | | | | | | | | | | | 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-126-4/+112
| | | | | | | | | | | | | | | | | | | | | | | 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
* Fix issues in libunwindstack.Christopher Ferris2017-12-153-10/+18
| | | | | | | | | | | | | | | | | | - 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-114-6/+115
| | | | | | | | | | 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-081-0/+4
| | | | | | | | 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
* Add method to detect remote read function to use.Christopher Ferris2017-12-071-1/+3
| | | | | | | | | | | | | | | | | | | | | 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
* Split arch data into separate files.Christopher Ferris2017-12-066-82/+245
| | | | | | | | | | | | | | 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
* Demand read load bias for a map.Christopher Ferris2017-12-053-0/+7
| | | | | | | | | | | | | | | | | | | 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
* Merge changes I53c2c560,I7d845ac5,I8b11d923Treehugger Robot2017-12-021-26/+36
|\ | | | | | | | | | | | | * changes: unwindstack: rename Memory::ReadPartially to Read. unwindstack: rename Memory::Read to ReadFully. unwindstack: add Memory::ReadPartially.
| * unwindstack: rename Memory::ReadPartially to Read.Josh Gao2017-11-151-7/+7
| | | | | | | | | | | | Test: mma Test: treehugger Change-Id: I53c2c5600fb44620b629c01db85a67789594595f
| * unwindstack: rename Memory::Read to ReadFully.Josh Gao2017-11-151-4/+8
| | | | | | | | | | | | | | | | | | | | Rename Memory::Read to ReadFully to match its semantics with that of android::base. ReadPartially will be renamed to Read in a follow up commit, kept intentionally separate so that there aren't any callers accidentally switched from ReadFully to Read. Test: treehugger Change-Id: I7d845ac5244c3025d92c8512e960e5d0d1da05af
| * unwindstack: add Memory::ReadPartially.Josh Gao2017-11-151-23/+29
| | | | | | | | | | | | | | | | Add a way to read while allowing for partial reads. Test: new tests added to libunwindstack_test, ran 32/64 on hikey960, sailfish Test: ran unwind on hikey960/sailfish Change-Id: I8b11d9230fcd3122148ef3f980863ac1404ad70a
* | Fix incorrect usage of relative pcs.Christopher Ferris2017-11-292-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When stepping, it's necessary to use both the unaltered relative pc and the adjusted relative pc. If the adjusted pc is not used, the wrong unwind information can be used. Added new offline unit tests that take real data and verifies that it unwinds properly. Fix a bug in the map code that would not properly parse map data for a 64 bit process when done in a 32 bit process. Fix bug in eh_frame processing that didn't adjust the pc correctly. Fix unit tests related to the pc adjustment. Bug: 69475565 Test: Passes libbacktrace/libunwindstack unit tests. Test: Run debuggerd -b on processes on a hikey. Change-Id: Ic501a1c4549c5f61d2742a7105c42a960f2c892b
* | Allow multiple threads sharing a map to unwind.Christopher Ferris2017-11-284-12/+29
|/ | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for only a .eh_frame.Christopher Ferris2017-11-072-4/+33
| | | | | | | | | | | | | | 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
* Add an interface for stopping in certain maps.Christopher Ferris2017-10-241-3/+2
| | | | | | | | | 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
* Merge changes I8f33830f,Icd2b891b,I8736ff5c,Iae6e342aTreehugger Robot2017-10-241-0/+18
|\ | | | | | | | | | | | | | | * changes: libunwindstack: add method to iterate across registers. libbacktrace: expose BacktraceMap's unwindstack::Memory. libunwindstack: expose UnwindStackMap::GetFunctionName. libbacktrace: expose libunwindstack Unwind routine.
| * libunwindstack: add method to iterate across registers.Josh Gao2017-10-201-0/+18
| | | | | | | | | | | | | | | | Add a function to iterate over Regs with a human-friendly name and the value of the register, to make it easy to string-format registers. Test: mma Change-Id: I8f33830fa79b245b5030b7bc9bc3c1c7ced80c75
* | Multiple bugfixes, small restructuring.Christopher Ferris2017-10-203-21/+25
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Move the load bias stored out of ElfInterface into Elf. For the compressed sections, the load bias was not the same as the data from the uncompressed section. - Move the initialization of the compressed section into Init. It was too easy to forget to call the init of the compressed section. - Do not automatically add in load bias to the pc before calling ElfInterface code. Do all of the pc manipulations in the Elf object. - Change the interface GetFunctionName code to pass in the load_bias instead of modifying the pc inside the code. - Modify the Step function to pass in the elf offset, not add it to the pc. It is necessary to have two different relative values when executing the Step: a pc that is relative to the beginning of the elf for the reading data the actual instructions when trying to determine if this is in a signal frame, and a pc that is relative to the map for finding the appropriate unwind information. - Add a feature to Unwinder so that an unwind can be stopped if it ends up in map that has a specified suffix. This is so that the ART unwinding code doesn't require skipping the compressed section. Instead, stop at if trying to unwind through a known suffix code that means the code is in java code. This is important because the compressed section data is not only used by the jave compiled code, so that will continue to work. - Fix tests for restructuring, add new tests for new functionality. Test: Ran art test 137-cfi using new unwinder as default. Test: Ran new unit tests. Change-Id: I42e658c64c5e14f698ba34944a3043afac967884
* Update the Unwinder object and add tests.Christopher Ferris2017-10-042-6/+8
| | | | | | | | | | | | | | | | | | 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