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
Comments
Removed Priority-Medium label. |
This is more a library question as Kasper points out. Where should this debugger breakpoint call live? cc @mhausner. |
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.) |
A debug library would be the obvious choice. cc @floitschG. |
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. |
Some candidates: showDebugger, stopInDebugger, debug.stop() |
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; |
another candidate: debugBreak() |
If the function is in a separate library (like dart:debug) then "break()" might actually be enough. |
This comment was originally written by bsles...@gmail.com But "break" is a reserved word. Perhaps "breakpoint()". |
Right. forgot about that... :( We should maybe also think about names that contain the expression to be executed. 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). |
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. |
We are in control of what dart2js emits, so no problems there. |
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. |
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. |
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. |
This comment was originally written by @mhausner |
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. |
Can this be closed? |
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) |
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.
The text was updated successfully, but these errors were encountered: