Software /
code /
prosody
Comparison
tools/linedebug.lua @ 11193:5850d24a4ad3
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 28 Oct 2020 23:05:15 +0100 |
comparison
equal
deleted
inserted
replaced
11192:11f285a439a4 | 11193:5850d24a4ad3 |
---|---|
1 local data = {} | |
2 local getinfo = debug.getinfo; | |
3 local function linehook(ev, li) | |
4 local S = getinfo(2, "S"); | |
5 if S and S.source and S.source:match"^@" then | |
6 local file = S.source:sub(2); | |
7 local lines = data[file]; | |
8 if not lines then | |
9 lines = {}; | |
10 data[file] = lines; | |
11 for line in io.lines(file) do | |
12 lines[#lines+1] = line; | |
13 end | |
14 end | |
15 io.stderr:write(ev, " ", file, " ", li, " ", lines[li], "\n"); | |
16 end | |
17 end | |
18 debug.sethook(linehook, "l"); |