- Add a new function Backtrace::UnwindOffline that takes the stack data.
- Modify BacktraceMap::CreateOffline so it doesn't take the stack data.
This makes it easier to reuse the map object created this way.
Reusing the map object increases simpleperf speed (unwinds per second) by 50%.
Test: backtrace_test libunwindstack_test
Change-Id: I90cfbae9e50d95d8a0e3cd394b33ba36d65d45f7
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
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
libbbacktrace changes:
- Completely rewrite the BacktraceOffline class to use the new unwinder.
- Modify the test data to save ucontext_t data instead of unw_context data.
- Convert the previous tests from unw_context data to ucontext_t data.
Bug: 65682279
Test: New unit tests pass in libunwindstack.
Test: All offline tests continue to pass.
Change-Id: I540345c304b20199d46deeb0349a0638a0f3ab2f
Use the art dex file library to read the dex data.
Add unit tests for the UnwindDexFile code.
Bug: 72070049
Test: All unit tests continue to pass.
Test: Dumped the backtrace of the 137-cfi test while running in interpreter
Test: mode and verified that the stack trace is correct. Did this on host
Test: and for arm/arm64.
Change-Id: Ia6f343318c5dd6968a954015a7d59fdf101575b0
In order to support the offline unwinding properly, get rid of the
usage of non-fixed type uintptr_t from all API calls.
In addition, completely remove the old local and remote unwinding code
that used libunwind.
The next step will be to move the offline unwinding to the new unwinder.
Bug: 65682279
Test: Ran unit tests for libbacktrace/debuggerd.
Test: Ran debuggerd -b on a few arm and arm64 processes.
Test: Ran crasher and crasher64 and verified tombstones look correct.
Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33
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
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
1. Extend MAX_BACKTRACE_FRAMES to 256, as we can have callchains
with length near 256 when recording Android applications.
2. .eh_frame and .ARM.exidx doesn't know how to unwind from instructions
setting up or destroying stack frames. It can lead to wrong callchains,
which may contain pcs outside executable mapping areas. Stop unwinding
once this is detected.
3. Some CIE entries in .eh_frame/.debug_frame suggest unwinder reading
personality routine from memory. However, that is not available in
offline unwinding, and leads to ACCESS_MEM_FAILED error. Work around
this by returning all zero data when failed to read data for some
addresses.
4. Some libraries have empty .eh_frame_hdr but valid .eh_frame.
Work around this by building eh_frame_hdr manually.
5. Prefer to use .debug_frame than .eh_frame. Because the former
can unwind instructions setting up and destroying stack frames.
Bug: http://b/69383534
Test: run backtrace_test.
Test: run simpleperf on some apps.
Change-Id: I62dddda3865dd567c6be150ce5527dc2d3516256
This is to help debugging different offline unwiding failures.
Bug: http://b/69383534
Test: run backtrace_test.
Change-Id: I5ed4837027a9f17d032925e97e9f5927161444b3
Currently, libBacktraceOffline doesn't try .ARM.exidx if a function
appears in .debug_frame. This make it can't unwind through functions
appear in both .debug_frame and .ARM.exidx, but having dwarf instructions
not accepted by libunwind.
This patch fixes this by trying first .debug_frame then .ARM.exidx on arm.
Bug: http://b/69383534
Test: run libbacktrace_test on arm.
Change-Id: Ib95dd56d5cc123a20948e880b51b28ddc04b4a6e
Rather than expect exactly one set of maps, make sure there are at
least XX number of maps.
Test: Ran the 32 bit and 64 bit variants of the benchmarks.
Change-Id: I34184eab3810e92e7f246aa810ddb18fab443c9a
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
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
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
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
When doing a remote unwind, and there is a crash in the unwind stack
code or in libbacktrace, the old version would skip those frames.
This makes debugging crashes in those libraries a bit difficult.
Bug: 68820611
Test: Ran unit tests.
Test: kill -3 a zygote process and verify no frames in
Test: libunwindstack.so/libbacktrace.so.
Test: Forced a crash in libunwindstack.so and verified the tombstone
Test: contains the full crash.
Change-Id: I297e5b3775c87c0dddf57ebb423bd72ba1baf193
Update the backtrace leak tests to share a map since this is the most
common way it will be used, and it runs much faster.
Remove the CreateNew functions, and references to them.
Remove benchmarks of CreateNew functions.
Test: Builds, ran new unit tests, ran art tests.
Change-Id: I4a25a412f1a74c6d43aebbebbf32ead20ead8f94
If libbacktrace is statically linked into a library that interposes
libc, exit-time destructors can lead to a segfault upon exit if static
variables are used after their destruction.
Remove the one use of a static variable (with inconsequential
performance impact of less than 1us per backtrace), and enable
-Wexit-time-destructors to ensure this stays fixed in the future.
Test: mma
Change-Id: Icdaf1cf1c1f166cf501d9ecd1983c44e4305f7e9
Manually doing 1000 iterations of the benchmark doesn't seem to add any
significant amount of precision, and it makes the benchmark take
forever and obfuscates the results. Just let benchmark figure out the
time (with the option of using command line flags to increase the
number of iterations).
Test: backtrace_benchmarks64
Change-Id: I8de912c1b3c904755c8e2ac4175ff70176544ba3
Correct for the number of skipped frames when unwinding with
libunwindstack.
Test: backtrace_test32 --gtest_filter="unwind_frame_skip_*"
Change-Id: I9528977104fde3c4ec792a6db1ada24ed571b867
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
These calls can only be used after the call to state.KeepRunning(),
which handles the start/stop itself.
Bug: 68170209
Test: Ran the benchmark and got reasonable results.
Change-Id: Ie12eb3a983f6fe60c85d6dfc90957eedc16b5526
Also move the Backtrace::CreateNew function into the same place as ::Create
in preparation for the switch to the new unwinder as the base.
Test: Verify that names are demangled properly.
Change-Id: I6274cd43ea52210523e1e1ce23af5b22f62f4573
Now in Android.bp files, target.linux applies to all targets running a
linux kernel (android, linux_glibc, linux_bionic). So common
flags/sources/etc can be combined instead of copying them to each
target.
Test: m
Change-Id: If7ad138ea1c540c160731f86b6ccc0daa5c69b83
This lib becomes VNDK-SP just because libutils, which is VNDK-SP, is
depending on it. Since libutils provide android::CallStack class for
collecting and printing the callstack, there is no need for vendors to
use the internal libbacktrace library. Thus the lib is marked as
vendor_available: false.
Bug: 64730695
Test: build 2017 pixel device
Change-Id: I4ad91e3a6747bb0ae88d32cd26dfba32239c5b93
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
In the future, target.linux will apply to all targets running a linux kernel
(android, linux_glibc, linux_bionic). So move all current users to the specific
linux_glibc.
There will be another cleanup pass later that will move some instances back to
target.linux if the properties should be shared with target.android and
target.linux_bionic, but target.linux needs to be removed first.
Test: out/soong/build.ninja identical before/after
Change-Id: I72ef34689c60ce547cab2898e354b027e335f6a1
Exempt-From-Owner-Approval: build system cleanup