-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Cannot get visual studio code to debug mono #13837
Comments
Is there already a plugin to debug godot's mono integration? |
We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth. |
I didn't make any editor extension yet because I'm still thinking how to make them communicate with Godot to be the most user friendly possible. This is the {
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "mono",
"request": "attach",
"address": "localhost",
"port": 23685
}
]
} That's the default port, but you can change it in project settings: |
Hi, I'm using Godot 3.0 RC1 on macOS Sierra. I've got VS Code installed and set up with my launch.json config using what's shown in @neikeq 's comment above. I actually use VS Code for my main development experience and it works fine (w/ intellisense for Godot code or other dependencies I've added to the project via Paket/nuget). I have the default debugger settings as shown in the project settings (port 23685). While the godot editor process is active, I notice that 23685 is open and I can connect from VS Code or telnet, but there's never any response to anything sent to that port. When I build/run the project and then try to connect, its the same thing; I can connect in VS code, but no breakpoints are hit and it's unresponsive. Also I've observed that, if I set the "wait for debugger" option in the project settings, any attempt to run/debug the project will stop immediately after debugging begins. I understand that any dev work to address this will have to wait until after the 3.0 release, but I wanted to chime in with my experience. |
Is working perfectly to me, my steps, dont know what is mandatory: |
Just attempted this again, on macOS Sierra, with the 3.0 stable release (64bit mono version). Have Mono 5.4.1 installed via brew. Still the same behavior as I described above here Can anyone confirm/deny remote debugging support w/ Godot+VS Code w/ Mono debugging extension on macOS? |
I have definitely debugged C# code successfully with the Mono Debug extension for VSCode. Wait for debugger is definitely broken however and there is an issue where the editor occupies the debug port. The latter is actually a problem because you end up debugging the editor which isn't running C# code to debug. As for the editor port occupation issue: should we make a second config option for an editor port (so you can still debug the editor if editor scripts ever get implemented) or just make the editor not enable the mono debugger. |
Actually nevermind on the wait for debugger thing. It works absolutely fine. Probably was fixed since I last tested it. |
I thought I already made the editor not enable the mono debugger: godot/modules/mono/mono_gd/gd_mono.cpp Lines 122 to 126 in 49dc473
I think at some point the editor should be debuggable, but right now there are a few issues with that. |
Digging into this: the issue is with the project manager eating port 23685. The |
I tested it with windows 10, mono 5.4.0, VS Code and mono debugger extension. I created a launch.json, started the game in godot and attached with the debugger. In VS Code I saw two threads: the thread#1 and the finalizer. I was able to pause the app from VS Code, in this case the Thread#1 was paused, and the game too, and I was able to continue it again, but unfortunately, the breakpoints wasn't hit. |
Ps. I used the latest godot version (3.0.1). |
@gattila in which method did you put the breakpoint? Is that method async by any chance? |
I simply clicked before the first line of the _Ready() function, and the big red button appeared, and I saw a new breakpoint in VS code in the breakpoints window. The code was executed, but the program was not stopped at the breakpoint. I debugged other .NET programs with VS Code before without any problem. Maybe the mono 5.4.0 is too old ? I tired to remove the 5.4 mono and install the latest (5.10.0.140), but after the install (and the restart of the computer) the godot crashed if I tired to open a C# based godot application. |
I tried with 5.4.17. The godot not crashing with this version, but it still don't stop on breakpoint. |
The Godot builds provided on the website are built against 5.4 and don't
work with any others due to other issues.
The debugger does attach though, right? It just doesn't hit any
breakpoints?
Does the Godot process lock up when you hit pause on the debugger when it's
attached?
…On Feb 28, 2018 20:14, "gattila" ***@***.***> wrote:
I tried with 5.4.17. The godot not crashing with this version, but it
still don't stop on breakpoint.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#13837 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHu1ww_v7-eqBsmh7iLrLiVujmkyk85eks5tZaWhgaJpZM4Qzbca>
.
|
@gattilla Maybe that code is executed before the debugger is attached? What happens if you enable de option in |
If I set the Wait for Debugger, the running app shows the godot splash screen and wait until I attach with the debugger. But it does not stop on my breakpoints, both on _Ready, _Input, _Process. These functions are executed: if I put a GD.print to these functions, I can see the result in the output window. I see the breakpoint lines in VS code, and the Thread#1 and Finalizer processes in the Call Stack window. I can play the pause button in VS code and in this case the godot application freezes, and the Thread#1 show Stopped status. If I press the Continue button in VS code the Thread#1 status changes to Running and the game also run as before the pause. All seems Ok, except the fact that the app doesn't stop on breakpoints. |
Oh I should've asked this earlier. Are you on Windows? Pretty sure #14822 would break the debugger too since it wouldn't be able to associate line numbers with instructions. |
Yes, it is windows 10. |
i confirmed the same behavior as gattila: on win 8.1 (it seems that I am the last person on earth who still use it), Godot 3.0.2 stable, Mono 5.4.1.7, VSCode + mono debugging extension: the debugger connects, the threads can be stopped, the breakpoints are not hit. |
same issue with jetbrains rider on windows. I get DWP Connection Failed. |
Marking this as Windows-only. Let me know if you can also reproduce this in other platforms. Debugging support will be added after 3.1, when we add extensions for some external editors and IDEs. |
I'm looking into this. So far I can confirm that embedded Mono debugging totally works on Windows in a tiny test project: #include "stdafx.h"
#include <iostream>
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/mono-debug.h>
int main()
{
mono_set_dirs("C:\\Program Files\\Mono\\lib",
"C:\\Program Files\\Mono\\etc");
mono_config_parse(NULL);
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
const char* options[] = {
"--soft-breakpoints",
"--debugger-agent=transport=dt_socket,address=127.0.0.1:3005,embedding=1,server=y,suspend=y,timeout=30000"
};
mono_jit_parse_options(2, (char **)options);
auto domain = mono_jit_init_version("thing.derp", "v4.0.30319");
auto assembly = mono_domain_assembly_open(domain, "C:\\Users\\absolutelynotmyusername\\Documents\\Visual Studio 2017\\Projects\\mono embed debugging pls\\helloworld\\bin\\Debug\\helloworld.dll");
auto image = mono_assembly_get_image(assembly);
auto theclass = mono_class_from_name(image, "helloworld", "Class1");
auto desc = mono_method_desc_new("Class1:Hello", false);
auto method = mono_method_desc_search_in_class(desc, theclass);
mono_runtime_invoke(method, nullptr, nullptr, nullptr);
return 0;
} and pasting said code into Not sure how helpful this info is but it's a start. |
I've been looking into this as well. So far, the debugger seems to be attached correctly. If there are no breakpoints, the applications run normally. If I set a breakpoint, the applications hangs indefinitely. I will try removing unnecessary stuff from initialization until it's fixed, to find out what is causing it (if the problem is in the initialization that is). |
Aha! Found it. Preparing a PR. |
@neikeq so you half fixed it. I can get vs code on windows 10 to attach to the debugger now without issue.
If I let godot project runs without debugging it'll timeout like normal and it'll run when the debugger connects without issue. Now the issue is the debugger isn't breaking any points for me. So close yet so far :(
Weirdly enough jetbrains rider won't even attach to the debugger. |
That's weird. It did hit the breakpoint for me... |
@neikeq do you have a sample project that I can test to see if I can reproduce it working for you? Going to rebuild shortly to make sure (after i finish setting up ubuntu 18 & godot on my other desktop pc) |
Definitely works on my end too. You changed the debug type of your project as instructed here right? |
@neikeq I just tested with mono 5.12.0 and it works perfectly. 5.10.1 doesn't work at all. Maybe we should require 5.12.0 the required version? On their release notes they said this version passes a lot of their tests and improved a bunch of stuff so it only makes sense. Edit: yup, jetbrains rider 2018.1 & visual studio code's debugging works with mono 5.12.0 |
I have |
these mono versions are so weird lol. So 5.10.0 & 5.12.0 works? 5.10.1 doesn't for me. |
@exts Could you share a minimal example project where you cannot get it to work? |
Just to clarify: 5.12.0 works fine, 5.10.1 didn't work, right now I'm building the editor using 5.10.0 to test if it works with that version. After I finish testing I'm going to redownload 5.10.1 and rebuild the editor again to confirm if it works or not with that version of mono. |
Alright I've rebuilt godot editor 3 times from master and I can confirm on windows 10 that:
Edit: Copy my message from discord: "I think I know why it didn't work on 5.10.1 the last time I tried it, if you have any errors in your code it'll attach but it won't hit any break points until you fix said errors. Retested with a very minimal project and it hits the breakpoint every time. " |
You mean compiler errors, or in vscode's editor? |
@neikeq correct. For instance, not instantiating a field that requires a instance would compile but throw an error to the Godot output yet the scene would still run. I'm on mobile so hope that helps. Edit: Now that I'm at a PC, like a static Random field |
Oh, I think you are getting a NullReferenceException. As far as I remember, the mono debug extension for VS Code would not break on unhandled exceptions by default, but you could change that in the settings. |
@neikeq nice, just figured out how to do it.
Adding this to your vs code user settings will catch said exceptions. I had to restart the editor for it to work, but yeah works as expected. |
Operating system or device, Godot version, GPU Model and driver (if graphics related):
Fedora 26, master branch
Issue description:
I cannot find any documentation on how to integrate Godot's mono capabilities with visual studio code, is there a launch.json I can use for reference somewhere? @neikeq
The text was updated successfully, but these errors were encountered: