[ANN] Lua Callgraph Generator (lcg)

140 views
Skip to first unread message

Martin Eden

unread,
Jul 15, 2026, 1:22:33 PMJul 15
to lu...@googlegroups.com
Hello list,

I want to announce my latest obsession of past three days --
callgraph generator.

Basically it's wrapper over "luac -l". You give program path to
Lua source file. It will compile and process it's bytecode
to generate VM instructions sequences graphs.

Graphs (source file can have several closures, so there can be several
graphs) are stored into plaintext formats (.dot and .tgf) inside
./output/.

Layout and conversion to image can be nicely done by "dot" from
Graphviz suite.

  https://github.com/martin-eden/Lua-Callgraph

It's early prototype so I'm interested in your feedback.

-- Martin

Martin Eden

unread,
Jul 24, 2026, 3:33:17 PMJul 24
to lu...@googlegroups.com
Hello list, I've finished work on this tool.

It allows you to generate image of execution flow for any Lua source code.

Now it's standalone Lua file.

  https://github.com/martin-eden/Lua-Callgraph

I think generated ".svg"'s are worthy addition to "luac.nl" functionality.

( As usual: "no batteries required", all code is mine, all feedback is
welcome. )

-- Martin

George Georgalis

unread,
Jul 24, 2026, 7:27:39 PMJul 24
to lu...@googlegroups.com
Hi,
Thanks for the tool, and followup, I missed the original post.
If you're not adverse to llm, I've found they are really good
at generating styles, such as colors, shapes, and fonts for dot.
I've not looked at the code closely enough to understand
classes of nodes and edges, but distinguishing the types
with shape, pen style, and color can inform graph analysis.
A great tool, the style sheet is only an enhancement suggestion.
-George


--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/8250ba1d-d53e-44b1-b438-166691221b12%40disroot.org.


--

Sainan

unread,
Jul 25, 2026, 3:27:21 AMJul 25
to lu...@googlegroups.com
Back in my day, we used to google and read the manual. Graphviz DOT is a great tool to learn: https://graphviz.org/doc/info/attrs.html

-- Sainan

Martin Eden

unread,
Jul 25, 2026, 11:39:18 AMJul 25
to lu...@googlegroups.com
On 2026-07-25 01:27, George Georgalis wrote:
> Hi,
> Thanks for the tool, and followup, I missed the original post.
> If you're not adverse to llm, I've found they are really good
> at generating styles, such as colors, shapes, and fonts for dot.
> I've not looked at the code closely enough to understand
> classes of nodes and edges, but distinguishing the types
> with shape, pen style, and color can inform graph analysis.
> A great tool, the style sheet is only an enhancement suggestion.
> -George

Thanks for the kind words, George!

Graph rendering is out of scope of this tool. (But can be done
downstream by processing generated .dot files.)

Core code answers riddles like

  Instruction 9 is "TFORPREP 8 38". What is the next instruction?
                                                           84: rewsnA

Serializers to .tgf and .dot doing _capitalization_ of results.
And shell script that converts .dot to .svg doing _commercialization_.

I want this tool be complete in some sense. So it must stay simple.

-- Martin

George Georgalis

unread,
Jul 25, 2026, 2:16:03 PMJul 25
to lu...@googlegroups.com
On Sat, Jul 25, 2026 at 8:39 AM 'Martin Eden' via lua-l <lu...@googlegroups.com> wrote:

I want this tool be complete in some sense. So it must stay simple.


I guess what I was getting at is, in order to do the input trace, the code must have some coherence toward the nature of the nodes and edges captured (their respective component classes) during the walk; and that would be the optimal time to inlay style types in the dot data. eg for all the types of nodes and edges you discover indicate that class in the node, that way colors and shapes can be defined as dot preamble (stylesheet). In the simplest sense, I could post-process the dot to make "GETUPVAL" a parallelogram node, "TEST" a diamond, and related style attributes. But differentiating edges would be more tricky. I was just imagining the class type data would be convenient writing into the dot. Even if left as default ellipse...

...I guess dot doesn't support node classes! so node style definition would need to aggregate each node type together
{  "Close 8" "Close 9" "Close 10" bgcolor="green" shape=circle };
and edge styles would just not be practical...

nevertheless differentiating node/edge classes within the graph, would inform the analysis, in a similar way the graph uplifts analysis, from the text. :-}

There is a powerful commercial tool made free, Sourcetrail which is the only one I bookmark, it doesn't do scripting languages though.

I made a function call to dot code parser but it only showed function dependencies. Once you need a tool like this, the value really comes through!

Best regards,
George
Reply all
Reply to author
Forward
0 new messages