diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-03-30 04:45:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 13:45:32 +0200 |
commit | 19cab9fa51fdb9a244ca35e978e9daa8cc81a785 (patch) | |
tree | 18200faaf701d17e1980f31bfa6c3833a6dfba5e /compiler | |
parent | 8088633250872de8777c7078e636b2379780e107 (diff) | |
download | Nim-19cab9fa51fdb9a244ca35e978e9daa8cc81a785.tar.gz |
stacktraces can now show custom runtime msgs per frame (#13351)
* stacktraces can now show custom runtime msgs * improve tests/stdlib/tstackframes.nim * fix test for --gc:arc * test --stacktraceMsgs:on and --stacktraceMsgs:off * --stacktracemsgs:off by default
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/commands.nim | 2 | ||||
-rw-r--r-- | compiler/condsyms.nim | 1 | ||||
-rw-r--r-- | compiler/options.nim | 6 | ||||
-rw-r--r-- | compiler/semexprs.nim | 5 |
4 files changed, 12 insertions, 2 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim index 024e6b417..4caccd165 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -281,6 +281,7 @@ proc testCompileOption*(conf: ConfigRef; switch: string, info: TLineInfo): bool of "hints": result = contains(conf.options, optHints) of "threadanalysis": result = contains(conf.globalOptions, optThreadAnalysis) of "stacktrace": result = contains(conf.options, optStackTrace) + of "stacktracemsgs": result = contains(conf.options, optStackTraceMsgs) of "linetrace": result = contains(conf.options, optLineTrace) of "debugger": result = contains(conf.globalOptions, optCDebug) of "profiler": result = contains(conf.options, optProfiler) @@ -531,6 +532,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; if processOnOffSwitchOrList(conf, {optHints}, arg, pass, info): listHints(conf) of "threadanalysis": processOnOffSwitchG(conf, {optThreadAnalysis}, arg, pass, info) of "stacktrace": processOnOffSwitch(conf, {optStackTrace}, arg, pass, info) + of "stacktracemsgs": processOnOffSwitch(conf, {optStackTraceMsgs}, arg, pass, info) of "excessivestacktrace": processOnOffSwitchG(conf, {optExcessiveStackTrace}, arg, pass, info) of "linetrace": processOnOffSwitch(conf, {optLineTrace}, arg, pass, info) of "debugger": diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index da40dd2b7..b6997e6fc 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -114,3 +114,4 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimHasSinkInference") defineSymbol("nimNewIntegerOps") + defineSymbol("nimHasStacktraceMsgs") diff --git a/compiler/options.nim b/compiler/options.nim index b38b5a6bc..8b2523478 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -28,7 +28,9 @@ type # please make sure we have under 32 options optOverflowCheck, optNilCheck, optRefCheck, optNaNCheck, optInfCheck, optStaticBoundsCheck, optStyleCheck, optAssert, optLineDir, optWarns, optHints, - optOptimizeSpeed, optOptimizeSize, optStackTrace, # stack tracing support + optOptimizeSpeed, optOptimizeSize, + optStackTrace, # stack tracing support + optStackTraceMsgs, # enable custom runtime msgs via `setFrameMsg` optLineTrace, # line tracing support (includes stack tracing) optByRef, # use pass by ref for objects # (for interfacing with C) @@ -325,7 +327,7 @@ const DefaultOptions* = {optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck, optOverflowCheck, optAssert, optWarns, optRefCheck, - optHints, optStackTrace, optLineTrace, + optHints, optStackTrace, optLineTrace, # consider adding `optStackTraceMsgs` optTrMacros, optNilCheck, optStyleCheck, optSinkInference} DefaultGlobalOptions* = {optThreadAnalysis, optExcessiveStackTrace, optListFullPaths} diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index c2f117efa..d6659f76b 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -10,6 +10,9 @@ # this module does the semantic checking for expressions # included from sem.nim +when defined(nimCompilerStackraceHints): + import std/stackframes + const errExprXHasNoType = "expression '$1' has no type (or is ambiguous)" errXExpectsTypeOrValue = "'$1' expects a type or value" @@ -2557,6 +2560,8 @@ proc shouldBeBracketExpr(n: PNode): bool = return true proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = + when defined(nimCompilerStackraceHints): + setFrameMsg c.config$n.info & " " & $n.kind result = n if c.config.cmd == cmdIdeTools: suggestExpr(c, n) if nfSem in n.flags: return |