Code Coverage Library

drcovlib is a DynamoRIO Extension that collects code coverage information. If you are looking for an end-user tool, the DynamoRIO tool Code Coverage Tool combined with the post-processing tool Post-Processing should be used instead of this library. drcovlib is intended to be used to add coverage information to other tools. The drcov client itself makes use of drcovlib.

The Code Coverage Interface

The drcovlib library's basic operation is to capture coverage information during execution and write the results to a single log file for the whole at the end of execution. Per-thread coverage information can be obtained by running DynamoRIO with thread-private code caches and passing the DRCOVLIB_THREAD_PRIVATE flag to drcovlib_init().

Coverage information is finalized to the log file when drcovlib_exit() is called (or for DRCOVLIB_THREAD_PRIVATE when drcovlib's own thread exit events are invoked by DynamoRIO). For processes that are terminated without a chance for a clean exit by their parents, the caller may want to consider using drx_register_soft_kills() with a soft kill callback that nudges the child process and a nudge event callback that invokes dr_exit_process(). This will ensure that log file are written out. If this is not sufficient, drcovlib_dump() is provided, though it should not be called when normal dumping will occur.

Elision Not Supported

The DynamoRIO runtime options -max_elide_jmp and -max_elide_call must be left at their default values of zero. drcovlib does not support setting them to non-zero values.


To post-process drcovlib's log files and create human-readable output, see instructinons for running the drcov2lcov utility: Post-Processing.

Module Tracking Feature

In addition to code coverage, drcovlib provides a module (library) tracking feature that is useful for using an index and an offset as a persistent representation of the location of an application program counter for later symbolization. This feature handles unloaded and reloaded libraries and offers fast lookup. The module information can be written to a file and read back in either online or offline using DR's standalone API via the drmodtrack_offline_* interface.