I want to pass --enable-vm-service to the dart VM while running flutter but I didn't find any way to do it
simply running flutter --enable-vm-service returns
Could not find an option named "enable-vm-service".
I'm using android studio I would like to know if there a way to automatically pass the argument like this
if not command line will be enough.
The VM service runs automatically for Flutter, since Flutter uses it internally (eg. to send Hot Reload requests). If you run Flutter with --start-paused from the terminal for example, that will force it to print the VM service URL out:
To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on iPhone XS Max is available at: http://127.0.0.1:49303/
If you're running in VS Code, during a debug session there's a Dart: Open Observatory command that will launch the Observatory web app in your browser (this exposes the URL). There may be a similar button in IntelliJ/Android Studio, though I'm not sure.
You can also pass --observatory-port if you want to force a specific port:
flutter run --observatory-port 9999
In VS Code, you can add this to the args collection in your launch config (.vscode/launch.json). It'll probably also work in the args box shown in your screenshot for IntelliJ/Android Studio.
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'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.
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.
So I decided to tinker around with Flutter.
Thus I downloaded the Flutter SDK (which contains the Dart SDK). I installed it (unpack, set bin to PATH).
Whenever I execute the dart command from the command line, it automatically triggers off building of the flutter tool as well as upgrading the pub tool, regardless of whether I want to or not. For example, as shown below:
(and mind you, when this happens, it also hogs a big chunk of the CPU % usage)
I wish to know how to disable this from happening. Either of these processes should be triggered only when I want them to be.
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.