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

doc: match debugger output & instructions to master behavior #13885

Merged
merged 0 commits into from
Jul 8, 2017

Conversation

jkrems
Copy link
Contributor

@jkrems jkrems commented Jun 23, 2017

Follow-up to #13777. Updates debugger.md with instructions & output that match behavior in node 8 / master.

Previously the instructions would at best trigger deprecation warnings and at worst fail completely.

Checklist
Affected core subsystem(s)

doc

@jkrems jkrems added the doc Issues and PRs related to the documentations. label Jun 23, 2017
@nodejs-github-bot nodejs-github-bot added debugger doc Issues and PRs related to the documentations. labels Jun 23, 2017
$ node inspect myscript.js
< Debugger listening on ws://127.0.0.1:9229/80e7a814-7cd3-49fb-921a-2e02228cd5ba
< For help see https://nodejs.org/en/docs/inspector
< Debugger attached.
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jun 23, 2017

Choose a reason for hiding this comment

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

I do not see this line in 8.1.2 output.

2 setTimeout(() => {
3 debugger;
3 console.log('world');
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jun 23, 2017

Choose a reason for hiding this comment

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

If you have not changed the code example below, this should still remain:

  3   debugger;

Copy link
Contributor Author

@jkrems jkrems Jun 23, 2017

Choose a reason for hiding this comment

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

Yeah, I wasn't sure about the exact "order" here. Because it first shows this and then later/below says (emphasis mine):

Inserting the statement debugger; into the source code of a script will
enable a breakpoint at that position in the code:

I interpreted that as "this is showing the original script run, then you insert debugger, then you run it again".

> 1 global.x = 5;
< Debugger listening on ws://127.0.0.1:9229/80e7a814-7cd3-49fb-921a-2e02228cd5ba
< For help see https://nodejs.org/en/docs/inspector
< Debugger attached.
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jun 23, 2017

Choose a reason for hiding this comment

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

I do not see this line in 8.1.2 output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird, I'm seeing it on master/this branch:

screen shot 2017-06-23 at 8 20 48 am

I also see it on 8.1.2:

screen shot 2017-06-23 at 8 21 31 am

I'm taking a TODO to check where the message is generated and why it wouldn't happen consistently. Might be a timing and/or platform issue..?

@@ -69,14 +71,14 @@ Press Ctrl + C to leave debug repl
> 2+2
4
debug> next
break in /home/indutny/Code/git/indutny/myscript.js:5
break in myscript.js:5
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jun 23, 2017

Choose a reason for hiding this comment

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

I see this order in 8.1.2:

debug> next
< world
break in myscript.js:5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! Missed that one.

@@ -41,22 +42,23 @@ Once the debugger is run, a breakpoint will occur at line 3:

```txt
$ node debug myscript.js
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this also should be:

$ node inspect myscript.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

$ node inspect test/fixtures/break-in-module/main.js
< Debugger listening on ws://127.0.0.1:9229/4e3db158-9791-4274-8909-914f7facf3bd
< For help see https://nodejs.org/en/docs/inspector
< Debugger attached.
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not see this line in 8.1.2 output.

< For help see https://nodejs.org/en/docs/inspector
< Debugger attached.
Break on start in test/fixtures/break-in-module/main.js:1
> 1 (function (exports, require, module, __filename, __dirname) { const mod = require('./mod.js');
2 mod.hello();
3 mod.hello();
debug> setBreakpoint('mod.js', 2)
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jun 23, 2017

Choose a reason for hiding this comment

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

2 -> 22 (due to copyright added recently):

debug> setBreakpoint('mod.js', 22)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I think the current instruction happened to work because it was smart enough to "shift" beyond the comment. But using 22 is definitely less confusing. 👍

3 mod.hello();
4 debugger;
5
6 });
debug> c
break in test/fixtures/break-in-module/mod.js:2
Copy link
Contributor

Choose a reason for hiding this comment

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

2 -> 22:

break in test/fixtures/break-in-module/mod.js:22

@vsemozhetbyt
Copy link
Contributor

Maybe we also should update the link to redirected one (line 194):
https://chromedevtools.github.io/debugger-protocol-viewer/
->
https://chromedevtools.github.io/devtools-protocol/

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jun 23, 2017

the last example may also be updated to:

$ node --inspect index.js
Debugger listening on ws://127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
For help see https://nodejs.org/en/docs/inspector

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

I'm LGTM if the nits raised by @vsemozhetbyt are attached - I see the same output as @vsemozhetbyt - without the "Debugger attached." line.

@jkrems
Copy link
Contributor Author

jkrems commented Jun 23, 2017

I'm not sure what's up with the "Debugger attached". I'm testing on macOS 10.12.5 if that makes any difference..? Anyhow, the straight-up wrong stuff should be fixed now. :)

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM. If the output is different between master and Node 8, then this might need to be adjusted during backporting.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jun 23, 2017

I cannot see "Debugger attached" in any recent version for Windows, including the master and canary:

screenshot:

1


@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jun 23, 2017

There is a small glimpse on the start, so I supposed this line was just rewritten on Windows. I've run this with redirection to a file and even have recorded a video and watched it frame by frame. There are some rewritten lines, but still, no "Debugger attached" among them:

node.8.1.2.v8-5.8.20170615.exe inspect test.js > debug.log:

�< Debugger listening on ws://127.0.0.1:9229/9ab1ed89-f254-4415-97eb-c99d61555806
< For help see https://nodejs.org/en/docs/inspector
�connecting to 127.0.0.1:9229 ... okdebug> �Break on start in test.js:1
> 1 (function (exports, require, module, __filename, __dirname) { global.x = 5;
  2 setTimeout(() => {
  3   debugger;
debug> 

@jkrems
Copy link
Contributor Author

jkrems commented Jun 23, 2017

Interesting. Will investigate what's up on Windows. One possible answer could be stdout vs. stderr -

fprintf(stderr, "Debugger attached.\n");
.

Given current information I suspect this is a bug (?) on Windows. The message should be printed.

@jkrems jkrems closed this Jul 8, 2017
@jkrems jkrems force-pushed the jk-update-debugger-docs branch from 6496ca3 to b647f04 Compare July 8, 2017 16:27
@jkrems jkrems merged commit b647f04 into nodejs:master Jul 8, 2017
@jkrems
Copy link
Contributor Author

jkrems commented Jul 8, 2017

Landed in b647f04.

@jkrems jkrems deleted the jk-update-debugger-docs branch July 8, 2017 16:28
addaleax pushed a commit that referenced this pull request Jul 11, 2017
@addaleax addaleax mentioned this pull request Jul 11, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants