Thread overview
Debugging D applications from VS code with webfreak.debug
Feb 23, 2017
FR
Feb 23, 2017
WebFreak001
Feb 23, 2017
FR
Feb 23, 2017
FR
Feb 24, 2017
Jerry
Feb 24, 2017
FR
Jul 11, 2017
Domain
February 23, 2017
Hi everyone,

as the subject says, I'm trying to get a debugger running with visual studio code on windows.
I have installed WebFreak001's code-d and debug extensions but fail to figure out how to install a working debugger. The gdb I have installed is part of a MinGW installation and complains about the file format of the executable, I'm unsure if there's soemthing wrong there.
I could not figure out how to obtain mago-mi to try that one, either.
I'd appreciate any help or pointers to resources on how to get this running, as I otherwise really like the workflow with code-d.

Cheers,

FR
February 23, 2017
On Thursday, 23 February 2017 at 16:28:26 UTC, FR wrote:
> Hi everyone,
>
> as the subject says, I'm trying to get a debugger running with visual studio code on windows.
> I have installed WebFreak001's code-d and debug extensions but fail to figure out how to install a working debugger. The gdb I have installed is part of a MinGW installation and complains about the file format of the executable, I'm unsure if there's soemthing wrong there.
> I could not figure out how to obtain mago-mi to try that one, either.
> I'd appreciate any help or pointers to resources on how to get this running, as I otherwise really like the workflow with code-d.
>
> Cheers,
>
> FR

I don't know how to build mago-mi either, but you can obtain it from the bundle with dlangide https://github.com/buggins/dlangide/releases/download/v0.6.11/dlangide-v0_6_11-bin-win32_x86-magomi-v0_3_1.zip

With GDB it should just work though, if you can run `gdb` from the command line. If you can only run it through some MinGW command line version, try running vscode over the command line there
February 23, 2017
On Thursday, 23 February 2017 at 16:30:08 UTC, WebFreak001 wrote:
> I don't know how to build mago-mi either, but you can obtain it from the bundle with dlangide https://github.com/buggins/dlangide/releases/download/v0.6.11/dlangide-v0_6_11-bin-win32_x86-magomi-v0_3_1.zip

Thanks, that got me somewhere. However, this executable stops working as soon as I run it from the command line. Double-clicking it from the explorer opens a gdb console. I added it to my path anyyhow, but clicking on debug in vscode with a launch.json with "type": "mago-mi" doesn't do anything.

> With GDB it should just work though, if you can run `gdb` from the command line. If you can only run it through some MinGW command line version, try running vscode over the command line there

gdb is in my path, I can run it from the command line. When I run 'gdb test.exe' (test.exe being the binary placed in my workspace folder), I get the error message "not in executable format: File format not recognized", whether I build as x86 or x86_64. Any further tips on where I could get a working gdb?
February 23, 2017
On Thursday, 23 February 2017 at 17:54:09 UTC, FR wrote:
> gdb is in my path, I can run it from the command line. When I run 'gdb test.exe' (test.exe being the binary placed in my workspace folder), I get the error message "not in executable format: File format not recognized", whether I build as x86 or x86_64. Any further tips on where I could get a working gdb?

Nevermind on this one. Turns out something was off with the gdb from my MinGW installation. Got a new one from http://www.equation.com/servlet/equation.cmd?fa=gdb , placed it where it can be found and it runs. Yay!

However: I cannot seem to get breakpoints to work. When my executable is launched, the debug output says "No symbol table is loaded.  Use the "file" command.". Is there any special flag I need to set in my dub.json? Should I point the "target" and "cwd" in the launch.json anywhere but the executable that pops up in my ${workspaceRoot} (e.g. one of the sub-folders of .dub/build)?

February 24, 2017
You can use the C++ plugin, which provides a debugger. Just make sure you aren't using optlink, I don't think it generates compatible files. Also you might need to use "-gc" which generates debug names to be in C format.

https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

You might also need to enable breakpoints anywhere in VS code user setting file.
February 24, 2017
On Friday, 24 February 2017 at 03:15:11 UTC, Jerry wrote:
> You can use the C++ plugin, which provides a debugger. Just make sure you aren't using optlink, I don't think it generates compatible files. Also you might need to use "-gc" which generates debug names to be in C format.
>
> https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
>
> You might also need to enable breakpoints anywhere in VS code user setting file.


Awesome! After finding the right combination of flags (-g and -m64 fed to dmd via dflags-dmd in my dub.json) this works quite nicely. Thanks a lot!
Is there anywhere I can contribute this as documentation?
July 11, 2017
On Friday, 24 February 2017 at 13:19:53 UTC, FR wrote:
> On Friday, 24 February 2017 at 03:15:11 UTC, Jerry wrote:
>> You can use the C++ plugin, which provides a debugger. Just make sure you aren't using optlink, I don't think it generates compatible files. Also you might need to use "-gc" which generates debug names to be in C format.
>>
>> https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
>>
>> You might also need to enable breakpoints anywhere in VS code user setting file.
>
>
> Awesome! After finding the right combination of flags (-g and -m64 fed to dmd via dflags-dmd in my dub.json) this works quite nicely. Thanks a lot!
> Is there anywhere I can contribute this as documentation?

I cannot debug my app with mago-mi. I click debug button, but nothing happen. I have installed cpptools, mago-mi, webfreak.debug, and I have tried vscode-dlang and code-d. My launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "mago-mi",
            "request": "launch",
            "target": "${workspaceRoot}/bin/exp.exe",
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "build"
        }
    ]
}