File: README.md

package info (click to toggle)
android-platform-frameworks-base 1%3A14~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 326,092 kB
  • sloc: java: 2,032,373; xml: 343,016; cpp: 304,181; python: 3,683; ansic: 2,090; sh: 1,871; makefile: 117; sed: 19
file content (50 lines) | stat: -rw-r--r-- 1,655 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# dumpcoverage

libdumpcoverage.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.

The JVMTI agent is used to make the calls to JaCoCo in its process.

# Usage

Note 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:

```
adb root # necessary to copy files in/out of the /data/data/{package} folder
adb shell 'mkdir /data/data/com.android.deskclock/folder-to-use'
```

Then we can run the command to dump the data:

```
adb shell 'am attach-agent com.android.deskclock /system/lib/libdumpcoverage.so=dump:/data/data/com.android.deskclock/folder-to-use/coverage-file.ec'
```

We can also reset the coverage information with

```
adb shell 'am attach-agent com.android.deskclock /system/lib/libdumpcoverage.so=reset'
```

then perform more actions, then dump the data again. To get the files, we can get

```
adb pull /data/data/com.android.deskclock/folder-to-use/coverage-file.ec ~/path-on-your-computer
```

And you should have `coverage-file.ec` on your machine under the folder `~/path-on-your-computer`

# Details

In dump mode, the agent makes JNI calls equivalent to

```
Agent.getInstance().getExecutionData(/*reset = */ false);
```

and then saves the result to a file specified by the passed in directory

In reset mode, it makes a JNI call equivalent to

```
Agent.getInstance().reset();
```