diff options
author | Kim Alvefur <zash@zash.se> | 2020-10-28 23:05:15 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-10-28 23:05:15 +0100 |
commit | 0219adfe3e83d6916a038e4b80b9754e37dcdac3 (patch) | |
tree | d0e4f0ad1dc1f7d69c7cae986212b07b111be7c2 | |
parent | 12fc380f8da7b9b57eb806533925bb868a9be01d (diff) | |
download | prosody-0219adfe3e83d6916a038e4b80b9754e37dcdac3.tar.gz prosody-0219adfe3e83d6916a038e4b80b9754e37dcdac3.zip |
tools/linedebug: Print each line of source executed
The extremely verbose debug output. Nice for getting some idea which
code runs most often, or where it pauses for no reason etc.
-rw-r--r-- | tools/linedebug.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/linedebug.lua b/tools/linedebug.lua new file mode 100644 index 00000000..96214cc8 --- /dev/null +++ b/tools/linedebug.lua @@ -0,0 +1,18 @@ +local data = {} +local getinfo = debug.getinfo; +local function linehook(ev, li) + local S = getinfo(2, "S"); + if S and S.source and S.source:match"^@" then + local file = S.source:sub(2); + local lines = data[file]; + if not lines then + lines = {}; + data[file] = lines; + for line in io.lines(file) do + lines[#lines+1] = line; + end + end + io.stderr:write(ev, " ", file, " ", li, " ", lines[li], "\n"); + end +end +debug.sethook(linehook, "l"); |