This backend produces visual representations of a P4 program as dot files. For now it only supports the generation of graphs for top-level control and parser blocks.
In addition to other p4c dependencies, this backend requires the Boost graph
headers. On a Debian system, they can be installed with sudo apt-get install libboost-graph-dev
.
mkdir out
p4c-graphs <prog.p4> --graphs-dir out
cd out
dot <name>.dot -Tpng > <name>.png
Here is the graph generated for the ingress control block of the flowlet_switching-bmv2.p4 test program:
Here is the graph generated for the parser block of the flowlet_switching-bmv2.p4 test program:
For a more complex example, you can look at the control graph generated for the egress control of switch.p4 here.