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: moving dispatch_debug_messages_async to Environment #7358

Closed

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Jun 22, 2016

Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

src

Description of change

This commit attempts to fix one of the items in
#4641, which was to move
dispatch_debug_messages_async to the Environment class.

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 22, 2016
@bnoordhuis
Copy link
Member

The intent of the TODO is to make the async handle a non-static Environment member, with the larger goal of being able to start a debugger per context. Making the handle a static member doesn't gain us much, it's really just moving code around.

@danbev
Copy link
Contributor Author

danbev commented Jun 22, 2016

@bnoordhuis Ah, that makes sense. I was not entirely sure when reading the TODO comment but thought it would become clear with a PR which it has. Let me take another stab at this.

This commit attempts to fix one of the items in
nodejs#4641, which was to move
dispatch_debug_messages_async to the Environment class.
@danbev danbev force-pushed the move-dispatch-debug-message-async-to-env branch from 56a9199 to 98b8689 Compare June 23, 2016 12:12
@danbev
Copy link
Contributor Author

danbev commented Jun 23, 2016

@bnoordhuis I've made another attempt at this. When you get a chance, please take a look and let me know if this is what you had in mind. Thanks

inline void* DebugSignalThreadMain(void* unused) {
inline void* DebugSignalThreadMain(void* async_handler) {
uv_async_t* dispatch_debug_messages_async =
reinterpret_cast<uv_async_t*>(async_handler);
Copy link
Member

Choose a reason for hiding this comment

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

Can you use static_cast here?

@danbev
Copy link
Contributor Author

danbev commented Jun 23, 2016

@bnoordhuis thanks for the review! I've updated the PR with commits to address your comments.

uv_unref(reinterpret_cast<uv_handle_t*>(
env.dispatch_debug_messages_async()));

if (!use_debug_agent) {
Copy link
Member

Choose a reason for hiding this comment

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

You might as well use instance_data->use_debug_agent() now that it's been moved to StartNodeInstance().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not aware of that method, I'll update this.

@bnoordhuis
Copy link
Member

LGTM with comments.

env.dispatch_debug_messages_async()));

if (!instance_data->use_debug_agent()) {
RegisterDebugSignalHandler(env.dispatch_debug_messages_async());
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I just realized this is probably not going to work. It installs the signal handler (and starts the watchdog thread, initializes the debug semaphore, etc.) for every context. It's not academic: Electron creates multiple contexts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I just realized this is probably not going to work. It installs the signal handler (and starts the watchdog thread, initializes the debug semaphore, etc.) for every context. It's not academic: Electron creates multiple contexts.

No worries, I appreciate your help and learned for doing it. Just to clarify, is that Electron that you are referring to?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that Electron.

@danbev
Copy link
Contributor Author

danbev commented Jul 16, 2016

Closing this with the reason given by @bnoordhuis in #7358 (comment)

@danbev danbev closed this Jul 16, 2016
@danbev danbev deleted the move-dispatch-debug-message-async-to-env branch April 20, 2017 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants