Jump to page: 1 2
Thread overview
Debugging improvements - Visual Studio Natvis, GDB, LLDB
Apr 06, 2021
WebFreak001
Apr 23, 2021
Dennis
Apr 23, 2021
WebFreak001
Apr 23, 2021
mw
Apr 24, 2021
WebFreak001
Apr 24, 2021
mw
Apr 24, 2021
WebFreak001
Apr 24, 2021
mw
Apr 24, 2021
WebFreak001
Apr 24, 2021
Gavin Ray
Apr 24, 2021
Gavin Ray
Apr 24, 2021
mw
April 06, 2021

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

The script and setup guide are available here: https://github.com/Pure-D/dlang-debug

If you want to, please try them out, they make each of the debuggers a lot more capable at debugging D! If you find any bugs or tested what is untested in the README, please consider opening issues / making PRs.

The files all add support for:

  • string/wstring/dstring (GDB and VSDBG take length as max length, LLDB can actually read over null bytes)
  • arrays (LDC, partially with DMD)
  • associative arrays (LDC, very partially with DMD)

These debug configurations have been tested with VSCode and will all be bundled with next code-d release. An alpha can be found on Discord. Other editors will also work, Visual Studio can also use the Natvis file.

Additionally these scripts could be used to add debugging support to standard library types / popular data types. If you have ideas for some you commonly use and want to debug, post a reply here or make an issue.

*: only when program is compiled with -gc

April 23, 2021

On Tuesday, 6 April 2021 at 21:04:47 UTC, WebFreak001 wrote:

>

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

The script and setup guide are available here: https://github.com/Pure-D/dlang-debug

This is great. Pretty-printing of associative arrays is a pretty big deal!

I'm having problems setting it up though.

You say the configuration is bundled since code-d 0.23.0 but the newest version VSCode lets me select is 0.22.0 (1 year ago).
When manually adding the script in setupCommands of my cppdbg configuration:

{
	"description": "Load D GDB type extensions",
	"ignoreFailures": false,
	"text": "-interpreter-exec console \"source /path/to/gdb_dlang.py\""
}

It said Undefined command: "import" referring to line 1 import gdb.printing. It looks like it's interpreting gdb_dlang.py as a shell script, so I changed source to python, which gives the error "Python scripting is not supported in this copy of GDB".
I have GNU gdb (Debian 8.2.1-2+b3) 8.2.1.

Maybe my version is too old (I'm used to that on Debian), or I need to install some other module. I'll look into it later.

April 23, 2021

On Friday, 23 April 2021 at 20:05:30 UTC, Dennis wrote:

>

On Tuesday, 6 April 2021 at 21:04:47 UTC, WebFreak001 wrote:

>

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

The script and setup guide are available here: https://github.com/Pure-D/dlang-debug

This is great. Pretty-printing of associative arrays is a pretty big deal!

I'm having problems setting it up though.

You say the configuration is bundled since code-d 0.23.0 but the newest version VSCode lets me select is 0.22.0 (1 year ago).

yeah the readme is already written assuming I release the new code-d release finally. Currently you still need to do it manually.

>

When manually adding the script in setupCommands of my cppdbg configuration:

{
	"description": "Load D GDB type extensions",
	"ignoreFailures": false,
	"text": "-interpreter-exec console \"source /path/to/gdb_dlang.py\""
}

It said Undefined command: "import" referring to line 1 import gdb.printing. It looks like it's interpreting gdb_dlang.py as a shell script, so I changed source to python, which gives the error "Python scripting is not supported in this copy of GDB".
I have GNU gdb (Debian 8.2.1-2+b3) 8.2.1.

Maybe my version is too old (I'm used to that on Debian), or I need to install some other module. I'll look into it later.

oh that's not good, I just saw it's only enabled when built with python support, so some package maintainers might not choose to do so. Considering this is the only real way to get this working however I don't think I have another choice than assume the user has a GDB with python enabled.

April 23, 2021

On Tuesday, 6 April 2021 at 21:04:47 UTC, WebFreak001 wrote:

>

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

The script and setup guide are available here: https://github.com/Pure-D/dlang-debug

where to input this command? from gdb command line? or in .gdbinit?

-enable-pretty-printing
-interpreter-exec console "source /path/to/gdb_dlang.py"

(sorry, I googled a bit, but didn't find the answer).

April 24, 2021

On Friday, 23 April 2021 at 23:54:21 UTC, mw wrote:

>

On Tuesday, 6 April 2021 at 21:04:47 UTC, WebFreak001 wrote:

>

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

The script and setup guide are available here: https://github.com/Pure-D/dlang-debug

where to input this command? from gdb command line? or in .gdbinit?

-enable-pretty-printing
-interpreter-exec console "source /path/to/gdb_dlang.py"

(sorry, I googled a bit, but didn't find the answer).

those are GDB-MI commands. If you can only run GDB console commands you can use

source /path/to/gdb_dlang.py
enable pretty-printer
April 24, 2021

On Saturday, 24 April 2021 at 16:08:07 UTC, WebFreak001 wrote:

>

those are GDB-MI commands. If you can only run GDB console commands you can use

source /path/to/gdb_dlang.py
enable pretty-printer

Thanks, I put these 2 lines into .gdbinit, and it seems loaded.

I have a question about print AA: it only print values?

11	    int[int] aa = [1:2, 2:4];
(gdb) p aa
$1 = [2] = {4, 2}
(gdb) p aa[1]
Invalid binary operation specified.

I tried both dmd -g and ldc2 -g on Linux, both the same behavior.

April 24, 2021

On Saturday, 24 April 2021 at 17:16:48 UTC, mw wrote:

>

On Saturday, 24 April 2021 at 16:08:07 UTC, WebFreak001 wrote:

>

those are GDB-MI commands. If you can only run GDB console commands you can use

source /path/to/gdb_dlang.py
enable pretty-printer

Thanks, I put these 2 lines into .gdbinit, and it seems loaded.

I have a question about print AA: it only print values?

11	    int[int] aa = [1:2, 2:4];
(gdb) p aa
$1 = [2] = {4, 2}
(gdb) p aa[1]
Invalid binary operation specified.

I tried both dmd -g and ldc2 -g on Linux, both the same behavior.

I haven't modified the expression parsing behavior (I don't know if I can even do that), it's only pretty printers

April 24, 2021

On Tuesday, 6 April 2021 at 21:04:47 UTC, WebFreak001 wrote:

>

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

[...]

Incredible -- below in VS Code (with launch.json and dub.json config as shown on right) I am able to see arrays, strings, and associative arrays keys/values!

codefreak natvis debug

April 24, 2021

On Saturday, 24 April 2021 at 18:32:42 UTC, Gavin Ray wrote:

>

On Tuesday, 6 April 2021 at 21:04:47 UTC, WebFreak001 wrote:

>

I have created editor independent pretty printers / visualization files for Visual Studio's debugger*, GDB and LLDB.

[...]

Incredible -- below in VS Code (with launch.json and dub.json config as shown on right) I am able to see arrays, strings, and associative arrays keys/values!

It seems that the forum CSS decides to display images without display: auto or display: scroll for showing a scrollbar when it's larger than the container dimensions.

So it's cropped the image and made the config on the right not visible.

Here's a direct link to full image:
https://i.imgur.com/FvcR9B9.png

April 24, 2021

On Saturday, 24 April 2021 at 17:44:39 UTC, WebFreak001 wrote:

>

On Saturday, 24 April 2021 at 17:16:48 UTC, mw wrote:

>

On Saturday, 24 April 2021 at 16:08:07 UTC, WebFreak001 wrote:

>

those are GDB-MI commands. If you can only run GDB console commands you can use

source /path/to/gdb_dlang.py
enable pretty-printer

Thanks, I put these 2 lines into .gdbinit, and it seems loaded.

I have a question about print AA: it only print values?

11	    int[int] aa = [1:2, 2:4];
(gdb) p aa
$1 = [2] = {4, 2}
(gdb) p aa[1]
Invalid binary operation specified.

I tried both dmd -g and ldc2 -g on Linux, both the same behavior.

I haven't modified the expression parsing behavior (I don't know if I can even do that), it's only pretty printers

Why they (keys & values) are showing below in VS code?

>

Incredible -- below in VS Code (with launch.json and dub.json config as shown on right) I am able to see arrays, strings, and associative arrays keys/values!

The implementations are different? or there are fundamental obstacles that cannot be done for GDB console?

« First   ‹ Prev
1 2