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

JavaScript debug statements #18851

Closed
BridgeAR opened this issue Feb 18, 2018 · 7 comments
Closed

JavaScript debug statements #18851

BridgeAR opened this issue Feb 18, 2018 · 7 comments
Labels
meta Issues and PRs related to the general management of the project.

Comments

@BridgeAR
Copy link
Member

I personally would some times like to have some debug calls for internal APIs e.g. the internal errors. It would make the API easier to use by just verifying the input but only when run by our test suite. We are all human and make mistakes. So it should behave similar to a DCHECK in C++ but just in JS. Because I would not want to have those checks run in production.

Do we want to introduce something like that? (Or do we actually already have that and I just missed that?)

I guess there are two ways of implementing something like that:

a) A macro
b) A simple if (env.NODE_DEBUG_INTERNAL === 'true') {}

What do others @nodejs/collaborators think?

@BridgeAR BridgeAR added the meta Issues and PRs related to the general management of the project. label Feb 18, 2018
@devsnek
Copy link
Member

devsnek commented Feb 18, 2018

we can pretty easily adapt the DTRACE_* macro system, i'd be willing to make a pr

@AndreasMadsen
Copy link
Member

There was some work that went into a //CHECK(statement); comment that could be enabled.

@BridgeAR
Copy link
Member Author

Nice, do you know where I can find some further info about it?

@targos
Copy link
Member

targos commented Feb 18, 2018

I think our JS files are preprocessed by a python script before ending up in the binary. It might be somewhere inside it?

@hashseed
Copy link
Member

I think our JS files are preprocessed by a python script before ending up in the binary. It might be somewhere inside it?

The version of js2c.py in V8 indeed supports macro expansion (as defined either inline or in macros.py). It should be easy to select a macro file depending on build mode.

@Fishrock123
Copy link
Contributor

I had discussed making debug macro comments with @trevnorris for async-hooks but the idea never got anywhere. I think this would be a good idea for core development/debugging.

@benjamingr benjamingr changed the title Javascript debug statements JavaScript debug statements Feb 19, 2018
@richardlau
Copy link
Member

As #18852 landed can this be closed? There's follow up in #19503.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Issues and PRs related to the general management of the project.
Projects
None yet
Development

No branches or pull requests

8 participants