Skip to content

ilmanzo/BinaryCoverage

 
 

Repository files navigation

BinaryCoverage

BinaryCoverage is a code coverage tool built as a plugin for Intel Pin, a dynamic binary instrumentation (DBI) framework. It analyzes binary executables to measure and report code coverage.

Build check Run unit tests

✅ Supported Platforms

  • GNU/Linux (x86_64 only)

📦 Prerequisites

To build and run this tool, you'll need:

  • x86_64 CPU (other architectures are not supported)
  • make
  • Go language compiler
  • g++ version 15 (or any c++ 2017 )
  • Catch2 v2 library (optional, only for running the C++ test suite)
    • A copy is provided in tests/catch2/catch.hpp

🛠️ Build & Run

🔧 Build

Clone the repository:

git clone git@github.com:ilmanzo/BinaryCoverage.git
cd BinaryCoverage/

Download and build the project:

./build.sh

build.sh will:

  • Download and extract Intel Pin locally
  • Build the coverage tool
  • Compile and instrument the example C program in the example/ directory

▶️ Run

Before building, export the PIN_ROOT environment variable:

export PIN_ROOT=../pin-external-4.0-99633-g5ca9893f2-gcc-linux

PIN_ROOT should point to the root directory where Intel Pin was extracted. This is a common convention when building Pin tools.

To run the tool:

$PIN_ROOT/pin -t ./obj-intel64/FuncTracer.so -- <target_binary_path> <args...>

Replace <target_binary_path> and <args...> with your target program and its arguments.

📎 Note on Debug Info

This tool relies on DWARF debugging information to determine line-level coverage. Please compile your target programs with:

gcc -g -gdwarf-4 main.c

Pin 3+ supports DWARF4. Debug info is essential for accurate line mapping.

🧪 Running Unit Tests

To run the unit tests:

Ensure to have gcc installed (required for running Go unit tests)

./run_unit_tests.sh

Uses Catch2 v2 (already included in the repo in tests/catch2/catch.hpp).

🖼️ Modifying the HTML Output

If you just want to modify the HTML report templates, you don't need to rebuild everything.

HTML templates are located in cmd/templates/. You can modify them and preview the results by displaying the HTML in a browser.

🔄 Rebuilding Just the Report Generator

If you change the analyzer logic or Go code:

cd cmd
go build
./cmd report ../example/sample_data /tmp

This generates example HTML reports (with dummy data) under /tmp.

About

Code coverage tool using IntelPin

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • C++ 90.9%
  • Go 5.4%
  • HTML 1.3%
  • Python 0.9%
  • Makefile 0.7%
  • Shell 0.3%
  • Other 0.5%