DynamoRIO
Code Coverage Tool

drcov is a DynamoRIO client tool that collects code coverage information.

The Code Coverage Client

The DynamoRIO tool drcov collects information about which basic blocks have been executed. It writes the results to a separate log file per process.

The runtime options for this tool include:

  • -dump_text: Dumps the log file in text format.
  • -dump_binary: On by default, dumps the log file in binary format.
  • -[no_]nudge_kills: Windows only. On by default. Uses nudge to notify the process for termination so that the exit event will be called.
  • -logdir dir: Sets log directory, which by default is ".".

Post-Processing

A post-processing tool drcov2lcov is provided to convert binary log files generated by the drcov client to the lcov format. The resulting files can be processed by lcov. We provide a modified version of lcov's genhtml script which includes support for running on Windows. Our copy of genhtml is available in the same directory as the drcov2lcov executable.

To exclude the source files for system libraries, we recommend using the -src_filter option to specify the root directory of the target application's source files.

Here is an example of post-processing a single log file:

tools/bin64/drcov2lcov -input drcov.myapp.30239.0000.proc.log -src_filter mydir

This results in a file coverage.info in the lcov format. This can be processed using the genhtml script:

perl tools/bin64/genhtml coverage.info

The final result is a set of web pages that allow viewing per-line coverage of each source file in a visual manner.

If genhtml complains about missing source files from third-party libraries used by the application, the option –ignore-errors=source can be passed to the script.

When post-processing a log file created on another machine, use the -pathmap option:

tools/bin32/drcov2lcov -input drcov.myapp.30239.0000.proc.log -pathmap /data/local/tmp/ /home/derek/android/

The command line options for drcov2lcov are as follows:

  • -input
    default value: ""
    Specifies a single drcov output file for processing.
  • -dir
    default value: ""
    Specifies a directory within which all drcov.*.log files will be processed.
  • -list
    default value: ""
    Specifies a text file that contains a list of paths of log files for processing.
  • -output
    default value: coverage.info
    Specifies the name for the output file.
  • -test_pattern
    default value: ""
    Includes test coverage information in the output file (which means that the output is no longer compatible with lcov). The test coverage information is based on matching the function specified in the pattern string.
  • -mod_filter
    default value: ""
    Requests that coverage information for all libraries and executables whose paths do not contain the given filter string be excluded from the output. Only one such filter can be specified.
  • -mod_skip_filter
    default value: ""
    Requests that coverage information for all libraries and executables whose paths contain the given filter string be excluded from the output. Only one such filter can be specified.
  • -src_filter
    default value: ""
    Requests that coverage information for all sources files whose paths do not contain the given filter string be excluded from the output. Only one such filter can be specified.
  • -src_skip_filter
    default value: ""
    Requests that coverage information for all sources files whose paths contain the given filter string be excluded from the output. Only one such filter can be specified.
  • -reduce_set
    default value: ""
    Results in drcov2lcov identifying a smaller set of log files from the inputs that have the same code coverage as the full set. The smaller set's file paths are written to the given output file path.
  • -pathmap
    default value: "" ""
    Takes two values: the first specifies the library path to look for in each drcov log file and the second specifies the path to replace it with before looking for debug information for that library. Only one path is currently supported.
  • -include_tool_code
    default value: false
    Requests that execution from the drcov tool libraries themselves be included in the coverage output. Normally such execution is excluded and the output focuses on the application only.
  • -help
    default value: false
    Prints the usage message.
  • -verbose
    default value: 1
    Verbosity level for informational notifications.
  • -warning
    default value: 1
    Level for enabling progressively less serious warning messages.