aboutsummaryrefslogtreecommitdiff
path: root/lib/v.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/v.lua')
-rw-r--r--lib/v.lua26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/v.lua b/lib/v.lua
index 93f1cbb2..649bbf8d 100644
--- a/lib/v.lua
+++ b/lib/v.lua
@@ -73,17 +73,23 @@ local active, out
73 73
74local startloc, startex 74local startloc, startex
75 75
76local function fmtfunc(func, pc)
77 local fi = funcinfo(func, pc)
78 if fi.loc then
79 return fi.loc
80 elseif fi.ffid then
81 return vmdef.ffnames[fi.ffid]
82 elseif fi.addr then
83 return format("C:%x", fi.addr)
84 else
85 return "(?)"
86 end
87end
88
76-- Format trace error message. 89-- Format trace error message.
77local function fmterr(err, info) 90local function fmterr(err, info)
78 if type(err) == "number" then 91 if type(err) == "number" then
79 if type(info) == "function" then 92 if type(info) == "function" then info = fmtfunc(info) end
80 local fi = funcinfo(info)
81 if fi.ffid then
82 info = vmdef.ffnames[fi.ffid]
83 else
84 info = fi.loc
85 end
86 end
87 err = format(vmdef.traceerr[err], info) 93 err = format(vmdef.traceerr[err], info)
88 end 94 end
89 return err 95 return err
@@ -92,11 +98,11 @@ end
92-- Dump trace states. 98-- Dump trace states.
93local function dump_trace(what, tr, func, pc, otr, oex) 99local function dump_trace(what, tr, func, pc, otr, oex)
94 if what == "start" then 100 if what == "start" then
95 startloc = funcinfo(func, pc).loc 101 startloc = fmtfunc(func, pc)
96 startex = otr and "("..otr.."/"..oex..") " or "" 102 startex = otr and "("..otr.."/"..oex..") " or ""
97 else 103 else
98 if what == "abort" then 104 if what == "abort" then
99 local loc = funcinfo(func, pc).loc 105 local loc = fmtfunc(func, pc)
100 if loc ~= startloc then 106 if loc ~= startloc then
101 out:write(format("[TRACE --- %s%s -- %s at %s]\n", 107 out:write(format("[TRACE --- %s%s -- %s at %s]\n",
102 startex, startloc, fmterr(otr, oex), loc)) 108 startex, startloc, fmterr(otr, oex), loc))