Oink: a Collaboration of C++ Static Analysis Tools

Maintainer: Daniel S. Wilkerson
Developer: Karl Chen
Developer: Scott McPeak

Introduction

Welcome to Oink! Oink is a collaboration of C++ static analysis tools. The C++ front-end for Oink is Elsa by Scott McPeak. Currently the main tool provided by Oink is Cqual++, a polymorphic whole-program dataflow analysis for C++. Cqual++ was inspired by Jeff Foster's and Cqual tool and shares the backend solver with it.

Companion projects

Directory contents

Page contents

Dependencies

Oink has been tested successfully on recent versions of Linux, Apple OSX, and Cygwin/Windows.

Here are some dependencies (with versions) that I know about and that occurred to me to mention.

Licensing

See License.txt for the the copyright and terms of use of the software in the oink repository and its subdirectories.

Tools

To make Oink easy to learn and build-upon, I have written some small example tools. Each sample tool is a stand-alone executable and does not share infrastructure with other unrelated tools, making it smaller and easier to understand. Oink also provides the Cqual++ tool, a polymorphic whole-program dataflow analysis for C++.

Oink tool

The Oink tool, oink/oink, is the empty analysis: it does nothing. Its features and command-line flags are shared by all other tools. For an exhaustive list of the oink/oink flags and a short description of each, just type: ./oink --help

StaticPrint tool

The StaticPrint tool, oink/staticprint, is intended to print out various facts about a program that can be obtained statically. Currently it prints the inheritance tree and a histogram of AST nodes. Run 'make staticprint-check-print' and then view Test/staticprint1.cc.ihg.dot.ps in a postscript viewer and compare with the source code in Test/staticprint1.cc. See the staticprint_test.incl.mk makefile for other examples. Note that currently this tree is translation-unit-local since staticprint has no linker imitator.

DfgPrint tool

The Dfgprint tool, oink/dfgprint, prints the data flow graph of a C++ program. It is purposefully small and simple so it is easy to see the essentials of writing a dataflow tool. It should be easy to get started on a dataflow analysis by simply copying dfgprint and hacking it. Run 'make dfgprint-check-print' and then view Test/dfgprint1.c.dfg.dot.ps in a postscript viewer and compare with the source code in Test/dfgprint1.c . Note that the graph generation requires that you have the graph layout program 'dot'.

Note that dfgprint prints 'expression-level' dataflow. The dataflow used by the Cqual++ analysis (described below) is the more detailed 'type-level' flow; you can get a graph of that flow by running Cqual++ with the flag -fprint-quals-graph and then running 'dot' on the resulting quals.dot file.

CfgPrint tool

The Cfgprint tool, oink/cfgprint, prints the intra-procedural control flow graph of a C++ program (by delegating to that functionality in Elsa). Similarly to dfgprint it also is purposefully small and simple. Run 'make cfgprint-check-print' and then view Test/cfgprint1.c.cfg.dot.ps in a postscript viewer and compare with the source code in Test/cfgprint1.c .

Note that cfgprint prints a statement-level control flow graph; a more precise expression-level graph could be implemented as (mostly) a refinement of the statement-level flow, but this is not done yet. (It would not be a strict refinement due to the possibility of using a goto to jump out of a gnu expression statement; Yes there is an example of this in the Red Hat 9 source tree.) We don't compute the (inter-procedural) call graph as to do that properly really requires including also a points-to analysis and a dataflow analysis.

Cqual++ tool [further documentation]

The major tool of the current Oink distribution is Cqual++, oink/qual, which checks static assertions about C++ programs that can be expressed as a polymorphic dataflow of type qualifiers. Cqual++ uses libqual to do the inference. Please see the Cqual++ Documentation for more information.

Acknowledgments

The old acknowledgments section was quite out of date. A new section is forthcoming.



Enjoy.

        --- Daniel


© 2002-2006 Daniel S. Wilkerson