Recover and compare code

glaurung graph

Write a call graph or one function's control-flow graph as DOT.

does not write by default 2 worked examples

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

short form
$ 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

from the engine checkout
$ glaurung graph samples/binaries/platforms/linux/amd64/export/native/clang/debug/hello-c-clang-debug callgraph > callgraph.dot

output

captured result captured DOT, shortened
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

from the engine checkout
$ glaurung graph samples/binaries/platforms/linux/amd64/export/native/clang/debug/hello-c-clang-debug cfg main | dot -Tsvg > main-cfg.svg

output

captured result captured after checking the generated file with file(1)
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

callgraph
Write recovered calls between functions.
cfg NAME|VA
Write the basic blocks and edges of one function.
--db PROJECT
Use names stored in a project.
> FILE.dot
Shell redirection keeps the DOT text in a file.

These are the flags used by the examples. Run glaurung graph --help for the complete parser help.

keep working

related commands

← all 40 commands