This commit is contained in:
Araq 2019-01-13 14:05:09 +01:00
commit 0c10fc67eb

View file

@ -85,7 +85,7 @@ proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int; recursionLimit=100) =
add(s, x.prc.name.s)
msgWriteln(c.config, s)
proc stackTrace(c: PCtx, tos: PStackFrame, pc: int,
proc stackTraceImpl(c: PCtx, tos: PStackFrame, pc: int,
msg: string, lineInfo: TLineInfo) =
msgWriteln(c.config, "stack trace: (most recent call last)")
stackTraceAux(c, tos, pc)
@ -93,8 +93,14 @@ proc stackTrace(c: PCtx, tos: PStackFrame, pc: int,
if c.mode == emRepl: globalError(c.config, lineInfo, msg)
else: localError(c.config, lineInfo, msg)
proc stackTrace(c: PCtx, tos: PStackFrame, pc: int, msg: string) =
stackTrace(c, tos, pc, msg, c.debug[pc])
template stackTrace(c: PCtx, tos: PStackFrame, pc: int,
msg: string, lineInfo: TLineInfo) =
stackTraceImpl(c, tos, pc, msg, lineInfo)
return
template stackTrace(c: PCtx, tos: PStackFrame, pc: int, msg: string) =
stackTraceImpl(c, tos, pc, msg, c.debug[pc])
return
proc bailOut(c: PCtx; tos: PStackFrame) =
stackTrace(c, tos, c.exceptionInstr, "unhandled exception: " &