actboy168 / lua-debug

Lua Debug Adapter for Visual Studio Code
MIT License
437 stars 95 forks source link

Can't debug an x64-debug executable #116

Closed bleachkitty closed 2 years ago

bleachkitty commented 3 years ago

I'm running Lua 5.3.6 and can't seem to debug an x64 executable anymore. x86 works fine as does x64 in release mode. When I try to debug (or even just launch without debugging), the application opens for a split second and immediately dies. Since I can't even launch without debugging, I'm guessing there's something that's broken in my configuration or how I've set up my project, but I have no idea what it could be.

I can open the application by double-clicking on the executable just fine, and I can debug it through it Visual Studio, but I can't Visual Studio Code to behave. This configuration definitely worked in the past, though I've been in C++ land for the last several months so I don't recall the last time it worked. I've tried both the release and debug versions of Lua DLL.

My configuration is as follows:

    "version": "0.2.0",
    "configurations": [

        // This configuration doesn't work.
        {
            "name": "SpaceSim x64 Debug",
            "type": "lua",
            "request": "launch",
            "stopOnEntry": false,
            "runtimeExecutable": "${workspaceFolder}/../../x64/SpaceSimSFML_D64.exe",
            "cwd": "${workspaceFolder}/../../x64/",
            "consoleCoding": "utf8",
            "luaVersion": "5.3",
        },

        // This configuration works fine.
        {
            "name": "SpaceSim x86 Debug",
            "type": "lua",
            "request": "launch",
            "stopOnEntry": false,
            "runtimeExecutable": "${workspaceFolder}/../../x86/SpaceSimSFML_D32.exe",
            "cwd": "${workspaceFolder}/../../x86/",
            "consoleCoding": "utf8",
            "luaVersion": "5.3",
        },

        // This configuration also works fine (it's running a release executable).
        {
            "name": "SpaceSim x64 Test",
            "type": "lua",
            "request": "launch",
            "stopOnEntry": false,
            "runtimeExecutable": "${workspaceFolder}/../../x64/SpaceSimSFML_T64.exe",
            "cwd": "${workspaceFolder}/../../x64/",
            "consoleCoding": "utf8",
            "luaVersion": "5.3",
        },
    ]
}
actboy168 commented 3 years ago

Since I don't know how your exe uses lua, I can't give any suggestions. But you need to know that using runtimeExecutable to debug is not applicable to any executable program. Because it cannot inject the debugger with zero knowledge. I suggest you load the debugger yourself. like this https://github.com/actboy168/lua-debug/blob/master/examples/attach

bleachkitty commented 3 years ago

Thanks for quick reply!

I just did some testing by rolling back the lua-debug plugin and everything works correctly with version 1.30.1. 1.31 appears to have broken this. Did anything change that might changed the behavior of how the debugger attaches?

To answer your question, I build the Lua runtime as a DLL and link that in.

-Rez

actboy168 commented 3 years ago

1.30.1 is the latest version, I don't know what 1.31 is.

bleachkitty commented 3 years ago

Sorry, I just realized that. Off-by-1 error! Version 1.29.1 works, version 1.30 does not.

image