summaryrefslogtreecommitdiff
path: root/simpleperf/dso_test.cpp
AgeCommit message (Collapse)Author
2021-01-11simpleperf: move all source files into simpleperf namespaceYabin Cui
Bug: none Test: run simpleperf_unit_test Change-Id: I348028ee5bea90ce908bc240fc5efc22c4cd540f
2020-11-25simpleperf: fix symbolization for kernel modules.Yabin Cui
Simpleperf makes a wrong assumption that the kernel always load .text section of a kernel module at the start of its module memory. This can map an ip addr of a module to a wrong symbol. To fix it: 1. In KernelModuleDso, calculate min_vaddr and memory_offset, which are used to do the conversion in IpToVaddrInFile(). 2. Change record_file_reader/writer to store min_vaddr and memory_offset of KernelModuleDso in the recording file. 3. To get module start addresses, Use CheckKernelSymbolAddress() in GetLoadedModules(). Bug: 174076407 Test: run simpleperf_unit_test. Test: run simpleperf manually to check symbols of kernel modules. Change-Id: I2498564f78dcc34761c5fe3ae9ffa6b88a98a048
2020-11-11simpleperf: support kernel etm data in inject cmd.Yabin Cui
1. Refactor KernelDso class to handle kernel address randomization. 2. Add Dso::IpToFileOffset() to convert ip addresses to file offsets, and use special operation for KernelDso. 3. Search for vmlinux in symbol dirs. 4. Delay creating KernelDso to use the kernel build id in recording files. Bug: 172933381 Test: run simpleperf_unit_test Test: run `simpleperf inject` manually to inject kernel etm data. Change-Id: Ice7f465a6f1e870740cc8ceaf8da76220026adef
2020-08-27simpleperf: add perf symbol map dso + testEvgeny Eltsin
Bug: 164091700 Test: simpleperf_unit_test Change-Id: I73c56d87518e22146dd7ec62c52ed80640369b59
2020-07-17simpleperf: find debug files for kernel modules.Yabin Cui
Also print a warning when a debug file in symfs_dir can't be used because of build_id mismatch. Bug: 161546498 Test: run simpleperf_unit_test Change-Id: I8d1d538a4a62339d236e665141b114428776fb54
2019-11-19simpleperf: support libraries without build ids when recording.Yabin Cui
Simpleperf can download unstripped libraries on device and use them for unwinding during recording, through `app_profiler.py -lib` and `simpleperf record --symfs` options. But it doesn't support libraries without build ids. To support them: 1. In app_profiler.py, download libraries without build ids in native lib dir. 2. In DebugElfFileFinder in dso.cpp, check path with the same basename in symfs_dir. Also add document for downloading unstripped libraries on device. Bug: none Test: run simpleperf_unit_test. Test: run test.py. Change-Id: I5d9015e683f2ecb992d425a42f1f7303307b2cea
2019-11-15simpleperf: fix build_id checking.Yabin Cui
Native libraries in apks may not have build ids. So change to below rules when looking for a debug elf file: 1) If having a build id, the build ids should match. 2) Otherwise, the debug elf file should exist and not have a build id. Bug: none Test: run simpleperf_unit_test. Test: test.py. Change-Id: I01332e3010a6df17e70c6c55e15874d43bfaeb86
2019-05-31simpleperf: check content in build_id_list.Yabin Cui
The content in build_id_list may not match files exist in symfs dir, (like due to interrupted tests). So in simpleperf binary, do build id check for files in build_id_list. Also check if files exist in NativeLibDownloader. Bug: 134164477 Test: run simpleperf_unit_test. Test: run test.py TestNativeLibDownloader* Change-Id: Ida435d17d4fead2ba3a14c7766ecaf7cf12448b2
2019-02-07simpleperf: fix symbolization in multi-executable-segments libraries.Yabin Cui
Apps may run with libraries with multiple executable segments. Symbolization ip addresses in these libraries need to use map.pgoff. The old formula converting ip to vaddr_in_file: vaddr_in_file = ip - map.start + min_executable_vaddr The new formula converting ip to vaddr_in_file: offset_in_file = ip - map.start + map.pgoff vaddr_in_file = offset_in_file - file_offset_of_min_executable_vaddr + min_executable_vaddr Bug: 124056476 Test: run simpleperf_unit_test. Test: use simpleperf to profile facebook app, ip addresses hitting libc.so Test: and libart.so are symbolized correctly. Change-Id: I5fd3ed822a916c4d04a9868d6d209c43ee190c5b
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-10-30simpleperf: fix simpleperf_unit_test on windows.Yabin Cui
Fix test failures caused by path separator and newline character. Bug: 117568547 Test: run simpleperf_unit_test on windows. Change-Id: I0522268368a2288893ecd52f505382c512d1d7c9
2018-07-23simpleperf: add --symdir option in report-sample command.Yabin Cui
--symdir option is used to provide a directory containing files with symbols. Mutliple --symdir options can be used to provide more than one directories. For each symbol directory, simpleperf collects build id for all elf files under it recursively. Then simpleperf can use the collected build ids to find files with symbols. Also fix an error in GetCompleteProcessName(). Bug: 111687223 Test: run simpleperf_unit_test. Change-Id: Ieac5ebf7451ae85ca15c3eae37bac3c89615580b
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-30simpleperf: add a missing null check.Yabin Cui
Bug: none. Test: run simpleperf_unit_test. Change-Id: I206c9c67cd96025956246c1bd080653f532a9112
2018-05-09simpleperf: change interface of read_apk.h.Yabin Cui
1. Remove GetBuildIdFromApkFile and ParseSymbolsFromApkFile, because their function can be supported using ApkInspector::FindElfInApkByName and read_elf.h. 2. Remove ApkInspector::FindOffsetInApkByName, instead the caller can use ApkInspector::FindElfInApkByName directly. 3. In ApkInspector::embedded_elf_cache_, add map for entry_name. So the EmbeddedElfs added by cmd_record.cpp can be used by OfflineUnwinder. Also support reading min executable virtual address from embedded elfs in ElfDso. Also avoid segfault reading build id of elf files with broken section table, and add test. Bug: none. Test: run simpleperf_unit_test. Change-Id: I2e4f51a5e348138cbf7445ec6dd42dbd6ae1b03d
2018-04-19simpleperf: use binary mode for build_id_list.Yabin Cui
As suggested in comments of https://android-review.googlesource.com/c/platform/system/extras/+/667472. Bug: none Test: run test.py. Change-Id: I55882f1cb07d87a5e09b75ab7ef901e478d614de
2018-04-18simpleperf: fix some errors testing on windows.Yabin Cui
Bug: none. Test: run simpleperf_unit_test. Test: run test.py. Change-Id: I9c77ce1704d7d7038c450a5f85c569dc2a728b92
2018-04-12simpleperf: fix reading dex files for unwinding while recording.Yabin Cui
When simpleperf does unwinding while recording, it processes mmap records before reading dex file linked list (via JITDebugReader). To process mmap records, it creates Dso objects of type ELF_FILE. Then after reading dex file linked list, it realizes some ELF_FILE Dso should actually be DEX_FILE. So this patch supports converting Dso objects of type ELF_FILE into DEX_FILE when they have dex file offsets. Bug: http://b/73126888 Test: run simpleperf_unit_test. Test: run `simpleperf record -g --no-post-unwind` on an app. Change-Id: I580a382724b17c1396a7f52d7b3f5df45bcbcfb7
2018-04-10simpleperf: Improve the way downloading native libs on device.Yabin Cui
Apks are usually built with stripped native libs, so app_profiler.py supports downloading native libs on device, and pass the native lib directory to simpleperf via --symfs option. However, it has below problems: 1. It needs to download native libs each time profiling. 2. It needs to wait until the app starts and read the /proc/pid/maps to know which native libs are needed. This patch solves the problems as below: 1. When app_profiler.py downloads native libs, it will write a build_id_list file in the native lib directory, which is a map from build_id to debug library path. 2. Simpleperf searchs build_id_list in the native lib directory, and uses build_id to find the debug files it needs. 3. Before downloading libs, app_profiler.py checks build_id_list to find libs available on device, thus avoids downloading libs more than once. Add tests in simpleperf_unit_test and test.py. Update demos to Android Studio 3.2. In profiling.gradle, remove the logic preventing stripping native libs in apk to test this patch. Another reason to remove it is because I found it affects release builds. Bug: http://b/69165587 Test: run simpleperf_unit_test && python test.py. Change-Id: I8ecf7ba2c0f58c131c261c1b4546f4916aea1f82