significantly better stack traces when templates are involved
This commit is contained in:
parent
a88a965c6d
commit
31bc063f2d
1 changed files with 12 additions and 8 deletions
|
|
@ -191,21 +191,25 @@ proc freshLineInfo(p: BProc; info: TLineInfo): bool =
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc genLineDir(p: BProc, t: PNode) =
|
proc genLineDir(p: BProc, t: PNode) =
|
||||||
var line = t.info.safeLineNm
|
var tt = t
|
||||||
|
while tt.kind in {nkStmtListExpr}+nkCallKinds:
|
||||||
|
tt = tt.lastSon
|
||||||
|
let line = tt.info.safeLineNm
|
||||||
|
|
||||||
if optEmbedOrigSrc in gGlobalOptions:
|
if optEmbedOrigSrc in gGlobalOptions:
|
||||||
add(p.s(cpsStmts), ~"//" & t.info.sourceLine & rnl)
|
add(p.s(cpsStmts), ~"//" & tt.info.sourceLine & rnl)
|
||||||
genCLineDir(p.s(cpsStmts), t.info.toFullPath, line)
|
genCLineDir(p.s(cpsStmts), tt.info.toFullPath, line)
|
||||||
if ({optStackTrace, optEndb} * p.options == {optStackTrace, optEndb}) and
|
if ({optStackTrace, optEndb} * p.options == {optStackTrace, optEndb}) and
|
||||||
(p.prc == nil or sfPure notin p.prc.flags):
|
(p.prc == nil or sfPure notin p.prc.flags):
|
||||||
if freshLineInfo(p, t.info):
|
if freshLineInfo(p, tt.info):
|
||||||
linefmt(p, cpsStmts, "#endb($1, $2);$n",
|
linefmt(p, cpsStmts, "#endb($1, $2);$n",
|
||||||
line.rope, makeCString(toFilename(t.info)))
|
line.rope, makeCString(toFilename(tt.info)))
|
||||||
elif ({optLineTrace, optStackTrace} * p.options ==
|
elif ({optLineTrace, optStackTrace} * p.options ==
|
||||||
{optLineTrace, optStackTrace}) and
|
{optLineTrace, optStackTrace}) and
|
||||||
(p.prc == nil or sfPure notin p.prc.flags) and t.info.fileIndex >= 0:
|
(p.prc == nil or sfPure notin p.prc.flags) and tt.info.fileIndex >= 0:
|
||||||
if freshLineInfo(p, t.info):
|
if freshLineInfo(p, tt.info):
|
||||||
linefmt(p, cpsStmts, "nimln($1, $2);$n",
|
linefmt(p, cpsStmts, "nimln($1, $2);$n",
|
||||||
line.rope, t.info.quotedFilename)
|
line.rope, tt.info.quotedFilename)
|
||||||
|
|
||||||
proc postStmtActions(p: BProc) {.inline.} =
|
proc postStmtActions(p: BProc) {.inline.} =
|
||||||
add(p.s(cpsStmts), p.module.injectStmt)
|
add(p.s(cpsStmts), p.module.injectStmt)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue