Commit graph

144 commits

Author SHA1 Message Date
Christopher Ferris
4cc36d2b43 Fix handling of load bias values.
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
2018-06-11 18:53:55 -07:00
Elliott Hughes
f6d7594d7f Try to fix LocalUnwinderTest.unwind_after_dlopen in APCT.
Failure:

  system/core/libunwindstack/tests/LocalUnwinderTest.cpp:181: Failure
  Value of: handle != nullptr
  Actual: false
  Expected: true

Bug: N/A
Test: N/A
Change-Id: I89b3228d51961f7bf952dd01f12f4ee61a97fe91
2018-06-06 10:48:41 -07:00
Treehugger Robot
6c9bb058c5 Merge "Build adbd for recovery" 2018-05-25 05:58:01 +00:00
Jiyong Park
a0e75045e6 Build adbd for recovery
adbd (and its dependencies) are marked as recovery_available:true so
that recovery version of the binary is built separately from the one for
system partition. This allows us to stop copying the system version to
the recovery partition and also opens up the way to enable shared
libraries in the recovery partition. Then we can also build adbd as a
dynamic executable.

Bug: 79146551
Test: m -j adbd.recovery
Change-Id: Ib95614c7435f9d0afc02a0c7d5ae1a94e439e32a
2018-05-24 14:11:11 +09:00
Christopher Ferris
ca9a54b2c0 Add a specialized LocalUnwinder object.
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
2018-05-23 20:02:30 -07:00
Treehugger Robot
2ed14f3923 Merge "Libunwindstack: Add -O0 to tools defaults on host" 2018-05-23 19:37:01 +00:00
Christopher Ferris
5e516cad93 Fix error messages handling.
Test: Builds.
Change-Id: I083ee4a51047e97e2ead78f40c82a21198f2b361
2018-05-21 13:26:58 -07:00
Andreas Gampe
8ccbe4258e Libunwindstack: Add -O0 to tools defaults on host
Extend the debug support from the host library to host tools.

Test: mmma system/core/libunwindstack
Change-Id: Ib6ea5f021d6b8139c545eaa2e6b1675befa4d3bd
2018-05-21 08:24:20 -07:00
Christopher Ferris
239425b9fa Fix bug when doing signal handler lookup.
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
2018-05-17 18:58:42 -07:00
Yabin Cui
3841accba8 libprocinfo: add functions reading process map file.
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
2018-05-14 14:00:18 -07:00
Sen Jiang
2ef03e0f01 Match LZMA SDK 18.05 API.
Test: libunwindstack_test
Change-Id: Ie1c9c91fb4f3585a7543df55a71abf64f8fc6dff
2018-05-04 13:12:36 -07:00
Elliott Hughes
40fdf3f4ab Add test_suites lines.
Bug: N/A
Test: builds
Change-Id: Ic5e2b9206bcfcb53c774989013b5db6aab462e42
2018-04-27 16:12:06 -07:00
Josh Gao
2f37a15472 libunwindstack: add Regs::Clone.
Add a way to copy a Regs object.

Bug: http://b/77296294
Test: libunwindstack_test
Change-Id: I28aff510aa3e1b677d5ae46dc3bfe7652817ce52
2018-04-20 13:23:20 -07:00
Christopher Ferris
6633b0ca09 Add a MemoryOfflineBuffer object.
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
2018-04-03 18:37:52 -07:00
Christopher Ferris
95a524460a Merge "Cache DWARF location rules for a given pc." 2018-03-29 14:47:35 +00:00
David Srbecky
3386ebade2 Cache DWARF location rules for a given pc.
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
2018-03-29 14:47:13 +00:00
Christopher Ferris
6dbc28ece3 Fix null pointer dereference in RegsArm.
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
2018-03-28 17:21:01 -07:00
Yabin Cui
d5b22c5f04 Support a map that represents gdb jit elf data.
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
2018-03-21 17:23:54 -07:00
Christopher Ferris
b22451f178 Merge "Always set the sp reg to the cfa for DWARF." 2018-03-19 17:48:59 +00:00
David Srbecky
e8d1b75c0c Merge "Don't include map name if the consumer doesn't want names." 2018-03-19 11:23:10 +00:00
David Srbecky
e62f4c4d4c Don't include map name if the consumer doesn't want names.
Simpleperf doesn't need the name, so avoid the string copies.

This seems to speed up simpleperf by around 20%.

Test: backtrace_test libunwindstack_test
Change-Id: Iba064c7078f7e5ecfc9d8539ba09c14495a52158
2018-03-19 11:20:00 +00:00
Yabin Cui
11e96fe48a Always set the sp reg to the cfa for DWARF.
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
2018-03-16 23:38:07 -07:00
Christopher Ferris
704ec9adba Handle ARM thumb function symbols.
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
2018-03-15 15:14:18 -07:00
David Srbecky
ff9b1db67c Merge "Remove libunwindstack_dex" 2018-03-13 11:31:22 +00:00
David Srbecky
18121dc4d0 Remove libunwindstack_dex
Thanks to David Sehr's recent work the isolation is no longer needed.

Bug: 72216369
Test: backtrace_test
Test: libunwindstack_test
Test: testrunner.py -t 137
Change-Id: I0f430e0c18bdbc83c5584a2461ebbcc7eeb91313
2018-03-12 20:13:21 +00:00
David Srbecky
3692f25199 Don't implicitly dereference DW_CFA_def_cfa_expression.
The specification isn't entirely clear. Follow the gdb interpretation.

Bug: 73954823
Test: libunwindstack_test
Change-Id: If72717f54eed84e442f43af19e615143a9796b68
2018-03-08 14:44:11 -08:00
Christopher Ferris
81744ac69f Remove leftover commented out code.
Test: Compiles.
Change-Id: Icf1cf1640e76450d5327395eb94dbd87d2faac36
2018-03-06 11:24:55 -08:00
David Srbecky
8fbdbba9f5 Merge "Adjust DEX file reading to follow layout changes in ART." 2018-02-23 17:53:23 +00:00
Christopher Ferris
a2ec50bf57 Change the GetAdjustedRelPc to GetPcAdjustment.
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
2018-02-21 20:16:39 -08:00
Christopher Ferris
e4b3a6aaa4 Add ability to skip function name resolution.
Bug: 73558129

Test: New unit tests pass.
Change-Id: I3a6b17d2590aacb367ab3e3a51cc85be73ad64eb
2018-02-20 17:10:23 -08:00
Treehugger Robot
0609e8d231 Merge "bpfmt." 2018-02-20 02:02:59 +00:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00
Christopher Ferris
d9575b668b Modify elf cache to handle elf_offsets properly.
Bug: 73498823

Test: All unit tests pass.
Test: Simpleperf run that previously failed, passes now.
Change-Id: Iff3a1f2f641a46ab9a0326579af3649f0c76fc65
2018-02-16 14:52:38 -08:00
David Srbecky
4015ef411a Adjust DEX file reading to follow layout changes in ART.
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
2018-02-16 14:54:49 +00:00
Christopher Ferris
beae42bc7f Fix soname reading code.
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
2018-02-15 17:57:13 -08:00
David Sehr
3a26c27252 Move libdexfile out of runtime
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
2018-02-14 17:42:59 +00:00
Christopher Ferris
559c7f2092 Implement new DEX PC lookup scheme.
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
2018-02-13 16:45:38 -08:00
Christopher Ferris
e4df5f5ab5 Fix computation of pc.
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
2018-02-12 14:06:13 -08:00
Christopher Ferris
73a2508dc4 Merge "Fix off by 4 error handling eh_frame hdr." 2018-02-12 18:58:34 +00:00
Christopher Ferris
a8c397317d Clear dex pc to avoid duplicate frames.
Bug: 73228466

Test: Passes new unit tests, fails without change.
Change-Id: I3660bfd16cbf2d5cf96490ca7714bc5f97914884
2018-02-12 08:46:19 -08:00
Christopher Ferris
e37e2d05b1 Fix off by 4 error handling eh_frame hdr.
- 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
2018-02-10 17:11:23 -08:00
Christopher Ferris
53914165e4 Expose per arch headers.
Bug: 73013352

Test: Compiles.
Change-Id: Ic05660db7d7858a9857143ee5e58cdaddcf52a35
2018-02-08 19:29:08 -08:00
David Sehr
892e675a89 Remove dependency on -no_art variant
Remove an external dependency on a shim I used to protect against
renaming.

Bug: 22322814
Test: make -j 50
Change-Id: I7e6eaee7d82a1a42d4c37daa74803cefc7bb68ce
2018-02-07 15:19:22 -08:00
Christopher Ferris
e762f1f193 Check that dex pc is in a valid map.
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
2018-02-06 15:00:04 -08:00
David Srbecky
d663ef9772 Merge "Fix in-memory loading of cdex files with shared data." 2018-02-06 11:00:31 +00:00
Christopher Ferris
5f5cb238f0 Small test clean up.
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
2018-02-05 13:12:54 -08:00
David Srbecky
417f7c3720 Fix in-memory loading of cdex files with shared data.
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
2018-02-05 20:40:31 +00:00
Christopher Ferris
7747b60faa Load dex files from ART-specific data structure.
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
2018-02-02 15:03:00 -08:00
David Srbecky
f9006ec9b6 Fix symbol resolution within a dex file.
Fixes the ART 137-cfi test, currently failing on buildbot.

Test: testrunner.py -j40 --host --cdex-none -t 137 -b
Change-Id: I16a007b291702207bbd003fd1e78e8e5ced7cd68
2018-02-01 14:51:57 +00:00
Christopher Ferris
d70ea5ea85 Move dex pc frame creation into libunwindstack.
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
2018-01-31 14:19:42 -08:00