add compiler/debugutils.nim to help debugging compiler (#17652)

* add compiler/debugutils.nim

* address comments
This commit is contained in:
Timothee Cour 2021-04-06 13:01:34 -07:00 • committed by GitHub
commit 6ab5816866
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 7 deletions

19
compiler/debugutils.nim Normal file
View file

@ -0,0 +1,19 @@
##[
Utilities to help with debugging nim compiler.
Experimental API, subject to change.
]##
import options
var conf0: ConfigRef
proc onNewConfigRef*(conf: ConfigRef) {.inline.} =
## Caches `conf`, which can be retrieved with `getConfigRef`.
## This avoids having to forward `conf` all the way down the call chain to
## procs that need it during a debugging session.
conf0 = conf
proc getConfigRef*(): ConfigRef =
## nil, if -d:nimDebugUtils wasn't specified
result = conf0