• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

Android.bpD23-Mar-2024894 3128

README.mdD23-Mar-20241.6 KiB5132

dump_coverage.ccD23-Mar-20246.4 KiB206126

README.md

1# dumpcoverage
2
3libdumpcoverage.so is a JVMTI agent designed to dump coverage information for a process, where the binaries have been instrumented by JaCoCo. JaCoCo automatically starts recording data on process start, and we need a way to trigger the resetting or dumping of this data.
4
5The JVMTI agent is used to make the calls to JaCoCo in its process.
6
7# Usage
8
9Note that these examples assume you have an instrumented build (userdebug_coverage). Here is, for example, how to dump coverage information regarding the default clock app. First some setup is necessary:
10
11```
12adb root # necessary to copy files in/out of the /data/data/{package} folder
13adb shell 'mkdir /data/data/com.android.deskclock/folder-to-use'
14```
15
16Then we can run the command to dump the data:
17
18```
19adb shell 'am attach-agent com.android.deskclock /system/lib/libdumpcoverage.so=dump:/data/data/com.android.deskclock/folder-to-use/coverage-file.ec'
20```
21
22We can also reset the coverage information with
23
24```
25adb shell 'am attach-agent com.android.deskclock /system/lib/libdumpcoverage.so=reset'
26```
27
28then perform more actions, then dump the data again. To get the files, we can get
29
30```
31adb pull /data/data/com.android.deskclock/folder-to-use/coverage-file.ec ~/path-on-your-computer
32```
33
34And you should have `coverage-file.ec` on your machine under the folder `~/path-on-your-computer`
35
36# Details
37
38In dump mode, the agent makes JNI calls equivalent to
39
40```
41Agent.getInstance().getExecutionData(/*reset = */ false);
42```
43
44and then saves the result to a file specified by the passed in directory
45
46In reset mode, it makes a JNI call equivalent to
47
48```
49Agent.getInstance().reset();
50```
51