Skip to content
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

Support for debugging GDNative #675

Open
SailorJoe6 opened this issue Jul 2, 2024 · 4 comments
Open

Support for debugging GDNative #675

SailorJoe6 opened this issue Jul 2, 2024 · 4 comments

Comments

@SailorJoe6
Copy link

Godot version

3.5

VS Code version

1.90.2 universal

Godot Tools VS Code extension version

2.0.0

System information

MacBook Pro M1 with Sonoma OS

Problem statement

I want to be able to step into my GDNative code while debugging. I used to be able to make this work on my Intel mac, but it was quite a hassle. Now that the this plugin exists, working with Godot is beautifully simple, except the plugin doesn't automatically allow you to step into my GDNative code. Now I have to find a wacky workaround, which is harder than ever with the universal build of Godot running on an Apple Silicon. I suppose I'll have to create a task that launches lldb-mi, finds the running process of godot and attaches to it for debugging into my GDNative code. This would be so much nicer if it was just a working feature of the plugin.

Proposed solution

Make sure to attach to any GDNative plugins that are running as part of the scene?

@DaelonSuzuka
Copy link
Collaborator

Yeah, that's probably not gonna happen. It took me more than six months to update the GDScript debugger for Godot 4, and "all" that's doing is translating messages from Godot's debug socket into a form that VSCode understands.

Add to that the fact that I don't really know anything about GDNative, I have no plans to use GDNative in my personal projects, and I expect very few people would ever use this feature... The return on investment just isn't there.

@SailorJoe6
Copy link
Author

SailorJoe6 commented Jul 3, 2024

Ok. Well, I guess that is what it is. For anyone who does use GDNative (or as it's called in Godot 4, GDPlugins) the problem wasn't too hard to solve. You need the CodeLLDB plugin installed to VSCode (which is recommended by Godot anyway) and if you're running on a recent mac, you need to follow the steps outlined in https://docs.godotengine.org/en/stable/contributing/development/debugging/macos_debug.html in order to attach to a running Godot instance. With that done, the following launch.json solves the issue:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "GDScript: Launch Project",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}"
        },
        {
            "name": "godot-attach",
            "type": "lldb",
            "request": "attach",
            "program": "${config:godotTools.editorPath.godot3}" //adjust if you're using godot4
        }
    ],
    "compounds": [
        {
            "name": "godot-complete-launch",
            "configurations": [
                "GDScript: Launch Project",
                "godot-attach"
            ]
        }
    ]    
}

Set up "godot-complete-launch" as your default and then F5 will launch this plugin as usual, but also attach an LLDB session to it, so you can debug the C++ code in your plugin. Note: If you compile Godot from source, you can even debug Godot this way (not that you would want to do that).

@DaelonSuzuka
Copy link
Collaborator

Does this create two separate debug sessions or are they somehow merged together?

@SailorJoe6
Copy link
Author

One session. This plugin launches godot and handles all that magick it does. LLDB (or GDB works on windows) attaches to the already running process and is the standard way to debug any C or C++ program, so yeah... It just works out of the box

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants