Re: debugging in vs code on Windows

2017-10-18 Thread evilrat via Digitalmars-d-learn

On Wednesday, 18 October 2017 at 07:57:25 UTC, Dmitry wrote:

On Tuesday, 17 October 2017 at 10:09:12 UTC, Dmitry wrote:

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/xwsvxphjtzgwjyrgd...@forum.dlang.org


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.


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.


Re: debugging in vs code on Windows

2017-10-18 Thread Dmitry via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 10:09:12 UTC, Dmitry wrote:

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/xwsvxphjtzgwjyrgd...@forum.dlang.org


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.


Re: debugging in vs code on Windows

2017-10-17 Thread Dmitry via Digitalmars-d-learn

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/xwsvxphjtzgwjyrgd...@forum.dlang.org




Re: debugging in vs code on Windows

2017-10-17 Thread Domain via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 08:43:33 UTC, Domain wrote:

On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:

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


Thank you very much! I used to use "mago-mi" type 
configuration, and never succeed.


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"
}
]
}


Re: debugging in vs code on Windows

2017-10-17 Thread Domain via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:

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


Thank you very much! I used to use "mago-mi" type configuration, 
and never succeed.


Re: debugging in vs code on Windows

2017-10-17 Thread Arjan via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:

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


Before this will work, one must install the Microsoft C/C++ Addin 
i.e. ms-vscode.cpptools.

Start debugging and select the C++ debugger.


Re: debugging in vs code on Windows

2017-10-16 Thread Dmitry via Digitalmars-d-learn

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



Re: debugging in vs code on Windows

2017-10-16 Thread Domain via Digitalmars-d-learn

On Sunday, 15 October 2017 at 13:54:49 UTC, Dmitry wrote:

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.


Can you share your tasks.json and launch.json?


Re: debugging in vs code on Windows

2017-10-15 Thread Dmitry via Digitalmars-d-learn

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.


Re: debugging in vs code on Windows

2017-10-14 Thread Heromyth via Digitalmars-d-learn

On Saturday, 14 October 2017 at 19:01:52 UTC, piotrklos wrote:

On Saturday, 14 October 2017 at 13:12:51 UTC, Jerry wrote:

On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:

(...)


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.


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?


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.





Re: debugging in vs code on Windows

2017-10-14 Thread Jerry via Digitalmars-d-learn

On Saturday, 14 October 2017 at 19:01:52 UTC, piotrklos wrote:

On Saturday, 14 October 2017 at 13:12:51 UTC, Jerry wrote:

On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:

(...)


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.


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?


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.


Re: debugging in vs code on Windows

2017-10-14 Thread piotrklos via Digitalmars-d-learn

On Saturday, 14 October 2017 at 13:12:51 UTC, Jerry wrote:

On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote:

(...)


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.


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?


Re: debugging in vs code on Windows

2017-10-14 Thread Jerry via Digitalmars-d-learn

On Saturday, 14 October 2017 at 14:23:34 UTC, piotrklos wrote:

On Saturday, 14 October 2017 at 13:20:27 UTC, Jerry wrote:

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


But I can already click on the edge of editor and red bubble 
appears. Its just that the execution doesn't stop on those.


That comment wasn't for you, the other one was.


Re: debugging in vs code on Windows

2017-10-14 Thread piotrklos via Digitalmars-d-learn

On Saturday, 14 October 2017 at 13:20:27 UTC, Jerry wrote:

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


But I can already click on the edge of editor and red bubble 
appears. Its just that the execution doesn't stop on those.


Re: debugging in vs code on Windows

2017-10-14 Thread Jerry via Digitalmars-d-learn

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


Re: debugging in vs code on Windows

2017-10-14 Thread Jerry via Digitalmars-d-learn

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.


Re: debugging in vs code on Windows

2017-10-14 Thread evilrat via Digitalmars-d-learn

On Saturday, 14 October 2017 at 07:40:31 UTC, piotrklos wrote:

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 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).


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?


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.


Re: debugging in vs code on Windows

2017-10-14 Thread piotrklos via Digitalmars-d-learn

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 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).


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?


Re: debugging in vs code on Windows

2017-10-13 Thread kerdemdemir via Digitalmars-d-learn

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).





debugging in vs code on Windows

2017-10-13 Thread piotrklos via Digitalmars-d-learn
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.