Is there any way to try Dart expressions and execute commands while in a debug breakpoint?
Like in Chrome Developer Bar, Firebug or Visual Studio Immediate Window.
Unfortunately not yet.
Star http://dartbug.com/3293 to track its progress.
A similar feature, a REPL (read-eval-print-loop) is tracked with http://dartbug.com/4409.
Related
I'm running dart with this command:
dart run --pause-isolates-on-start --observe --enable-vm-service=8181/0.0.0.0
With this command, can open on browser the dart native user interface to debug on
http://<ip>:8181/<authentication-code>
On debug page, is possible to set breakpoints and use them. But I don't find a way to save the break point to use on a future loading of dart debug.
Every time that I start the debug i have to set this breakpoints?
There is a way to save this break points to use on the future?
Not necessarily the answer you are looking for but could be seen as a workaround.
I have not tested this with VS Code, but if you are using IntelliJ (or Android Studio) with Dart plugin, you can essentially do remote debugging. So instead of using observatory to insert breakpoints, you can set them in your IDE which will then remember them and resend them to the Dart process when start debugging again.
If you go into "Run/Debug Configuration" and click + (Add), you can find "Dart Remote Debug":
As described in the dialog, when you are starting this "Run profile", you will be asked for the address to the Dart service protocol which your application should print out when started with Observatory / Dart DevTools enabled:
Unrelated notes
I have spend some time look at vm_service package which does provide ways to fetch breakpoints and adding breakpoints. But it is not really easy to map the breakpoints into something that can easily be persisted and later resent again. Some links you can use if you want to go for that journey:
https://pub.dev/documentation/vm_service/latest/vm_service/Isolate/breakpoints.html
https://pub.dev/documentation/vm_service/latest/vm_service/Breakpoint-class.html
https://pub.dev/documentation/vm_service/latest/vm_service/VmService/addBreakpoint.html
https://pub.dev/documentation/vm_service/latest/vm_service/VmService/addBreakpointAtEntry.html
https://pub.dev/documentation/vm_service/latest/vm_service/VmService/addBreakpointWithScriptUri.html
I would like to open F# compiler solution (FSharp.sln) from https://github.com/fsharp/fsharp/ in an IDE on a mac, then make some changes and run the compiler or ideally step through the code.
I tried JetBrains Rider, but it gets stuck soon after opening the solution: "Initial file processing: prim-type-prelude.fs". Code completion is not available.
I also tried opening another solution from https://github.com/Microsoft/visualfsharp, but both Rider and Visual Studio For Mac crash almost immediately.
What's the best way of working on F# compiler source code on a Mac? Is this feasible only on Windows? I'm new to .net and F#.
Edit: I had much better luck with Windows and Visual Studio. Everything worked pretty much out of the box. I was able to run the project, debug selected test and make minor changes with code completion enabled. I might be missing something, but it seems like it's a much smoother experience on Windows than on a Mac.
Somehow, debugging rascal in eclipse doesnt work for me.
I'm running rascal in eclipse Luna.
Everyting works, debug Start.rsc as application starts the rascal console in debug.
But clicking in the marging does not add a breakpoint no matter what.
Do I have to use a specific editor? (now using the java editor)
cheers, Ibanezje
The answer is: upgrade to Eclipse Mars.
Then with the 'impulse editor' you will be able to debug.
Is there a REPL for Dart to experiment with?
I tried inputing dart code in DevTools in Dartium and that also didn't work.
So I couldn't find an easy way to play with various APIs in dart.
I tried inputing dart code in devtools in Dartium and that also didn't
work.
I'm very new to Dart, but something I came across was that you CAN evaluate code in Dartium. In order to do so, you must first load a page with Dart code in it and then toggle this selector in the console from "javascript page context" to one that references a Dart package or Dart code.
Once you do that you should be able to execute Dart in the console:
As a VIM user, I hardly have to open the Dart Editor now :). I should also mention that breakpoints, hovering over stepped into code to get variable details, navigating the call stack, and some level of intellisense in the console also work. I couldn't get conditional breakpoints to work, though.
Though it is not really a REPL, you may find the Try Dart online tool useful for playing around. It's a bit slow, since it is actually compiling the Dart code to JavaScript in order to have it work within the browser.
There is also a console that someone built, which is probably better if you're looking for a real REPL, but it requires a bit of setup.
There is an announcement about REPL for Dartium - see Nathanial's comment below. There are plans for Smalltalk like super-REPL. Here is what Gilad Bracha (member of the Dart team at Google) wrote on this subject in Is there a REPL or console for Dart:
"I don't see this as a language question at all. It is a matter of tooling and reflective library support. With proper mirror builder APIs, building a REPL would be trivial. As it sands right now, it can be quite challenging. And of course, REPL is not the ultimate goal - there are more advanced interactive tools, like workspaces in Smalltalk/Self/Newspeak, where you not only evaluate things interactively at some top level, but can inspect the resulting objects, evaluate within the scope of an individual declaration or object etc. I am sure we will get there in time - and i much prefer sooner than later."
The correct answer is https://dartpad.dev/
That site didn't exist when the other answers were posted in 2013, but you've stumbled on this post after 2020. And now you know. https://dartpad.dev allows you to create and share new Dart snippets and even put them in a Flutter app running online. Very, very cool!
Since 2022.10.22, there is a REPL for Dart: https://github.com/fzyzcjy/dart_interactive :)
Features:
Use any third-party package freely
Auto hot-reload code anywhere, with state preserved
Supports full grammar in REPL
Play with existing code side-by-side
Disclaimer: I wrote that package.
So i've been using Rascal for a while now, but I was wondering if there is support debugging without using println and the terminal?
So like with c# in Visual Studio, stepping through the code, into functions and so on.
For me this would be a big help and can save time.
Just like visual studio, we have breakpoints and stepping through code. Since Rascal runs in eclipse, it might look slightly differently.
Remember to start your rascal console in debug mode, else it won't work.
You start it in debugging mode:
by selecting a .rsc file and right clicking Debug as > Rascal application.
or, if you select start console from a navigator or editor context-menu, it is a "Debug" console by default.
Adding breakpoints is done by clicking in the margin of an editor.
Any function you call from the console will activate the debug mode of Eclipse as soon as it hits the breakpoint.
Structured statements such as if and for act a little different in the debugger than what you might expect from Java or C#. Namely you have to "step into" them, otherwise if you press "step over" you will jump over their bodies.