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

Provide a dart method that trigger a breakpoint #10536

Closed
jacob314 opened this issue May 8, 2013 · 21 comments
Closed

Provide a dart method that trigger a breakpoint #10536

jacob314 opened this issue May 8, 2013 · 21 comments
Labels
type-enhancement A request for a change that isn't a bug web-dart2js

Comments

@jacob314
Copy link
Member

jacob314 commented May 8, 2013

In javascript, you can drop in a

debugger;

statement to trigger a breakpoint when running the code with a debug tool (e.g. chrome dev tools).

It would be helpful to have a similar dart statement so that breakpoints can be triggered in the code and then used in whatever debugger the user prefers (e.g. dartium or dart editor).
In particular, when dealing with generated code it is challenging to set breakpoints at the moment.

@iposva-google
Copy link
Contributor

Removed Priority-Medium label.
Added Priority-Unassigned label.

@kasperl
Copy link

kasperl commented Jun 6, 2013

For what it's worth, I really dislike calling this "debugger". Maybe some kind of breakpoint() top-level function in some library would be nicer? If you really want to we could make it a getter to avoid the parentheses.


Removed c2 label.
Added C2 label.

@iposva-google
Copy link
Contributor

This is more a library question as Kasper points out. Where should this debugger breakpoint call live?


cc @mhausner.
cc @kasperl.
Removed the owner.
Removed Type-Defect, Area-VM labels.
Added Type-Enhancement, Area-Library labels.

@DartBot
Copy link

DartBot commented Jun 18, 2013

This comment was originally written by bsles...@gmail.com


Hmm, how about a mode in which failed assertions drop you into the debugger? Then you can trigger a breakpoint using "assert(false)", and conditional breakpoints are easy.

(In this mode you'd also want to be able to continue after a failed assertion.)

@lrhn
Copy link
Member

lrhn commented Jun 18, 2013

A debug library would be the obvious choice.
We are considering it for other reasons as well, but haven't gotten around to looking at it seriously yet.


cc @floitschG.

@floitschG
Copy link
Contributor

Unless there are objections I'm fine with adding dart:debug with this method. I'm confident that we will have more utility classes/methods that fit into the dart:debug library.
I would also make dart:debug "unstable" (at least for now). It is supposed to be something for debugging and should not exist in production code.
I'm proposing breakIntoDebugger() for the actual method name. It is long, though. If there are better suggestions please speak up.
(I don't like "breakpoint()" because it has a noun-name. It would need to be a getter, which would be another alternative.).

@skybrian
Copy link

Some candidates: showDebugger, stopInDebugger, debug.stop()

@DartBot
Copy link

DartBot commented Jun 19, 2013

This comment was originally written by @mhausner


breakIntoDebugger() is definitely too long, especially so for a language that tries to be terse.

How about halt(); or halt;

@devoncarew
Copy link
Member

another candidate: debugBreak()

@floitschG
Copy link
Contributor

If the function is in a separate library (like dart:debug) then "break()" might actually be enough.

@DartBot
Copy link

DartBot commented Nov 5, 2013

This comment was originally written by bsles...@gmail.com


But "break" is a reserved word. Perhaps "breakpoint()".

@floitschG
Copy link
Contributor

Right. forgot about that... :(
breakpoint would need to be a getter then.

We should maybe also think about names that contain the expression to be executed.
For example: foo(bar(), debug(toto()))

In this case I would want bar to have executed, but not the call to toto.

debug(); would then just be a shorthand for debug(null).

@DartBot
Copy link

DartBot commented Nov 5, 2013

This comment was originally written by bslesinsk...@gmail.com


What would that mean? The JavaScript debugger statement doesn't take any parameters or return anything. Also, it's a statement so it would tricky to execute while evaluating an expression.

@floitschG
Copy link
Contributor

We are in control of what dart2js emits, so no problems there.
For the DartVM we don't need to follow the example of JavaScript, and switch from statement to expression.

@DartBot
Copy link

DartBot commented Nov 5, 2013

This comment was originally written by bslesi...@gmail.com


When debugging it helps to keep things as simple as possible, to make it less likely that the bug goes away when you try to debug a problem. So I'd prefer a way to simply emit a JavaScript "debugger" statement without any other changes to the AST that might cause the dart2js compiler to optimize the code differently. (There is always some change but we should try to minimize it.) This sort of low-level control should be left in the hands of the programmer as much as possible.

@floitschG
Copy link
Contributor

We don't design language/library features under the assumption that our tools are broken. Sometimes we take some inherent limitations (for dart2js the JavaScript language) into account, but otherwise we should just fix our tools.

@DartBot
Copy link

DartBot commented Nov 5, 2013

This comment was originally written by bslesinsky...@gmail.com


That's assuming the JavaScript "debugger" statement is somehow broken, and I'm not seeing that. Does anyone care about setting a breakpoint in an expression? It seems like we shouldn't add complexity without a compelling reason.

Also, fixing all the tools isn't actually practical. Since we're talking about debugging, the runtime environment includes the debuggers for Firefox, IE, and the iPhone. We need to play well with those.

@DartBot
Copy link

DartBot commented Mar 31, 2014

This comment was originally written by @mhausner


cc @peter-ahe-google.

@peter-ahe-google
Copy link
Contributor

https://codereview.chromium.org/204483002/

I agree with Florian: debugging expressions is important. I've never heard a user complain that they could set precise breakpoints. In fact, expression-level breakpoints is a feature in both Eclipse and NetBeans, and was considered a major deficiency in NetBeans until we implemented it.

As far as I can tell, Florian's solution wouldn't change Brian's workflow. Dart2js will inline the method and simply emit a debugger statement.


Set owner to @peter-ahe-google.
Added Started label.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
@zoechi
Copy link
Contributor

zoechi commented Nov 19, 2016

Can this be closed?

@mhausner
Copy link
Contributor

Yes, this functionality has been added in the dart:developer library (https://api.dartlang.org/stable/1.20.1/dart-developer/dart-developer-library.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug web-dart2js
Projects
None yet
Development

No branches or pull requests