-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
enable VM tracing in user code via {.define(nimVmTrace).}
#18244
Conversation
But please notice that even after my remarks, the mechanism is most alien. We don't enable features via .define/.undef pragmas in a block scope manner, there are much better mechanisms available. Like: static:
trace:
main1()
|
the only reason I used {define}/{undef} was to avoid adding a magic or vmops, but I agree that a magic or vmops is cleaner (and a bit more efficient) here; i'll update this PR with a magic or vmops (TBD), how about adding that API in (the existing lib/std/private/vmutils.nim is unrelated and can be renamed for clarity) |
814e607
to
7a61955
Compare
PTAL, now using a vmops which is more efficient (single bool flag lookup) and flexible (can be set/unset during the course of VM evaluation, unlike define/undef) see test in PR (nimout is truncated but you can see the full listing by running locally) |
The implementation is ok but don't document it and don't make it an "std" module. I mean, you can document it in our "internal documentation". We don't need a "standard library" extension every time you add a debugging aid. |
seems like all i need is move it regarding documentation, IMO everything should ideally be documented and docgen'd, including compiler (https://nim-lang.github.io/Nim/compiler/theindex.html), including runnableExamples wherever it makes sense; even for APIs that can change; doesn't mean end users need to see those docs, but those docs should be viewable somewhere. stdx can have it's own doc/theindex, just like compiler now has (and listed in https://nim-lang.github.io/Nim/lib.html):
|
Merging it as it is, will move it to lib/dist once we have that. |
…#18244) * enable VM tracing in user code via `{.define(nimVmTrace).}` * add vmutils.vmTrace * add vmTrace
features
This PR allows user code to enable/disable VM tracing in a code section via
{.define(nimVmTrace).}
and{.undef(nimVmTrace).}
.Unlike
-d:nimVMDebug
, this doesn't require re-compiling nim and allows user code to control what sections of code should be traced (-d:nimVMDebug
by contrast generates lots of noise and cannot be controlled by user code). The check whether to trace doesn't slow down VM thanks to a caching mechanism.example
future work
when traceCode:
into a similar flag that can be set similarly, without recompiling nim