Blog post about printing associative arrays from GDB

Johannes Riecken johannes.riecken at
Tue Nov 12 09:09:16 UTC 2019

I created an initial version and would be glad to get some 
feedback. I couldn't figure out how to call the _AAGetX-style 
functions, so I just went with the approach in my blog post to 
get something working that can be refactored later.

Here is the code. It currently works with gdc, but not with dmd, 
because dmd calls the type like _AArray_int_int, not int[int]. 
Also note that it creates (or overwrites) two files in the 
directory, and helpers.d:

I kept the generated files in there to ease experimentation 
(which I would take out later) and still it's very little code. 
To get it working I had to add the directory containing the code 
to my .gdbinit with `add-auto-load-safe-path ~/workspace/pretty`
gdb can auto-load python files related to an executable if they 
are named as <executable_name>, so I did that for my 
example executable foo (which i create with `gdc-9 -g -o foo 
foo.d`. To check if my code works I used the command

     PYTHONPATH=. gdb ./foo -ex 'b 3' -ex run -ex 'p dict'

For troubleshooting, check the output of `info pretty-printer` in 
Support for custom structs should be easy enough to add, but I 
need to work now. Cheers!

More information about the Digitalmars-d-announce mailing list