Recover and compare code
glaurung graph
Write a call graph or one function's control-flow graph as DOT.
use it for
DOT files can be rendered with Graphviz. The command writes graph text to standard output.
Run glaurung graph --help on your installed version before putting the command in a script.
Glaurung is still pre-1.0.
- input
- A native binary plus callgraph, or cfg followed by a function name or VA.
- output
- GraphViz DOT on standard output.
- mode
- read only. The examples leave the input unchanged.
command shape
syntax
$ glaurung graph PATH {callgraph|cfg} ...
The installed parser is authoritative: glaurung graph --help
run it
examples
Write the call graph
The command emits text. Redirect it before opening it with GraphViz.
run
$ glaurung graph samples/binaries/platforms/linux/amd64/export/native/clang/debug/hello-c-clang-debug callgraph > callgraph.dot output
digraph callgraph {
rankdir=LR;
node [shape=box, fontname=monospace, fontsize=10];
"_start" [style=filled, fillcolor=lightyellow];
"main" [style=filled, fillcolor=lightyellow];
"print_sum";
"printf@plt";
"main" -> "printf@plt";
"main" -> "print_sum";
} captured DOT, shortened.
Read the result: A missing edge can mean an unresolved indirect call. DOT records recovered structure, not a complete runtime trace.
Render main to SVG
GraphViz reads the DOT file and writes an SVG you can open in a browser.
run
$ glaurung graph samples/binaries/platforms/linux/amd64/export/native/clang/debug/hello-c-clang-debug cfg main | dot -Tsvg > main-cfg.svg output
main-cfg.svg: SVG XML document captured after checking the generated file with file(1).
Read the result: The shell redirects both stages, so success is a file rather than terminal text. Open the SVG or keep the DOT source for review and diffs.
used above
important options
These are the flags used by the examples. Run glaurung graph --help for the complete parser help.
keep working