GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - gszr/lua-call-graph: Generate the call graph of a Lua program

BranchesTags
Open more actions menu

Latest commit

 

History

14 Commits
14 Commits

Folders and files

NameName
Last commit message
Last commit date
test
test
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
callgraph-0.3.0-1.rockspec
callgraph-0.3.0-1.rockspec
 
 
callgraph.lua
callgraph.lua
 
 

Repository files navigation

Lua Call Graph

Generate a call graph of Lua programs.

API

new

Create new capture instance.

syntax: graph.new(cfg)

Supported configs:

  • name: call graph name
  • filename: name for the call graph .dot file (defaults to name)
  • ignores: an array of function names to redact from the .dot file
  • separator: the character to use as separator for spaces1
  • mappings: a translation map of function names; if a function mamed key is found, it's renamed with value

:capture

syntax: graph:capture()

Starts capturing the call graph from that point in the program.

:stop

syntax: graph:stop()

Stops capturing the call graph. A subsequent call to :emit generates the call graph.

:emit

syntax: graph:emit()

Emits the captured call graph named name into the DOT file filename.

Example

Given the Lua code below

local callgraph = require"callgraph"

function a()
  b()
end

function b()
  c()
  print()
end

function c()
  local t = {"a", "b"}
  for _, _ in pairs(t) do end
  d()
end

function d()
  print("")
end

local g = callgraph.new({
  name = "callgraph",
  filename = "graph.dot",
  ignores = {"something"},
})

g:capture()
pcall(a) -- this one is found
pcall(function() end) -- this one cannot be found - so shows as unknown
g:stop()
c()
g:emit()

the library outputs the following call graph:

call graph

Footnotes

  1. Some internal function names might contain spaces. For example, for iterator. The separator value will be used to replace these spaces. ↩

About

Generate the call graph of a Lua program

Topics

call-graphcallgraphlua

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.