www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Debugging D applications from VS code with webfreak.debug

reply FR <fr58426 gmail.com> writes:
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
Feb 23
parent reply WebFreak001 <d.forum webfreak.org> writes:
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
Feb 23
parent reply FR <fr58426 gmail.com> writes:
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?
Feb 23
parent reply FR <fr58426 gmail.com> writes:
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)?
Feb 23
parent reply Jerry <hurricane hereiam.com> writes:
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.
Feb 23
parent FR <fr58426 gmail.com> writes:
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?
Feb 24