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

View file

@ -446,6 +446,10 @@ proc newProfileData(): ProfileData =
const foreignPackageNotesDefault* = {
hintProcessing, warnUnknownMagic, hintQuitCalled, hintExecuting, hintUser, warnUser}
proc isDefined*(conf: ConfigRef; symbol: string): bool
import debugutils
proc newConfigRef*(): ConfigRef =
result = ConfigRef(
selectedGC: gcRefc,
@ -504,16 +508,21 @@ proc newConfigRef*(): ConfigRef =
# enable colors by default on terminals
if terminal.isatty(stderr):
incl(result.globalOptions, optUseColors)
when defined(nimDebugUtils):
onNewConfigRef(result)
proc newPartialConfigRef*(): ConfigRef =
## create a new ConfigRef that is only good enough for error reporting.
result = ConfigRef(
selectedGC: gcRefc,
verbosity: 1,
options: DefaultOptions,
globalOptions: DefaultGlobalOptions,
foreignPackageNotes: foreignPackageNotesDefault,
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])
when defined(nimDebugUtils):
result = getConfigRef()
else:
result = ConfigRef(
selectedGC: gcRefc,
verbosity: 1,
options: DefaultOptions,
globalOptions: DefaultGlobalOptions,
foreignPackageNotes: foreignPackageNotesDefault,
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])
proc cppDefine*(c: ConfigRef; define: string) =
c.cppDefines.incl define