Commit graph

15 commits

Author SHA1 Message Date
Sim Sun
273d3f08aa Avoid re-mapping dex file that's in local memory.
If the Dex file we're trying to examine is already within the unwinder's
address space, we don't need to load it from disk or copy it across
processes.

This avoids using up virtual address space to map in dex files, and
also should be a bit faster to read since it won't go out to the file.

Patch by Chris Sarbora

Test: Ran new unit tests.
Test: Ran 137-cfi art test.
Change-Id: I949457856f051cca11b9020e9da3a41bbf6e5c8e
2020-04-07 18:07:38 -07:00
Yong Li
489c3a8b35 Fix memory leak of DexFile handle after release
The DexFile handle is allocated from heap in OpenFromFd/OpenFromMemory.
After releasing the unique_ptr, the DexFile handle itself is no longer
managed by the smart pointer. However, the DexFile handle is not freed
in the constructor of DexFileFromFile/DexFileFromMemory.

This change uses get() method to get the DexFile pointer while allowing
it to be managed by smart pointer so that it can be freed after method
end.

Added new unit tests to detect leaks.

Bug: 151966190

Test: Unwinding can still retrieve dex frame information during crash.
Test: Ran new unit tests before change and verified they fail, ran them
Test: after the change and verified they don't fail.

Signed-off-by: Yong Li <yongl0722@gmail.com>
Change-Id: I0627e1e255eb6644aba51e940c1a79ff78d568d7
2020-03-20 16:46:11 -07:00
Martin Stjernholm
9062bb4269 Continue without DEX support if libdexfile_external.so fails to load.
libunwindstack may be used in situations where we cannot guarantee that
libdexfile_external.so is available, e.g. from libc_malloc_debug.so in the
bootstrap Bionic, or in APEXes with incomplete linker configs.

Test: atest libunwindstack_unit_test
Test: atest --host libunwindstack_unit_test
Test: rm -f out/host/linux-x86/lib*/libdexfile_external.so && \
  out/host/linux-x86/nativetest64/libunwindstack_unit_test/libunwindstack_unit_test
  (check that DexFile(s)Test tests fail without abort)
Bug; 139408016
Change-Id: I7eeee77ab363d9d39412ece2038ce786394bb34f
2019-10-08 19:21:45 +01:00
David Srbecky
b9cc4fbb26 Revert "Check for data races when reading JIT/DEX entries."
This reverts commit 85b5fecec9.

Reason for revert: Breaks ART tests, reverting to investigate.

Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
2019-04-05 18:23:32 +00:00
David Srbecky
85b5fecec9 Check for data races when reading JIT/DEX entries.
Update the entries only when the list is modified by the runtime.

Check that the list wasn't concurrently modified when being read.

Bug: 124287208
Test: libunwindstack_test
Test: art/test.py -b --host -r -t 137-cfi
Change-Id: I87ba70322053a01b3d5be1fdf6310e1dc21bb084
2019-03-29 14:01:32 +00:00
Martin Stjernholm
b49289b43a Some minor updates in the libdexfile external API.
Test: m
Test: mmma system/core/{libunwindstack,libbacktrace} and run host gtests
Bug: 119632407
Bug: 120978655
Change-Id: I919586ab503be3617e8a0604dfe48db331e7af94
2019-01-09 23:25:25 +00:00
Martin Stjernholm
bb4f2b440a Revert^2 "Use libdexfile external API in libunwindstack."
This reverts commit cacf5bf6bc.

Reason for revert: Re-apply with proper fix for VNDK visibility on marlin and sailfish.

Test: Manual repro of http://b/121110092#comment1 on reported branch
Test: atest CtsRenderscriptTestCases
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Test: Forrest cts/art/gce-all: https://android-build.googleplex.com/builds/forrest/run/L00300000240828791
Test: Forrest cts/bionic/gce-all: https://android-build.googleplex.com/builds/forrest/run/L05600000240682947 (shows 27/2958 failed, but it doesn't pass on Blackbox either: http://screen/xbjioEf6UgR)
Test: Forrest cts/renderscript/gce-all: https://android-build.googleplex.com/builds/forrest/run/L66200000240680523
Bug: 119632407
Change-Id: I601aa97eac8127e30d753405f8bc1fc4ae7f849f
2018-12-19 21:04:35 +00:00
Martin Stjernholm
cacf5bf6bc Revert "Use libdexfile external API in libunwindstack."
This reverts commit 444e23d2fc.

The rest of the topic doesn't need to be reverted.

Reason for revert: Breaks renderscript on marlin and sailfish.

Test: Manual repro of http://b/121110092#comment1 on reported branch
Test: "atest CtsRenderscriptTestCases" on that branch
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Bug: 121110092, 119632407
Change-Id: If1976b19ce386c95bc5bd4fd6d523745c167de18
2018-12-19 00:11:04 +00:00
Martin Stjernholm
444e23d2fc Use libdexfile external API in libunwindstack.
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Bug: 119632407
Change-Id: I370f089a1b20ba432e136818b4325d46f99df708
2018-12-13 17:58:23 +00:00
Mathieu Chartier
c2277fc216 Move to using ClassAccessor
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
2018-08-08 11:04:15 -07:00
David Srbecky
02d0f7962d Create lookup table of DEX symbols.
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
2018-07-20 10:48:59 -07: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
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
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
Renamed from libbacktrace/UnwindDexFile.cpp (Browse further)