Commit graph

234 commits

Author SHA1 Message Date
Christopher Ferris
6f3981c181 Add support for the new unwind method.
Also add a comment to the GetElf function to indicate that it never returns
nullptr.

Also needed to add this library to the a million and one places that the vndk
has hard-coded this data.

Bug: 23762183

Test: Built, nothing uses the new code.
Test: However, I did run backtrace_test using this code, and all tests pass.
Change-Id: Ib270665dcb7a7607075e36d88be76dbde6e2faa8
(cherry picked from commit dc4104b720)
2017-08-03 10:15:44 -07:00
Christopher Ferris
32766f1f52 Allow mips to build.
Test: Build mips.
Change-Id: Ice2fe1d11b7c628b325ea2ad1fd1252ad8e10668
2017-08-02 10:45:46 -07:00
Christopher Ferris
bd625efbca Revert "Add support for the new unwind method."
This reverts commit 5b460d13a4.

Reason for revert: Strange sailfish boot problem.

Change-Id: Ibde9375405cca4343c262335647dac120aab4d73
2017-08-02 01:47:31 +00:00
Christopher Ferris
5b460d13a4 Add support for the new unwind method.
Also add a comment to the GetElf function to indicate that it never returns
nullptr.

Bug: 23762183

Test: Built, nothing uses the new code.
Test: However, I did run backtrace_test using this code, and all tests pass.

Change-Id: I252b9c2497e2d3d94347dd6e506170bf50cbfe16
2017-07-31 13:00:35 -07:00
Christopher Ferris
eb4a6dbf5c Speed up StepIfSignalHandler path.
The StepIfSignalHandler code reads from the process memory object, which
is currently the slowest way to read memory. Change the code to read from
the elf memory object which will almost always be a memory mapped file and
should be really fast.

Also, move the tests for StepIfSignalHandler to its own file.

Bug: 23762183

Test: Unit tests pass.
Change-Id: I1100b50554e5ef736a87babd484f3f34e9071caa
2017-07-19 21:35:46 +00:00
Christopher Ferris
a019665b3c Add signal handling to the register object.
- Add the StepIfSignalHandler function to the Regs object that checks
  if the code is in a signal handler.
- Add tests for new code, also add a test that unwinds through a signal
  handler.
- Slight modification to Elf to fail if a bad machine type is encountered.
  Add tests for this.

Bug: 23762183

Test: Ran unit tests.
Change-Id: Idafa1105d00b91a9343d7464ac9ed1cb95830963
2017-07-18 17:27:48 -07:00
Christopher Ferris
d226a51409 Make the library usable as a library.
- 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
2017-07-14 12:20:23 -07:00
Christopher Ferris
b5d7a87512 Move tools to separate directory.
Bug: 23762183

Test: Ran unit tests, ran new tools.
Change-Id: Icc7cbb4102a68042f4683d6dd622f21bc5e74deb
2017-07-13 13:20:10 -07:00
Christopher Ferris
f6d5431273 A few cleanups.
- Cleanup the blueprint file a bit.
- Fix the formatting in DwarfMemoryTest.cpp.
- Fix the misnamed test MemoryBuffer.cpp to MemoryBufferTest.cpp.
- Add a function to find the location of the test files so it's not
  necessary to run the test in the same directory as the test files.

Bug: 23762183

Test: Builds and unit tests pass.
Change-Id: I5666972bd01f14b8ee47c518f1840f8aeb7fd08b
2017-07-11 19:10:34 -07:00
Christopher Ferris
3517fe0413 Fix mips build.
Don't build for mips, none of this is supported on mips.

Bug: 23762183

Test: Mips build passes.
Change-Id: Iba89466a7bc13856f8fcd59ca0708a30f417b6c6
2017-07-11 15:06:19 -07:00
Christopher Ferris
2a25c4aab5 Add full support for initing registers.
- Fixes a few bugs in untested functionality.
- Add tests for the way the register handling code is used.
- Fix a few tests that were not reaping child processes.

Bug: 23762183

Test: Ran unit tests on host (32 bit and 64 bit).
Test: Ran unit tests on angler (32 bit and 64 bit).
Change-Id: I573d6617b4f1561f6e8494d7213c52086d112d97
2017-07-11 12:15:54 -07:00
Christopher Ferris
9744fb2b54 Add missing test files to compile.
Bug: 23762183

Test: Ran unit tests.
Change-Id: I8ac43517231d88c68c288800d8ed286daa57bce1
2017-07-07 12:25:23 -07:00
Christopher Ferris
570b76f04f Init .gnu_debugdata in GetElf().
- Modify the tests to share some code for the generation of the elf data.
- Move the gnu_debugdata files into a separate directory.
- Add tests for GetElf().
- Move the CreateMemory() tests and the GetElf() tests into separate files.

Bug: 23762183

Test: New unit tests pass.
Change-Id: Ie3380296bb49753c2ac8801cfa11f93d6ff7121d
2017-06-30 17:24:58 -07:00
Christopher Ferris
9416703f5b Remove assert, use CHECK instead.
- Use the CHECK macro everywhere that assert was used.
- Remove the _debug version of the tests and leave the CHECK macro so
  it's always checking in the code.

Bug: 23762183

Test: Ran unit tests.
Change-Id: Ie705eedae393d0e95bb9d99f852687a11881aef1
2017-06-29 10:29:43 -07:00
Christopher Ferris
bfd6292db6 Fix mac build.
Test: Built.
Change-Id: I455381d29045dc6dddfb2b77dcde312722c06ebf
2017-06-28 20:44:48 -07:00
Christopher Ferris
bae69f1892 Add .gnu_debugdata support.
Update the unwind_info tool to dump all of the sections.

Bug: 23762183

Test: Passes new unit tests.
Change-Id: I8b223bc208a1a2ef06ed333e6d96943c8f273681
2017-06-28 15:23:10 -07:00
Christopher Ferris
8098b1c378 Add section parsing and function name handling.
Add the code to parse the Elf section headers.

Add the plumbing through of all the symbol handling code.

Add tests for all of this new functionality.

Bug: 23762183

Test: Pass new unit tests.
Change-Id: Ie2d90cbb3d7653c53251dbcf34d9e5d241278377
2017-06-23 10:51:28 -07:00
Christopher Ferris
9d239ec6a5 Merge "Fix some memory leaks, potential errors." 2017-06-20 18:29:24 +00:00
Christopher Ferris
051792fed4 Fix some memory leaks, potential errors.
Fix a couple of memory leaks in tests.

Fix a potential case that length could be zero.

Bug: 23762183

Test: Ran unit tests, then ran valgrind on unit tests and verified no leaks.
Change-Id: I5f7602aa0204db0488a8e305250658cdb6e977d0
2017-06-19 16:20:33 -07:00
Christopher Ferris
61d4097737 Add EH frame and debug frame support.
Bug: 23762183

Test: Pass new unit tests.
Change-Id: I1bfe900e068017ff31998f359bf98d4c5c9af2a5
2017-06-16 14:25:29 -07:00
Christopher Ferris
7b8e467192 Change RegsTmpl to RegsImpl.
Also clang-format modified Regs.cpp slightly.

Bug: 23762183

Test: Built and ran unit tests.
Change-Id: I1c7c1b01974ee3f35059c42b8e2aef24d46c81a7
2017-06-01 17:56:46 -07:00
Christopher Ferris
53a3c9b4ab Add DwarfSection classes.
Bug: 23762183

Test: Ran new unit tests.
Change-Id: Icca2a73c50d467718ba4ac41e1c8f541488620dd
2017-06-01 13:12:31 -07:00
Christopher Ferris
8642fcbad2 Add the Dwarf CFA handling.
Bug: 23762183

Test: Ran new unit tests.
Change-Id: I31abac1238cc671b78a505da655fb6298be072b4
2017-04-24 13:24:33 -07:00
Christopher Ferris
0d7cf3e8dd Add function definitions for MapInfo.
Bug: 23762183

Test: All new unit tests pass.
Change-Id: I26a1f6e84bf1a02447eff48ff6e35068554330fe
2017-04-19 15:48:02 -07:00
Christopher Ferris
09385e7db5 Implement maps parsing.
The MapsOffline code is still in development so I'm not testing it very
thoroughly yet.

Bug: 23762183

Test: All unit tests pass.
Change-Id: I77aeac62940cd95c489ee221afe02349bfe39671
2017-04-06 15:01:02 -07:00
Christopher Ferris
e7ba4cc222 Add Symbols parsing.
Bug: 23762183

Test: New unit tests pass.
Change-Id: Ib67fee879120b5e82889076a0f7221dc429ac140
2017-04-04 14:41:34 -07:00
Christopher Ferris
55d22ef67c Add DwarfOp support.
Bug: 23762183

Test: New unit tests pass.
Change-Id: I9581701ee2721283a1114adab4e1bcff881980cc
2017-04-04 12:35:50 -07:00
Christopher Ferris
f447c8eb20 Add overflow checks in Memory objects.
Also change one of the reads to be explicitly ReadField instead of an
overloaded Read function.

Bug: 23762183

Test: Passes new unit tests.
Change-Id: Id848f7b632f67df0c5b7318d9e588942cfd2099a
2017-04-03 18:36:33 -07:00
Christopher Ferris
72a6fa693b Add DwarfMemory class.
Bug: 23762183

Test: Passes new unit tests.
Change-Id: I80293af0b5a8a042195c37a06d64082d2f7c781a
2017-03-24 14:07:21 -07:00
Christopher Ferris
adda674466 Use the 2 space clang format for libunwindstack.
Test: NA
Change-Id: Ibf321931d1e7ac5bbe4e8479c9d706576f55e8ac
2017-03-21 10:41:45 -07:00
Christopher Ferris
3958f8060a Elf interface for new unwinder.
This cl includes the code to read arm unwind information from a shared
library.

Bug: 23762183

Test: Passes all unit tests. I can dump the arm unwind information
Test: for an arm shared library.
Change-Id: I43501ea2eab843b81de8bd5128401dd1971af8d3
2017-03-09 12:27:16 -08:00
Christopher Ferris
01d50374ad Do not build any host targets on mac.
Bug: 23762183

Test: Compiled.
Change-Id: I42afabeb7d3576ea4afd4af05bb1cabd79ac76e5
2017-01-30 13:45:16 -08:00
Christopher Ferris
71a2dcfc64 Remote reference to log/logger.h
It was made an error to include this file after I went through the
presubmit checks.

Test: Compiles.
Change-Id: If00b0b644ecef95325636cec094cfcb399e307f9
2017-01-30 13:24:51 -08:00
Christopher Ferris
723cf9b6e6 New version of unwinder.
Bug: 23762183

Test: All unit tests pass.
Change-Id: I0ac69e55af56e1142c0a1ee3715cdc48f2ed3ec3
2017-01-25 12:21:51 -08:00