summaryrefslogtreecommitdiff
path: root/simpleperf/JITDebugReader.h
AgeCommit message (Collapse)Author
2020-10-23simpleperf: enable .clang-formatThiƩbaud Weksteen
Use the 2-space configuration by default and disable any formatting for the demo/ subdirectory. The following command was used to generate this change: $ find . \( -name \*.cpp -o -name \*.h \) -exec clang-format \ --style=file -i {} \; Test: mm Change-Id: I89ec1f18f6e352f40cfa1a770087f3b586b1d7cb
2020-09-09simpleperf: fix tests broken by jit symfile path change.Yabin Cui
Simpleperf checks if a path is JIT symfile by looking for a colon symbol in it. But a normal path on windows can contain colon symbols. Thus two windows tests are broken. This CL fixs them by adding a function in JITDebugReader class to check JIT symfile paths. Also fix python test TestReportLib.test_merge_java_methods. It was broken by report_lib_interface.cpp dropping support for old jit symfile paths. This CL added the support back. Also add a new test TestReportLib.test_jited_java_methods to test new jit symfile path. Bug: 167604389 Test: run simpleperf_unit_test. Test: run test.py. Change-Id: Ic0f69d224069f708fe20d79d0ce61cf63bd17e5f
2020-08-06simpleperf: fix jit cache path in report cmd.Yabin Cui
1. Separate app cache and zygote cache in ElfDso::GetReportPath(). 2. Use GetReportPath() in --dsos option in report cmd. So "[JIT app cache]" can be used to filter binaries. Bug: 159155297 Test: run simpleperf_unit_test Change-Id: Idc52bd1b2496aae30721a224d93621f776f2ae03
2020-08-03simpleperf: Split jit_app_cache and jit_zygote_cache.Yabin Cui
Bug: 159155297 Test: run simpleperf_unit_test Change-Id: I187a4bcf5d45d355abb153e20ba44028a842b2b9
2020-07-28simpleperf: dump jit symfiles to a single file.Yabin Cui
Currently, each jit symfile is dumped to a distinct temporary file. This creates many temporary files, having two drawbacks: 1. It leaves many junk files if simpleperf is killed in the middle. 2. The names of the temporary files change in different recording files, making them harder to compare. This CL fixes it by making changes below: 1. Store jit symfiles in a single file. The location of a symfile is passed via a special path format: <file_path>:<file_start>-<file_end>. So the unwinder and ElfFile class can read it correctly. 2. Add Dso::GetReportPath() to give a unified name for jit symfiles. And use it in different reporting methods. Also split JITDebugReader::ReadProcess() into smaller functions. Bug: 159155297 Test: run simpleperf_unit_test Test: run simpleperf manually Change-Id: I37cd1888b855b4b88bb83e453e39230b96fb304f
2020-03-03Revert "simpleperf: add temporary work around for debug interface change."Yabin Cui
This reverts commit 95d8395bcaf09d7079fe0fbbf7514631990ae47d. The workaround isn't needed after https://android-review.googlesource.com/c/platform/art/+/1156360. Bug: none Test: run simpleperf_unit_test. Change-Id: I2ec6abbd2cdf48329b3a2bd8c100283afa5dda4a
2019-11-05simpleperf: add temporary work around for debug interface change.Yabin Cui
To fix a libunwindstack problem, ART appends new debug entries to the end of the debug entry list, insteading prepending to it. This breaks CtsSimpleperfTestCases. This CL adds a temporary work around in simpleperf, so we have time to try other fixes in ART. Bug: 143375574 Test: run simpleperf_unit_test Change-Id: I5d73792996fb89d22a664b982e667ba0a4ee8276
2019-10-10simpleperf: change based on jit debug interface change.Yabin Cui
1. Change magic field and sizeof_entry check for JITDescriptor. 2. Use seqlock field in JITCodeEntryV2 to check its valid. 3. Allow but skip entry with symfile_size = 0 in V2. Bug: 141558390 Test: run simpleperf_unit_test. Change-Id: I30e214597cec78c73492fdfeac1f9766b775f0e3
2019-05-31simpleperf: dump mmap records for dex files extracted in JITDebugReader.Yabin Cui
On Android Q, ART extracts dex files in apk files directly into memory, and names it using prctl(). The kernel doesn't generate a new mmap record for it. So if simpleperf is started before the app, it can't receive the correct mmap info of dex files extracted into memory. Thus making missing symbols and broken callchains. So work around this by dumping the mmap info in JITDebugReader. Bug: 134081613 Test: run simpleperf manually. Test: run simpleperf_unit_test. Test: run test.py TestCppDemoJniCall.test_smoke. Change-Id: I995573309816c84729e82e58148890a76725ae36
2018-11-14switch to using android-base/file.h instead of android-base/test_utils.hMark Salyzyn
Test: compile Bug: 119313545 Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-08-29simpleperf: sync JIT debug info with records.Yabin Cui
To save time, simpleperf doesn't check JIT debug info update each time unwinding a sample. Instead, it checks JIT debug info update every 100ms. So some samples (about 1%) can be failed to unwind because of lacking the latest JIT debug info. This patch fixes it by using monotonic timestamps to sync JIT debug info and samples. It contains below changes: 1. Use monotonic timestamp for records by default if that is supported. 2. Add a priority queue in JITDebugReader to sort existing JIT debug info by timestamp. Each time reading new JIT debug info from remote processes, it is put in the queue. 3. Each time processing a record, JITDebugReader flushes all debug info in the queue generated before the record. So a record only sees JIT debug info generated before it. 4. If unwinding a sample fails because of incomplete JIT debug info, read newest debug info from the process and retry unwinding. Bug: 110923759 Test: run simpleperf manually and check no unwinding fails because Test: of lacking the latest JIT debug info. Change-Id: I769b72a3345f917e5c0f9a9936d19bca536e1153
2018-06-11simpleperf: support JIT/interpreted java code in system wide profiling.Yabin Cui
It contains below changes: 1. Support monitoring multiple processes in JITDebugReader. 2. Switch from 100ms period to 100ms interval when scanning JIT debug info changes. 3. Limit read entry length by seqlock different instead of a fixed value. 4. Support disable/enable periodic events in IOEventLoop. 5. Remove duplicated dex file offsets in DexFileDso. 6. Enable JITDebugReader for recording on Android P. 7. Remove " (deleted)" suffix in filenames of maps, because some vdex files in map file have this suffix. Bug: http://b/79118393 Test: run `simpleperf record -a` manually. Test: run simpleperf_unit_test. Change-Id: Ia398ddd7bc74cbc5fdca6caa6f548a62447d9729
2018-05-22simpleperf: get symbols from dex files extracted from zip files.Yabin Cui
ART may extract dex files into memory from zip files. This CL supports getting symbols from extracted dex files in below steps: 1. Change map names in "/dev/ashmem/dalvik-xxx extracted in memory from yyy.apk" format into yyy.apk!/xxx format. 2. Support dumping dex files in yyy.apk!/xxx format in JITDebugReader. 3. Support reading symbols from dex files in yyy.apk!/xxx format in DexFileDso. Also refactor FileHelper to return android::base::unique_fd, refactor ArchiveHelper to wrap all operations to zip files. Bug: 79118393 Test: run simpleperf_unit_test. Test: run simpleperf on an app containing extracted dex files. Change-Id: I65dbd98843f2d47272ea72935fd3d2b6d6e8ae40
2018-03-28simpleperf: support showing symbols for interpreted java code.Yabin Cui
To convert from a dex_pc (returned by libunwindstack) to a symbol name, we need below things: 1. The mapping info of the vdex file containing the dex_pc. 2. The offsets of dex files in the vdex file. So make below changes: 1. Record none executable maps when profiling java code. 2. Refactor dso code to add a new type for dex file, using DexFileDso to store dex file offsets in a vdex file, and load symbols from that vdex file. 3. Add read_dex_file.cpp to read java symbols using libdexfile. 4. Change the format of file section in record_file_format.h, to store dex file offsets in vdex files. Bug: http://b/73126888 Bug: http://b/77236599 Test: Run simpleperf to profile several apps manually, can see Test: callstacks of both java code and native code. Test: Run simpleperf_unit_test. Change-Id: I08005a03beb3df1a70db034bc463f555934856ba
2018-03-19simpleperf: Add JITDebugReader.Yabin Cui
When profiling an app on Android >= P, simpleperf reads new JIT/dex symfiles exported by the app's __jit_debug_descriptor and __dex_debug_descriptor every 100ms. It also saves new JIT symfiles in temporary files for unwinding/symbolization later. This is a preparation to support profiling JITed/interpreted Java code. Bug: http://b/73127105 Test: run simpleperf_unit_test. Test: run simpleperf manually. Change-Id: I0a3a483a61e7388e51627a7779547016b0b268a0