godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.93k stars 20.17k forks source link

Cannot debug Godot with GDB on WSL #52417

Open Nukiloco opened 3 years ago

Nukiloco commented 3 years ago

Godot version

master

System information

Windows 10, Nvidia GTX 750 Ti

Issue description

I compiled Godot under WSL/WSL2 and been trying to mess around in the engine in VScode with WSL though I'm being currently halted by a GDB terminal error.

Terminal output:

&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n"
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-koccktbn.vlf" 1>"/tmp/Microsoft-MIEngine-Out-ususmfus.ggs"

Debug console output:

ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x401b8b

This is the launch.json file that I currently have:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Editor",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/bin/godot.windows.tools.64.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
        }
    ]
}

Note that when searching up for a fix on this issue, some people say to set the externalConsole variable to true, though this hasn't worked for me at all as it just completely gets stuck trying to launch Godot.

Steps to reproduce

Compile for Windows with Linux with these instructions: https://docs.godotengine.org/en/stable/development/compiling/compiling_for_windows.html#cross-compiling-for-windows-from-other-operating-systems

After that, copy the exact launch.json code from the issue description debug and put that in the .vscode in the project root.

Minimal reproduction project

No response

Nukiloco commented 3 years ago

I did some researching and someone else has been having this issue also with GDB though it doesn't seem like its related to Godot at all Here's the issue on vscode's c++ tools repository https://github.com/microsoft/vscode-cpptools/issues/8011

Nukiloco commented 3 years ago

Some extra note here, this might not be an issue with Godot though an issue with vscode's c++ tools instead though imo its still worth noting somewhere. On the issue that I linked, the person that posted the issue says a temporary solution to go around this is to attach the debugger instead of launching it. I will try to see if this solution works.

Nukiloco commented 3 years ago

When using the attach option, I couldn't find the process ID for Godot when Godot was opened. The rest that I'm about to say is what I assume is happening and is just a guess. When running GDB, it can't see the Godot process because the Godot process is running on Windows instead of Linux. This is because the GDB that is being launched is from WSL or the linux environment and not GDB on Windows. The GDB process on linux can't see the Godot process on Windows which would probably make sense then.

If this is the case, then I'm going to search up on how to launch GDB on Windows and not on Linux when using WSL in vscode.