stacktraces can now show custom runtime msgs per frame by timotheecour · Pull Request #13351 · nim-lang/Nim (original) (raw)

stacktraces can now show custom runtime msgs per frame.

example:

say you want to debug an internal compiler error such as #12263 which normally gives a regular stacktrace error (with --stacktrace:on);

if we simply add the following line inside proc semExpr(...) (obviously setFrameMsg can be called in other places as needed)

when defined(nimCompilerStackraceHints): setFrameMsg c.config$n.info & " " & $n.kind

it'll show that context in each stackframe corresponding to that (re-entrant) function, which helps showing the progress in the file being compiled:

stacktrace with custom runtime msgs for nim c /pathto/t1015.nim
shows both tracing and traced programs along side:

compiler/nim.nim(118) nim
compiler/nim.nim(95) handleCmdLine
compiler/cmdlinehelper.nim(105) loadConfigsAndRunMainCommand
compiler/main.nim(190) mainCommand
compiler/main.nim(92) commandCompileToC
compiler/modules.nim(143) compileProject
compiler/modules.nim(84) compileModule
compiler/passes.nim(210) processModule
compiler/passes.nim(86) processTopLevelStmt
compiler/sem.nim(600) myProcess
compiler/sem.nim(568) semStmtAndGenerateGenerics
compiler/semstmts.nim(2240) semStmt
compiler/semexprs.nim(986) semExprNoType
compiler/semexprs.nim(2743) semExpr /pathto/t1015.nim(5, 1) nkStmtList
compiler/semstmts.nim(2180) semStmtList
compiler/semexprs.nim(2670) semExpr /pathto/t1015.nim(35, 1) nkWhenStmt
compiler/semexprs.nim(2256) semWhen
compiler/semexprs.nim(2743) semExpr /pathto/t1015.nim(36, 3) nkStmtList
compiler/semstmts.nim(2180) semStmtList
compiler/semexprs.nim(2746) semExpr /pathto/t1015.nim(50, 3) nkLetSection
compiler/semstmts.nim(450) semVarOrLet
compiler/semexprs.nim(64) semExprWithType
compiler/semexprs.nim(2708) semExpr /pathto/t1015.nim(50, 33) nkBracket
compiler/semexprs.nim(557) semArrayConstr
compiler/semexprs.nim(64) semExprWithType
compiler/semexprs.nim(2654) semExpr /pathto/t1015.nim(51, 10) nkPrefix
compiler/semexprs.nim(2248) semMagic
compiler/semexprs.nim(967) semDirectOp
compiler/semexprs.nim(816) semOverloadedCallAnalyseEffects
compiler/semcall.nim(532) semOverloadedCall
compiler/semcall.nim(335) resolveOverloads
compiler/semcall.nim(93) pickBestCandidate
compiler/sigmatch.nim(2522) matches
compiler/sigmatch.nim(2459) matchesAux
compiler/sigmatch.nim(2261) prepareOperand
compiler/semexprs.nim(49) semOperand
compiler/semexprs.nim(2708) semExpr /pathto/t1015.nim(51, 11) nkBracket
compiler/semexprs.nim(557) semArrayConstr
compiler/semexprs.nim(64) semExprWithType
compiler/semexprs.nim(2704) semExpr /pathto/t1015.nim(52, 7) nkPar
compiler/semexprs.nim(2513) semTupleConstr
compiler/semexprs.nim(2435) semTuplePositionsConstr
compiler/semexprs.nim(64) semExprWithType
compiler/semexprs.nim(2615) semExpr /pathto/t1015.nim(52, 54) nkDotExpr
compiler/semexprs.nim(2645) semExpr /pathto/t1015.nim(52, 54) nkCall
compiler/semexprs.nim(272) semConv
compiler/semcall.nim(444) inferWithMetatype
compiler/sigmatch.nim(2171) paramTypesMatch
compiler/sigmatch.nim(2015) paramTypesMatchAux
compiler/sigmatch.nim(1654) typeRel
compiler/sigmatch.nim(1210) typeRel
compiler/types.nim(815) lengthOrd
compiler/types.nim(776) lastOrd
compiler/msgs.nim(565) internalError
compiler/msgs.nim(443) rawMessage
compiler/msgs.nim(440) rawMessage
compiler/msgs.nim(356) handleError
compiler/msgs.nim(346) quit

unrelated changes