digitalmars.D.learn - debugging in vs code on Windows
- piotrklos (11/11) Oct 13 2017 I have windows 10, VS Code with code-d and C/C++ language
- kerdemdemir (7/19) Oct 13 2017 I am using VisualD(https://github.com/dlang/visuald/releases)
- piotrklos (5/13) Oct 14 2017 I will consider that, but I really like VS Code because I often
- evilrat (7/21) Oct 14 2017 Only "dub generate visuald"
- Jerry (12/24) Oct 14 2017 If you use generate a 32-bit binary using DMD, it generates it in
- piotrklos (7/20) Oct 14 2017 I have added this to dub.json:
- Dmitry (6/8) Oct 15 2017 Yep, it work for me.
- Domain (2/10) Oct 16 2017 Can you share your tasks.json and launch.json?
- Dmitry (23/24) Oct 16 2017 tasks.json - I don't have this file.
I have windows 10, VS Code with code-d and C/C++ language extensions. I try to debug but it doesn't work. In particular, the debugging doesn't stop on breakpoints. It exits immediately. I recompile with -m64 and -g. I use dub to build the project. I use unit-threaded and I'm trying to debug a unittest build. Has anyone been able to debug in VS code on Windows? What am I doing wrong? (Rhetorical) Why is dlang community provide so many options (see https://wiki.dlang.org/Debuggers) and **every single one** of them is faulty in some way? I tried windbg and mago-mi but didn't gen anywhere.
Oct 13 2017
On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I have windows 10, VS Code with code-d and C/C++ language extensions. I try to debug but it doesn't work. In particular, the debugging doesn't stop on breakpoints. It exits immediately. I recompile with -m64 and -g. I use dub to build the project. I use unit-threaded and I'm trying to debug a unittest build. Has anyone been able to debug in VS code on Windows? What am I doing wrong? (Rhetorical) Why is dlang community provide so many options (see https://wiki.dlang.org/Debuggers) and **every single one** of them is faulty in some way? I tried windbg and mago-mi but didn't gen anywhere.I am using VisualD(https://github.com/dlang/visuald/releases) with vs2015 community version(free) and I can debug. I highly recommend it if you haven't tried yet. Those options like "-g" is presented to you with interfaces. Forexample "-g" is automatically is being added if you are selecting debug builds(like Debug DMD or Debug LDC).
Oct 13 2017
On Friday, 13 October 2017 at 17:04:00 UTC, kerdemdemir wrote:On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I will consider that, but I really like VS Code because I often switch between Linux and Windows machine, so I can have the same thing on both. Does VisualD play well with dub?(...)I am using VisualD(https://github.com/dlang/visuald/releases) with vs2015 community version(free) and I can debug. I highly recommend it if you haven't tried yet. Those options like "-g" is presented to you with interfaces. Forexample "-g" is automatically is being added if you are selecting debug builds(like Debug DMD or Debug LDC).
Oct 14 2017
On Saturday, 14 October 2017 at 07:40:31 UTC, piotrklos wrote:On Friday, 13 October 2017 at 17:04:00 UTC, kerdemdemir wrote:Only "dub generate visuald" As for VS Code you need code-d extension, MS C++ extension in order to debug, and webfreak's NativeDebug extension to be able to click to set breakpoint on lines(only for that). Then under the debug pallette configure MS VS debugger and hit run from there. That's it.On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I will consider that, but I really like VS Code because I often switch between Linux and Windows machine, so I can have the same thing on both. Does VisualD play well with dub?(...)I am using VisualD(https://github.com/dlang/visuald/releases) with vs2015 community version(free) and I can debug. I highly recommend it if you haven't tried yet. Those options like "-g" is presented to you with interfaces. Forexample "-g" is automatically is being added if you are selecting debug builds(like Debug DMD or Debug LDC).
Oct 14 2017
On Saturday, 14 October 2017 at 10:15:53 UTC, evilrat wrote:webfreak's NativeDebug extension to be able to click to set breakpoint on lines(only for that).You can just use VS Code setting, put the following into your settings.json: "debug.allowBreakpointsEverywhere": true
Oct 14 2017
On Saturday, 14 October 2017 at 13:20:27 UTC, Jerry wrote:On Saturday, 14 October 2017 at 10:15:53 UTC, evilrat wrote:But I can already click on the edge of editor and red bubble appears. Its just that the execution doesn't stop on those.webfreak's NativeDebug extension to be able to click to set breakpoint on lines(only for that).You can just use VS Code setting, put the following into your settings.json: "debug.allowBreakpointsEverywhere": true
Oct 14 2017
On Saturday, 14 October 2017 at 14:23:34 UTC, piotrklos wrote:On Saturday, 14 October 2017 at 13:20:27 UTC, Jerry wrote:That comment wasn't for you, the other one was.On Saturday, 14 October 2017 at 10:15:53 UTC, evilrat wrote:But I can already click on the edge of editor and red bubble appears. Its just that the execution doesn't stop on those.webfreak's NativeDebug extension to be able to click to set breakpoint on lines(only for that).You can just use VS Code setting, put the following into your settings.json: "debug.allowBreakpointsEverywhere": true
Oct 14 2017
On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I have windows 10, VS Code with code-d and C/C++ language extensions. I try to debug but it doesn't work. In particular, the debugging doesn't stop on breakpoints. It exits immediately. I recompile with -m64 and -g. I use dub to build the project. I use unit-threaded and I'm trying to debug a unittest build. Has anyone been able to debug in VS code on Windows? What am I doing wrong? (Rhetorical) Why is dlang community provide so many options (see https://wiki.dlang.org/Debuggers) and **every single one** of them is faulty in some way? I tried windbg and mago-mi but didn't gen anywhere.If you use generate a 32-bit binary using DMD, it generates it in a format that the C/C++ extension doesn't understand. You need to compile -m32mscoff or -m64, and you need to make sure the /DEBUG is passed to the linker, as I don't think dmd passes it that. You can do that by passing "-L/DEBUG" to DMD (when using -m32mscoff or -m64). There should be a .pdb file that gets generated, when you start the debugger it should say that symbols were loaded for the exe. I also can't say for certain if debug information is even generated for the unittests, so that might be something worth looking into to make sure it does.
Oct 14 2017
On Saturday, 14 October 2017 at 13:12:51 UTC, Jerry wrote:On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I have added this to dub.json: "dmd-flags":[ "-g", "-m64", "-L/DEBUG" ] but I don't see a pdb file generated when I build. What am I doing wrong?(...)If you use generate a 32-bit binary using DMD, it generates it in a format that the C/C++ extension doesn't understand. You need to compile -m32mscoff or -m64, and you need to make sure the /DEBUG is passed to the linker, as I don't think dmd passes it that. You can do that by passing "-L/DEBUG" to DMD (when using -m32mscoff or -m64). There should be a .pdb file that gets generated, when you start the debugger it should say that symbols were loaded for the exe. I also can't say for certain if debug information is even generated for the unittests, so that might be something worth looking into to make sure it does.
Oct 14 2017
On Saturday, 14 October 2017 at 19:01:52 UTC, piotrklos wrote:On Saturday, 14 October 2017 at 13:12:51 UTC, Jerry wrote:Are you sure it's not dflags? I don't use dub but a quick search shows there's dflags, but no flags setting. https://code.dlang.org/package-format?lang=json Also using verbose flag with dub should show you the commands that are executed for building.On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I have added this to dub.json: "dmd-flags":[ "-g", "-m64", "-L/DEBUG" ] but I don't see a pdb file generated when I build. What am I doing wrong?(...)If you use generate a 32-bit binary using DMD, it generates it in a format that the C/C++ extension doesn't understand. You need to compile -m32mscoff or -m64, and you need to make sure the /DEBUG is passed to the linker, as I don't think dmd passes it that. You can do that by passing "-L/DEBUG" to DMD (when using -m32mscoff or -m64). There should be a .pdb file that gets generated, when you start the debugger it should say that symbols were loaded for the exe. I also can't say for certain if debug information is even generated for the unittests, so that might be something worth looking into to make sure it does.
Oct 14 2017
On Saturday, 14 October 2017 at 19:01:52 UTC, piotrklos wrote:On Saturday, 14 October 2017 at 13:12:51 UTC, Jerry wrote:It's not necessary to set "dmd-flags". You need to run dub with "--arch=x86_64 --build=debug". Then, the .pdb file is under the folder .dub. To start a debug session, you would add a config file called launch.json, set the "program" and press F5. By the way, don't foret to add a breakpoint.On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:I have added this to dub.json: "dmd-flags":[ "-g", "-m64", "-L/DEBUG" ] but I don't see a pdb file generated when I build. What am I doing wrong?(...)If you use generate a 32-bit binary using DMD, it generates it in a format that the C/C++ extension doesn't understand. You need to compile -m32mscoff or -m64, and you need to make sure the /DEBUG is passed to the linker, as I don't think dmd passes it that. You can do that by passing "-L/DEBUG" to DMD (when using -m32mscoff or -m64). There should be a .pdb file that gets generated, when you start the debugger it should say that symbols were loaded for the exe. I also can't say for certain if debug information is even generated for the unittests, so that might be something worth looking into to make sure it does.
Oct 14 2017
On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:Has anyone been able to debug in VS code on Windows? What am I doing wrong?Yep, it work for me. How do you start debugging? I noticed that the bottom button (small bug) at status bar doesn't work for me. But when I use Debug → Start Debugging (F5), it works.
Oct 15 2017
On Sunday, 15 October 2017 at 13:54:49 UTC, Dmitry wrote:On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:Can you share your tasks.json and launch.json?Has anyone been able to debug in VS code on Windows? What am I doing wrong?Yep, it work for me. How do you start debugging? I noticed that the bottom button (small bug) at status bar doesn't work for me. But when I use Debug → Start Debugging (F5), it works.
Oct 16 2017
On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote:Can you share your tasks.json and launch.json?tasks.json - I don't have this file. launch.json: { "version": "0.2.0", "configurations": [ { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}\\parser.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true } ] } Also I have changed preferences: "debug.allowBreakpointsEverywhere": true, Status bar: x86_64 debug dmd
Oct 16 2017
On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote:Before this will work, one must install the Microsoft C/C++ Addin i.e. ms-vscode.cpptools. Start debugging and select the C++ debugger.Can you share your tasks.json and launch.json?tasks.json - I don't have this file. launch.json: { "version": "0.2.0", "configurations": [ { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}\\parser.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true } ] } Also I have changed preferences: "debug.allowBreakpointsEverywhere": true, Status bar: x86_64 debug dmd
Oct 17 2017
On Tuesday, 17 October 2017 at 08:38:20 UTC, Arjan wrote:Before this will work, one must install the Microsoft C/C++ Addin i.e. ms-vscode.cpptools. Start debugging and select the C++ debugger.Yep https://forum.dlang.org/post/xwsvxphjtzgwjyrgdquu forum.dlang.org
Oct 17 2017
On Tuesday, 17 October 2017 at 10:09:12 UTC, Dmitry wrote:On Tuesday, 17 October 2017 at 08:38:20 UTC, Arjan wrote:Yesterday I found that C/C++ debugger is not very usable for D. For example, it doesn't show some structs and associative arrays (shows it just as pointer), pointer+length+chunk of memory instead of string, etc. So, I had to use VisualStudio + Mago for debugging.Before this will work, one must install the Microsoft C/C++ Addin i.e. ms-vscode.cpptools. Start debugging and select the C++ debugger.Yep https://forum.dlang.org/post/xwsvxphjtzgwjyrgdquu forum.dlang.org
Oct 18 2017
On Wednesday, 18 October 2017 at 07:57:25 UTC, Dmitry wrote:On Tuesday, 17 October 2017 at 10:09:12 UTC, Dmitry wrote:That's because compiler doesn't (yet) generates all necessary debug info. x86_mscoff had better support last time I checked. And structs can be observed using watch, like if it is C++ variable (&some_struct), not sure about strings though.On Tuesday, 17 October 2017 at 08:38:20 UTC, Arjan wrote:Yesterday I found that C/C++ debugger is not very usable for D. For example, it doesn't show some structs and associative arrays (shows it just as pointer), pointer+length+chunk of memory instead of string, etc. So, I had to use VisualStudio + Mago for debugging.Before this will work, one must install the Microsoft C/C++ Addin i.e. ms-vscode.cpptools. Start debugging and select the C++ debugger.Yep https://forum.dlang.org/post/xwsvxphjtzgwjyrgdquu forum.dlang.org
Oct 18 2017
On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote:Thank you very much! I used to use "mago-mi" type configuration, and never succeed.Can you share your tasks.json and launch.json?tasks.json - I don't have this file. launch.json: { "version": "0.2.0", "configurations": [ { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}\\parser.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true } ] } Also I have changed preferences: "debug.allowBreakpointsEverywhere": true, Status bar: x86_64 debug dmd
Oct 17 2017
On Tuesday, 17 October 2017 at 08:43:33 UTC, Domain wrote:On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:This is my tasks.json: { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", // Run the dub command to do a build or test "type": "shell", "command": "dub", "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared" }, "tasks": [ { "taskName": "build", "args": [ "--arch=x86_mscoff", "--build=debug" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": { "owner": "d", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^([^(]*)\\((\\d+),\\s*(\\d+)\\):\\s*(Warning|Error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } }, { "taskName": "test", "group": "test", "problemMatcher": { "owner": "d", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^([^(]*)\\((\\d+),\\s*(\\d+)\\):\\s*(Warning|Error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } } ] } And this is my launch.json: { // 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": "Debug", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}/app.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true, "preLaunchTask": "build" } ] }On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote:Thank you very much! I used to use "mago-mi" type configuration, and never succeed.Can you share your tasks.json and launch.json?tasks.json - I don't have this file. launch.json: { "version": "0.2.0", "configurations": [ { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}\\parser.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true } ] } Also I have changed preferences: "debug.allowBreakpointsEverywhere": true, Status bar: x86_64 debug dmd
Oct 17 2017