Generate a call graph of Lua programs.
Create new capture instance.
syntax: graph.new(cfg)
Supported configs:
name
: call graph namefilename
: name for the call graph.dot
file (defaults toname
)
syntax: graph:capture()
Starts capturing the call graph from that point in the program.
syntax: graph:stop()
Stops capturing the call graph. A subsequent call to :emit
generates the
call graph.
syntax: graph:emit()
Emits the captured call graph named name
into the DOT file filename
.
Given the Lua code below
local graph = require"graph"
function a()
b()
end
function b()
c()
print()
end
function c()
d()
end
function d()
print("")
end
local g = graph.new({
name = "callgraph",
filename = "graph.dot",
})
g:capture()
a()
g:stop()
c()
g:emit()
the library outputs the following call graph: