Skip to content

Commit 3d709e5

Browse files
committed
add helper scripts
1 parent b8b9007 commit 3d709e5

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# afl-cov - AFL Fuzzing Code Coverage
22

3+
- [Preface](#preface)
34
- [Introduction](#introduction)
45
- [Prerequisites](#prerequisites)
56
- [Workflow](#workflow)
@@ -10,6 +11,20 @@
1011
- [License](#license)
1112
- [Contact](#contact)
1213

14+
## Preface
15+
16+
This is a modified afl-cov fork because the original author's account is
17+
inactive :-(
18+
19+
It has three changes:
20+
* afl-cov now accepts "@@" like AFL++ in the command line
21+
* afl-cov.sh makes using afl-cov easier (just needs two parameters)
22+
* afl-cov-build.sh makes builing a target for coverage easier
23+
24+
Enjoy!
25+
26+
Marc "vanHauser" Heuse
27+
1328
## Introduction
1429
`afl-cov` uses test case files produced by the
1530
[AFL fuzzer](http://lcamtuf.coredump.cx/afl/) `afl-fuzz` to generate gcov code

afl-cov-build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
test -z "$1" -o "$1" = "-h" && {
4+
echo "Syntax: $0 <command> [options]"
5+
echo Sets build options for coverage instrumentation with gcov/lcov.
6+
echo Example: "$0 ./configure --disable-shared"
7+
}
8+
9+
test -z "$CC" && export CC=gcc
10+
test -z "$CXX" && export CXX=g++
11+
export CFLAGS="-fprofile-arcs -ftest-coverage"
12+
export CXXFLAGS="$CFLAGS"
13+
export LDFLAGS="-lgcov --coverage"
14+
15+
$*

afl-cov.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
#
3+
# easy wrapper script for afl-cov
4+
#
5+
test "$1" = "-h" -o -z "$1" && {
6+
echo Syntax: $0 out-dir \"exec cmd --foo @@\"
7+
echo Generates the coverage information for an AFL run.
8+
echo Must be run from the top directory of the coverage build.
9+
echo Example: $0 ../target/out \"tools/target @@\"
10+
exit 1
11+
}
12+
test -d "$1" || { echo Error: not a directory: $1 ; exit 1 ; }
13+
test -e "$1"/queue || { echo Error: not an afl-fuzz -o out directory ; exit 1 ; }
14+
DST=`realpath "$1"`
15+
afl-cov -v -d "$DST" --cover-corpus --coverage-cmd "$2" --code-dir . --overwrite
16+
test -e "$1"/fuzzer_stats && {
17+
echo "runtime :" $(expr `grep last_update "$DST"/fuzzer_stats|awk '{print$3}'` - `grep start_time "$DST"/fuzzer_stats|awk '{print$3}'`) seconds
18+
egrep 'execs_done|paths_total|^unique_|stability' "$DST"/fuzzer_stats
19+
}
20+
echo open "file://$DST/cov/web/index.html"

0 commit comments

Comments
 (0)