Dart debug, how to save and load breakpoints? - dart

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

Related

IntelliJ and Dart: restart daemon/dartvm

I'm doing Dart FFI development in IntelliJ to create bindings to a native library. While trying to get the bindings right, I seem to be messing up some internal memory of this library. After making corrections to my code, the library is still in an inconsistent state due to my earlier errors. This is because the updated code is run inside the same instance of the DartVM as earlier: IntelliJ doesn't restart it, it reuses it. The only way to get back to a consistent state is to restart IntelliJ, which is quite annoying.
Is there a way from inside IntelliJ to only restart the DartVM used to run my program? I've not been able to find any way...
It's not quite clear which Dart VM you want to restart.
There's only one long-living Dart VM, it's Dart Analysis Server, the tool from the Dart SDK that is responsible for code highlighting, completion, and other code insight features in the IDE editor. To restart it click the corresponding button in the Dart Analysis tool window, or open Find Action and search for 'Restart Dart Analysis Server'.
Speaking of running your application, IDE doesn't reuse any running VM. Which run configuration type do you use to start your app: Dart Command Line App or Dart Web App (see Run -> Edit Configurations)? Both have the 'Stop' button in the Run tool window in case you application doesn't terminate normally itself.
More details about the problem (probably with screenshots) will help us to give a better answer.

VS Code doesn't continue inputs (Dart)

I have started learning Dart for 2-3 days, something I have noticed is that when I use replit.com, I can continue getting inputs and outputs, for example in this code:
I have the exact code in VS Code and here:
https://replit.com/#Vonarian/anotherhello?v=1
When I click run and debug in VS Code, I enter the Student I want the name/nick of, and then nothing happens, like only one input and it doesn't bring up anything.
I also have tested different codes and projects and it's the same, works on replit but not in VS Code.
Not continuing in VS Code
This happens because the default mode of running Dart scripts is using the Debug Console so that you can use the REPL. Although you could run the script through the Terminal to solve this, it won't allow you to use the debugging features (like breakpoints, or pausing on exceptions).
You can change the default way of running CLI scripts with the Dart: CLI Console setting in VS Code as shown here:
This will set it globally (or if set in the Workspace Settings, just for that workspace). Otherwise, you could add "console": "terminal", into a launch.json configuration to have it apply only to a specific launch configuration.

Force Open Lua Console or Run Lua Console Automatically on Startup

I'm new to Wireshark & Lua and I have a question that I can't seem to find the answer to by reading around online
Is there a way to open the Wireshark Lua console window on start up? Or even automatically open dialogs created by listeners on start up? I was hoping there were some commands or capability that would allow me to open (not just create) dialogs from within a script.
I've read about the exploit for the console in versions 1.6 and earlier, but I'm running 1.6.8 and I'd rather not use something that could potentially cause Wireshark to be unstable.
Modify the bottom of C:\Program Files\Wireshark\console.lua. Before the final "end", add:
run_console()
You can find an advanced option in the preferences dialog:
Open Preferences from the Edit menu
Navigate to Advanced
Filter for console
Change the value for gui.console_open to ALWAYS

Is it possible to enter Dart code directly into the Chromium Dev Tools Console?

I am running the latest Chromium build, with the Dart VM. I would like to start playing with Dart's HTML library by messing around with websites, using the Console to enter Dart commands. Obviously, this is easy with Javascript, but I can't work out how to tell the console that I am entering Dart, not JS.
Is this possible?
It is not. I actually requested this feature on the bug tracker a while back but I can't seem to find it. IIRC, it has to do with the fact that you'd have to be running the code within a particular isolate, which at the moment is not possible. In javascript, everything is global so there is a fundamental difference.
It is possible if it has the Dart VM... I run Dartium but I guess that it can be similar!
https://drive.google.com/file/d/0B1XajbEHFd35OFRJSU5hR0FPZlE/edit?usp=sharing
You have to change in the context menu.
If this answer doesn't work for you I'm sorry...

How to debug .exe started by another .exe in Delphi

I want to debug App2.exe, which is started by App1.exe. If App2.exe were a dll I could specify a host application, but this doesn't seem to work with an .exe.
I now use 'attach to process', but this is useless if App2.exe crashes before I do that.
Is there a way to do this with having to attach to the process manually?
Set the "debug spawned processes" debugging option. It is off by default. When App1 starts the new process, the debugger will pause. If the debugger isn't already attached to the new process automatically, attach to it, and then resume running it.
No, but there might be a way to get it to attach properly. Find something that you know will happen in App2 soon before the crash point, and have it pop up a modal dialog box at that point. Then it won't continue until you dismiss it, giving you time to attach the debugger.
I guess you could launch app2.exe yourself and pass any necessary command line parameters to it.
If you're using windows, there is a built in support for it.
basically, you can tell the windows loader to launch some other process whenever a specific process is launched. for example, you can tell windows to always launch winword.exe whenever you click on notepad.exe
you can use this ability in order to automatically launch a debugger whenever you start your process (this is why this feature was originally introduced, however you are not restricted to launch only debuggers :))
You can read exactly how to do it here.
You can also download the debugging tools for windows package and use GFlags to do it for you.
If both apps are yours and you have the code than I propose the following:
Make a debug mode for both apps. Use external inc file for instance
Start two IDEs and load each app in its own IDE. Build in debug mode
If done right you can now debug the internal communication between apps
I have a project where a server spawns multiple exe worker processes that host each its own dll module. I have a debug mode in which I can specify which dll will be loaded and I can have both processes running and communicationt in between from IDEs. It is the best way I have found so far.

Resources