aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-15 17:36:29 +0100
committerMike Pall <mike>2010-02-15 17:36:29 +0100
commit3452bfcf8cb2dc67819485c7b011e5c6a59310f8 (patch)
treeef9296179854170d517ed02bdfc51f2003ceedf0 /lib
parentb838cd8dca67c8ea251faf71408a9d4c45fd0daf (diff)
downloadluajit-3452bfcf8cb2dc67819485c7b011e5c6a59310f8.tar.gz
luajit-3452bfcf8cb2dc67819485c7b011e5c6a59310f8.tar.bz2
luajit-3452bfcf8cb2dc67819485c7b011e5c6a59310f8.zip
Add generic function handling for debug modules.
Don't call record vmevent for non-Lua functions.
Diffstat (limited to 'lib')
-rw-r--r--lib/dump.lua42
-rw-r--r--lib/v.lua26
2 files changed, 34 insertions, 34 deletions
diff --git a/lib/dump.lua b/lib/dump.lua
index be456aa0..c12b0ba8 100644
--- a/lib/dump.lua
+++ b/lib/dump.lua
@@ -227,6 +227,19 @@ local function ctlsub(c)
227 end 227 end
228end 228end
229 229
230local function fmtfunc(func, pc)
231 local fi = funcinfo(func, pc)
232 if fi.loc then
233 return fi.loc
234 elseif fi.ffid then
235 return vmdef.ffnames[fi.ffid]
236 elseif fi.addr then
237 return format("C:%x", fi.addr)
238 else
239 return "(?)"
240 end
241end
242
230local function formatk(tr, idx) 243local function formatk(tr, idx)
231 local k, t, slot = tracek(tr, idx) 244 local k, t, slot = tracek(tr, idx)
232 local tn = type(k) 245 local tn = type(k)
@@ -240,12 +253,7 @@ local function formatk(tr, idx)
240 elseif tn == "string" then 253 elseif tn == "string" then
241 s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) 254 s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub))
242 elseif tn == "function" then 255 elseif tn == "function" then
243 local fi = funcinfo(k) 256 s = fmtfunc(k)
244 if fi.ffid then
245 s = vmdef.ffnames[fi.ffid]
246 else
247 s = fi.loc
248 end
249 elseif tn == "table" then 257 elseif tn == "table" then
250 s = format("{%p}", k) 258 s = format("{%p}", k)
251 elseif tn == "userdata" then 259 elseif tn == "userdata" then
@@ -428,14 +436,7 @@ local recdepth = 0
428-- Format trace error message. 436-- Format trace error message.
429local function fmterr(err, info) 437local function fmterr(err, info)
430 if type(err) == "number" then 438 if type(err) == "number" then
431 if type(info) == "function" then 439 if type(info) == "function" then info = fmtfunc(info) end
432 local fi = funcinfo(info)
433 if fi.ffid then
434 info = vmdef.ffnames[fi.ffid]
435 else
436 info = fi.loc
437 end
438 end
439 err = format(vmdef.traceerr[err], info) 440 err = format(vmdef.traceerr[err], info)
440 end 441 end
441 return err 442 return err
@@ -452,16 +453,14 @@ local function dump_trace(what, tr, func, pc, otr, oex)
452 if dumpmode.H then out:write('<pre class="ljdump">\n') end 453 if dumpmode.H then out:write('<pre class="ljdump">\n') end
453 out:write("---- TRACE ", tr, " ", what) 454 out:write("---- TRACE ", tr, " ", what)
454 if otr then out:write(" ", otr, "/", oex) end 455 if otr then out:write(" ", otr, "/", oex) end
455 local fi = funcinfo(func, pc) 456 out:write(" ", fmtfunc(func, pc), "\n")
456 out:write(" ", fi.loc, "\n")
457 recprefix = "" 457 recprefix = ""
458 reclevel = 0 458 reclevel = 0
459 elseif what == "stop" or what == "abort" then 459 elseif what == "stop" or what == "abort" then
460 out:write("---- TRACE ", tr, " ", what) 460 out:write("---- TRACE ", tr, " ", what)
461 recprefix = nil 461 recprefix = nil
462 if what == "abort" then 462 if what == "abort" then
463 local fi = funcinfo(func, pc) 463 out:write(" ", fmtfunc(func, pc), " -- ", fmterr(otr, oex), "\n")
464 out:write(" ", fi.loc, " -- ", fmterr(otr, oex), "\n")
465 else 464 else
466 local link = traceinfo(tr).link 465 local link = traceinfo(tr).link
467 if link == tr then 466 if link == tr then
@@ -487,12 +486,7 @@ local function dump_record(tr, func, pc, depth, callee)
487 local line = bcline(func, pc, recprefix) 486 local line = bcline(func, pc, recprefix)
488 if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end 487 if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end
489 if type(callee) == "function" then 488 if type(callee) == "function" then
490 local fi = funcinfo(callee) 489 out:write(sub(line, 1, -2), " ; ", fmtfunc(callee), "\n")
491 if fi.ffid then
492 out:write(sub(line, 1, -2), " ; ", vmdef.ffnames[fi.ffid], "\n")
493 else
494 out:write(sub(line, 1, -2), " ; ", fi.loc, "\n")
495 end
496 else 490 else
497 out:write(line) 491 out:write(line)
498 end 492 end
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))