diff options
| author | Mike Pall <mike> | 2010-02-15 17:36:29 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2010-02-15 17:36:29 +0100 |
| commit | 3452bfcf8cb2dc67819485c7b011e5c6a59310f8 (patch) | |
| tree | ef9296179854170d517ed02bdfc51f2003ceedf0 /lib/v.lua | |
| parent | b838cd8dca67c8ea251faf71408a9d4c45fd0daf (diff) | |
| download | luajit-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/v.lua')
| -rw-r--r-- | lib/v.lua | 26 |
1 files changed, 16 insertions, 10 deletions
| @@ -73,17 +73,23 @@ local active, out | |||
| 73 | 73 | ||
| 74 | local startloc, startex | 74 | local startloc, startex |
| 75 | 75 | ||
| 76 | local 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 | ||
| 87 | end | ||
| 88 | |||
| 76 | -- Format trace error message. | 89 | -- Format trace error message. |
| 77 | local function fmterr(err, info) | 90 | local 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. |
| 93 | local function dump_trace(what, tr, func, pc, otr, oex) | 99 | local 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)) |
