Lancern / llvm-covmap

Profiling for code coverage via bitmap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

llvm-covmap

Build Passing LLVM 10.0.0

LLVM passes and utilities that instruments code to profile for function-level code coverage via bitmap during program runtime.

Build

Build Prerequisites

  • CMake version >= 3.12
  • LLVM

To install LLVM on your platform, execute the following command:

sudo apt install llvm-dev

It's recommended to use LLVM version 10.0.0. Other versions of LLVM might work as well, but they are not tested. To check the LLVM version on your system, execute the following command:

llvm-config --version

Build Steps

Clone the repository:

git clone https://github.com/Lancern/llvm-covmap.git
cd llvm-covmap

Create a build directory:

mkdir build
cd build

Build the project using the familiar two-step build:

cmake ..
cmake --build .

The output files are generated in the lib/ directory in the build tree.

Usage

For advanced usage of llvm-covmap, please refer to docs.

To simplify examples, we assume that the LLVM_COVMAP_BUILD_DIR environment is set to the root of the build tree.

Instrument LLVM modules by hand:

opt -load $LLVM_COVMAP_BUILD_DIR/lib/libLLVMCoverageMapPass.so -covmap \
  -o=instrumented-module.bc \
  input-module.bc

End-to-end build using the drop-in replacement of clang and clang++:

# Compile only, do not link
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-clang -c -o example.o example.c

# End-to-end compile is supported
# All necessary runtime libraries required by llvm-covmap will be linked automatically
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-clang -o example example.c
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-clang++ -o example example.cpp

One-shot run an instrumented program and dump the coverage information:

$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-shell ls

Contribute

This project is built for private use so we don't accept any feature requests or pull requests. But you're free to fork your own copy of this project and add modifications to fit your need.

License

This repository is open-sourced under the MIT license.

About

Profiling for code coverage via bitmap

License:MIT License


Languages

Language:C++ 73.1%Language:C 13.8%Language:CMake 11.2%Language:Shell 1.9%