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

debugger: introduce exec method for debugger #1491

Closed
wants to merge 1 commit into from

Conversation

JacksonTian
Copy link
Contributor

In debugger, the usage of repl very ugly. I'd like there is a p
like gdb. So the exec is coming.

Usage:

$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec('process.title')
/Users/jacksontian/git/io.js/out/Release/iojs
debug>

And the repl:

debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)

The enter and leave debug repl is superfluous.

@JacksonTian JacksonTian changed the title Introduce exec debugger: introduce exec method for debugger Apr 21, 2015
@@ -1575,6 +1575,17 @@ Interface.prototype.repl = function() {
this.repl.displayPrompt();
};

Interface.prototype.exec = function(code) {
var self = this;
this.debugEval(code, null, null, function (err, result) {
Copy link
Member

Choose a reason for hiding this comment

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

Minor style issue: no space after function keyword.

@bnoordhuis
Copy link
Member

LGTM sans style nit.

@JacksonTian
Copy link
Contributor Author

thanks @bnoordhuis

@JacksonTian JacksonTian force-pushed the introduce_exec branch 3 times, most recently from 39fa227 to a358dee Compare April 22, 2015 04:16
@chrisdickinson
Copy link
Contributor

Curious: down the line is there interest in moving to a more python pdb-style debugger, where the interface is a REPL by default and will evaluate any expression inline, but still respond to debugging commands?

@monsanto
Copy link
Contributor

@chrisdickinson +1 this tripped me up when I first started playing with Node

@JacksonTian
Copy link
Contributor Author

@chrisdickinson hope there is an idb or ndb command.

@JacksonTian
Copy link
Contributor Author

ping anyone?

@silverwind
Copy link
Contributor

Not sure this is the best approach. exec('') seems a bit too verbose.

I've recently experimented with the debugger for the first time, and was a bit surprised it wasn't a real repl. How about actually making it a repl and adding all debug related commands to the existing list of commands shown in the repl with .help?

This would of course be an incompatible change, but having all commands prefixed with a dot would be my preferred method. Maybe add a short print to refer to .help on debug start.

@rlidwka
Copy link
Contributor

rlidwka commented May 10, 2015

This would of course be an incompatible change, but having all commands prefixed with a dot would be my preferred method.

I use debugger heavily, and most commands I use are n, s and c. So I don't really like the idea to prefix them with dots: that's twice the amount of characters to type.

@JacksonTian
Copy link
Contributor Author

@silverwind the exec(exp) is a shorthand of repl + exp + control/c, and not an incompatible change.

@chrisdickinson
Copy link
Contributor

I think we should take a page from python's book and allow those commands unprefixed, but if the line isn't a known command treat it as a repl utterance.

On May 10, 2015, at 6:01 AM, Alex Kocharin [email protected] wrote:

This would of course be an incompatible change, but having all commands prefixed with a dot would be my preferred method.

I use debugger heavily, and most commands I use are n, s and c. So I don't really like the idea to prefix them with dots: that's twice the amount of characters to type.


Reply to this email directly or view it on GitHub.

@rlidwka
Copy link
Contributor

rlidwka commented May 11, 2015

I think we should take a page from python's book

That one where n+1 means next, but 1+n means local variable access?

>>> import pdb
>>> pdb.run('for n in range(1, 100):\n  n')
> <string>(1)<module>()
(Pdb) n
> <string>(2)<module>()
(Pdb) print n
1
(Pdb) n+1
> <string>(1)<module>()
(Pdb) 1+n
2

@silverwind
Copy link
Contributor

One way around this variable name problem could be to require a semicolon to access local variables, so n; would get you the variable, n would execute next.

@jasnell
Copy link
Member

jasnell commented Oct 22, 2015

@nodejs/collaborators ... anyone have any idea on the status of this? Is it still something that's wanted? /cc @JacksonTian

@JacksonTian
Copy link
Contributor Author

yes, repl is ugly.

@silverwind
Copy link
Contributor

@JacksonTian can you at least make it exec process.title or short e process.title?

@JacksonTian
Copy link
Contributor Author

ok.

@JacksonTian
Copy link
Contributor Author

@silverwind Implement exec process.title is ok. I'd like to know whether the command expr style fit the API style, the other command meet command() function call style.

/\d/, /\d/, /\d/, /\d/, /\d/
]);

// Execute
addTest('exec("process.title")', [
/iojs/
Copy link
Contributor

Choose a reason for hiding this comment

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

needs to be node now ;)

@@ -949,6 +950,12 @@ Interface.prototype.controlEval = function(code, context, filename, callback) {
}
}

// exec process.title => exec("process.title");
var match = code.match(/exec\s+([^\n]*)/);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably use an anchoring match (i.e. /^\s*exec) so it won't get confused by e.g. "exec exec exec" as the input.

EDIT: Can you add a regression test for that while you're at it? Thanks.

@JacksonTian
Copy link
Contributor Author

Thanks @bnoordhuis , I updated the commit.

// execute expression
Interface.prototype.exec = function(code) {
var self = this;
this.debugEval(code, null, null, function(err, result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use an arrow function callback and get rid of self.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The PR was submitted long time ago : ). updated.

In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.
@cjihrig
Copy link
Contributor

cjihrig commented Nov 17, 2015

Thanks, LGTM.

@bnoordhuis
Copy link
Member

LGTM2. I can't start the CI though, seems to be down at the moment.

@bnoordhuis
Copy link
Member

jasnell pushed a commit that referenced this pull request Nov 17, 2015
In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.

R-URL: #1491
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@jasnell
Copy link
Member

jasnell commented Nov 17, 2015

Failures in CI look unrelated. Will get this landed.

@jasnell
Copy link
Member

jasnell commented Nov 17, 2015

Landed in b33e9da

@jasnell jasnell closed this Nov 17, 2015
rvagg pushed a commit that referenced this pull request Dec 5, 2015
In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.

R-URL: #1491
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@MylesBorins
Copy link
Contributor

Is this something we would want in LTS? /cc @nodejs/lts

@jasnell
Copy link
Member

jasnell commented Mar 11, 2016

hmmm... good question. lts-agenda label applied.

@MylesBorins
Copy link
Contributor

lts wg has agreed this poses little risk. Added lts-watch label and we can add this to the next LTS semver minor bump

@MylesBorins MylesBorins self-assigned this May 17, 2016
MylesBorins pushed a commit that referenced this pull request May 27, 2016
In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.

R-URL: #1491
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 23, 2016
In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.

R-URL: #1491
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
In debugger, the usage of `repl` very ugly. I'd like there is a `p`
like gdb. So the `exec` is coming.

Usage:

```
$ ./iojs debug ~/git/node_research/server.js
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in /Users/jacksontian/git/node_research/server.js:1
> 1 var http = require('http');
  2
  3 http.createServer(function (req, res) {
debug> exec process.title
/Users/jacksontian/git/io.js/out/Release/iojs
debug>
```

And the `repl`:

```
debug> repl
Press Ctrl + C to leave debug repl
> process.title
'/Users/jacksontian/git/io.js/out/Release/iojs'
debug>
(^C again to quit)
```

The enter and leave debug repl is superfluous.

R-URL: #1491
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@MylesBorins MylesBorins removed their assignment Dec 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.