Various 3rd-party benchmarking suites exist for static analysis tools:
collections of source files with and without problems for various CWEs.

This is great, but exactly how they express "ground truth" about which
tests a tool should complain about, and what build flags and
dependencies there are per test vary between the suites.

So I've created a new harness for using them for testing GCC's -
fanalyzer option:
  https://github.com/davidmalcolm/gcc-analyzer-benchmarks
running them, generating scores, diffing two runs, etc.  The tool is
called "gab":

$ ./bin/gab --help
usage: gab [-h] [--version] [-c PATH] [--color {auto,always,never}] [-f 
{text,json,html}]
           [--json] [--html]
           {suites,toolchains,run,score,diff,failures,show} ...

Benchmark GCC's static analyzer (-fanalyzer).

positional arguments:
  {suites,toolchains,run,score,diff,failures,show}
    suites              list configured suites
    toolchains          list configured compilers
    run                 run a suite under a compiler
    score               score a run directory
    diff                compare two run directories
    failures            list the false positives and false negatives in a run
    show                dump a run directory as JSON

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -c, --config PATH     config file (default: ./config.json or $GAB_CONFIG)
  --color {auto,always,never}
                        colourise output (default: auto -- on only when writing 
to a
                        terminal, never under NO_COLOR)
  -f, --format {text,json,html}
                        output format (default: text)
  --json                shorthand for --format json
  --html                shorthand for --format html


It's separate from the main GCC repo since it's more of a specialized
benchmarking harness (also, essentially all the code was written by AI
under my guidance, which isn't acceptable for the regular GCC repos,
but seems fine to me for this kind of "glue" code).  I've MIT-licensed
it.

Comparing GCC 16 and trunk already shows a modest improvement in
results; see the attached HTML "diff" report (it can also output as
text or as json).

Currently it only knows about 2 relatively small test suites:

  benchproctor-c      1140 tests   570 vulnerable   19 categories     0 with 
line truth   v2026.11.19.1+g23a5f7bd
  castle-c250          250 tests   150 vulnerable   25 categories   150 with 
line truth   v1.2+gc7391c9

but I plan to add more.

I plan to use this when testing patches for -fanalyzer and possibly
wire it up to bunsen.  The tool is also highlighting some pre-existing
analyzer bugs I hadn't spotted before.

Hope others find this useful.
Dave

Attachment: diff.html
Description: application/xhtml

Reply via email to