Remove unit test that is not needed any more.
Slightly reorganize the code around the changed check.
Bug: 77958880
Test: Ran backtrace tests with new linker options.
Test: Ran libunwindstack unit tests.
Change-Id: Ie95707323fb51616a093cafb83e0343fa24e7e61
To avoid a case where a malicious app might try and trick the system to
create an elf and register object that mismatches, always verify that they
are the same arch.
Test: Ran unit tests.
Change-Id: I66978e9e02f8e4f396856912e7019528ead4838e
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
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
When adding a frame with a dex pc, two frames will be added total. However,
if there is only enough room for a single frame, two get added any way.
Only add a single frame in this case, and add a unit test for this case.
Test: Passes unit tests.
Change-Id: If320584b126967a042c623d8fdf3f51dbc1c2251
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
The new linker base map is read-only, but the global handling code
for jit and dex information assumed the base map was a read-execute
one. Relax that requirement to search read-only maps.
Adjust the unit tests for this case.
Bug: 117293117
Test: Passes unit tests.
Test: Passes art cfi tests with and without llvm linker.
Change-Id: I31a765d51847d0b8d778ace9cbaa29f42073f4d9
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
Add FALLTHROUGH_INTENDED for clang compiler.
Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
In preparation for removal of ClassDataItemAccessor.
Bug: 79758018
Test: make
Test: test/run-test --host 137
Test: out/host/linux-x86/nativetest/libunwindstack_test/libunwindstack_test
Change-Id: I61a20fe7200a0d669b84573d3853b55877922602
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
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
Create fast lookup table instead of iterating every single time.
This will create the cache as methods are searched for.
Test: 137-cfi
Change-Id: I4be190bb1a637fef5d385b993be6a7e2203a6814
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
There's still <cutils/atomic.h> in a test, but I don't understand why
that isn't just std::atomic.
Also add a shared tgkill wrapper to libbase.
Bug: N/A
Test: ran tests
Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
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
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
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
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
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
Extend the debug support from the host library to host tools.
Test: mmma system/core/libunwindstack
Change-Id: Ib6ea5f021d6b8139c545eaa2e6b1675befa4d3bd
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
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
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
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
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
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
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
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
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
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