Does [Graphviz] actually analyze the code, or do you have to enter a flowchart?
It is just a visualizer, not a code analyser, so you have to write the
.dot file yourself, or use a code analyzer that can generate it for you.
From symbolic assembly or disassembly, you can write a script that reads the mnemonics, generates missing target labels if any, and then the DOT language graph, as long as no computed jumps are used (those with a target address in a register). Some code analysers do support DOT output, and most have a simple text/csv-based output that is easy to turn to DOT. (
awk is a very powerful tool for this.)
If you have an existing codebase with separate function symbols at the node level, and use ELF format object files, you can parse the possible call graph from the
objdump output on many architectures (those where the relocation record uses the target symbol, not the target section with an offset). If each function is put in its own section (via e.g.
-ffunction-sections using GCC or clang), then the call graph can be done on all architectures using ELF object files. I can show an example of this, although one of my not-yet-done projects is writing that in Python 3 (using just
struct.Struct, no other dependencies); it already works (tested on AVR, ARM, x86, a86-64; need to test on a big-endian arch too), but the code is just too ugly to live in public.
In this case, because DOT supports comments (
/* C-style */,
// C/C++ style till the end of the line, and
# at the start of the line), I would suggest writing the pseudocode (as shown in the thread start post)
as a .dot file from the get go. There are also many ways how
nodes and
edges and entire
graphs can be modified, for example many different node shapes exist; so one could use those as well to indicate code section types. Even HTML table node labels are possible.