Debugging D code with GDB

user1234 user1234 at 12.de
Sun Nov 28 14:53:17 UTC 2021


On Saturday, 27 November 2021 at 14:17:11 UTC, Eduard Staniloiu 
wrote:
> Hello,
>
> I'm trying to use `gdb` to debug D binaries, but I'm having 
> trouble accessing the methods of a struct or class. It seems 
> that `gdb` doesn't see them.
>
> [...]
>
> Looking forward to your answers,
> Edi
>
> [0] - https://sourceware.org/bugzilla/show_bug.cgi?id=22480

Hello, while I never evaluate calls during debugging I've managed 
to find
a way : you can call the mangled name so for

```d
#!dmd -g
module a;

import std.stdio;

struct S
{
     int myPrint(){return 8;}
}

pragma(msg, S.myPrint.mangleof);
int main(string[] args)
{
     S s;
     return 0;
}
```
in gdb CLI

```bash
p (int) _D1a1S7myPrintMFZi(s)
$1 = 8
```

works. Note that for some reasons writefln causes a crash, that's 
why I've modified the example.

The problem is that my workaround does not scale better than your.


More information about the Digitalmars-d-learn mailing list