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

src: make debug_options getters public #30494

Closed
wants to merge 1 commit into from

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Nov 15, 2019

Refs #30466.

Now that Electron is parsing and passing CLI options, we can set DebugOptions ourselves through ParseGlobalArgs. However, we also need to create and start the inspector agent with the DebugOptions set by users, since the inspector agent Start function takes a parameter const DebugOptions& options.

The most straightforward way to do this is for us to pass env->options()->debug_options() to our inspector agent Start call, but since debug_options was defined in src/node_options-inl.h we'd need to require extra files to do what could trivially be consolidated into one. This PR therefore moves those definitions into a public-facing file, allowing us to pass correct options to the inspector without needing to parse all-new ones we'd previously parsed on startup.

cc @joyeecheung @addaleax

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Nov 15, 2019
@codebytere codebytere added the embedding Issues and PRs related to embedding Node.js in another project. label Nov 15, 2019
@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

This has me scratching my head a lot…

However, we also need to create and start the inspector agent with the DebugOptions set by users

I think this is the main issue here – we should get Electron away from having to do this manually, and provide an API for that, rather than exposing various internals. In #30467, inspector setup would be moved into LoadEnvironment() (i.e. part of a public API), so it would be awesome if you could take a look at that, both from a general API perspective and regarding how it affects Electron specifically.

The most straightforward way to do this is for us to pass env->options()->debug_options() to our inspector agent Start call, but since debug_options was defined in src/node_options-inl.h we couldn't do that. This PR therefore moves those definitions into a public-facing file, allowing us to pass correct options to the inspector without needing to parse all-new ones we'd previously parsed on startup.

I’m a bit confused by this – src/node_options.h and src/node_options-inl.h should both be available to Electron in the same way, and neither of them are public-facing (anything guarded by NODE_WANT_INTERNALS is private), so I’m surprised that this PR improves the situation for Electron? I feel like learning a bit more about why and how it does that might help me understand more about how Electron uses Node’s source tree.

@joyeecheung joyeecheung mentioned this pull request Nov 19, 2019
4 tasks
@codebytere
Copy link
Member Author

@addaleax since debug_options was defined in src/node_options-inl.h we'd need to require an extra file to do what could trivially be consolidated into one. This just simplifies our requires, since we already require the other file.

@addaleax
Copy link
Member

@codebytere Going by that, it’s probably the simplest solution if you only include the -inl.h file?

But yeah, you can feel free to go ahead and land this – just maybe update the commit message so it doesn’t give the impression that something’s being made part of the public API?

@codebytere
Copy link
Member Author

Will do! thanks :)

@codebytere codebytere added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 13, 2019
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

codebytere added a commit that referenced this pull request Dec 14, 2019
This simplifies requires for those using DebugOptions,
since debug_options was defined in src/node_options-inl.h  and thus
embedders would need to require an extra file to do what could
trivially be consolidated into one.

PR-URL: #30494
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
@codebytere
Copy link
Member Author

codebytere commented Dec 14, 2019

Landed in ccdd6ef

@codebytere codebytere closed this Dec 14, 2019
@codebytere codebytere deleted the move-debug-options branch December 14, 2019 14:46
MylesBorins pushed a commit that referenced this pull request Dec 17, 2019
This simplifies requires for those using DebugOptions,
since debug_options was defined in src/node_options-inl.h  and thus
embedders would need to require an extra file to do what could
trivially be consolidated into one.

PR-URL: #30494
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 17, 2019
targos pushed a commit that referenced this pull request Jan 14, 2020
This simplifies requires for those using DebugOptions,
since debug_options was defined in src/node_options-inl.h  and thus
embedders would need to require an extra file to do what could
trivially be consolidated into one.

PR-URL: #30494
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
This simplifies requires for those using DebugOptions,
since debug_options was defined in src/node_options-inl.h  and thus
embedders would need to require an extra file to do what could
trivially be consolidated into one.

PR-URL: #30494
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. embedding Issues and PRs related to embedding Node.js in another project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants