Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 6, 2021

Conversation

timotheecour
Copy link
Member

add compiler/debugutils.nim; this module (intended to grow) adds utilities to help debugging the compiler.

When nim is built without -d:nimDebugUtils, it has no effect; with -d:nimDebugUtils, it enables some callbacks that help with debugging.

For now this helps with the issue mentioned in #17541, by providing a better fix: instead of SIGSEGV (as before this PR) or returning a dummy path (as with #17541), we return a valid path (see #17541 (comment) for how to reproduce).

We cache a global ConfigRef (again, this is only enabled via -d:nimDebugUtils), which allows client code to access it in any context, without having to forward ConfigRef all the way to the code that requires it during a debugging session, thus making debugging easier.

future work

I've already implemented a number of those in a private fork, so this is a start.

  • add more debugging functionality, counters, etc, all hidden unless -d:nimDebugUtils is specified.
  • better debugging utilities for PNode, PType, PSym; we already have astalgo.debug, but its functionality is limited. I've been using the (fully generic) pretty printing described in Every value should be printable with echo RFCs#203 (comment) which really helps with debugging some compiler issues, when you easily need to inspect recursive cyclic data structures such as PNode, PType, PSym.
  • etc.

more debugging utilies lowers the barrier for fixing compiler bugs.

compiler/options.nim Outdated Show resolved Hide resolved
@timotheecour timotheecour force-pushed the pr_fix_fileInfos_debugging_v2 branch from d5eef73 to e065540 Compare April 6, 2021 17:07
@timotheecour
Copy link
Member Author

PTAL

Copy link
Contributor

@dom96 dom96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Araq Araq merged commit 6ab5816 into nim-lang:devel Apr 6, 2021
@timotheecour timotheecour deleted the pr_fix_fileInfos_debugging_v2 branch April 6, 2021 21:06
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
* add compiler/debugutils.nim

* address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants