Thread overview
Help with GDB?
Dec 31, 2008
jq
Jan 01, 2009
naryl
Jan 01, 2009
Adam D. Ruppe
December 31, 2008
Reposted from digitmars.D.debugger, because there seems to be no life there:

Note that I'm seeing the same problem with gdc compiled programs.  This is on linux - debian testing, to be precise.  Thanks for any help here.

---------

Hi.  I'm porting a program from C++ to D and finally at the point to try running it.  Needless to say, there are bugs, and I'm trying to debug them.

I've applied the patch floating around to GDB 6.8 to support D.  I then take a trivial hello world program, compile with dmd -g and run inside gdb.  Whether or not I use the D patches, I get the following behavior.

Any suggestions?

Thanks

jlquinn@cerberus:~/d$ gdb ./junk
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb) b main
Breakpoint 1 at 0x804aa79
(gdb) run
Starting program: /home/jlquinn/d/junk
[Thread debugging using libthread_db enabled]
[New Thread 0xf7d43ae0 (LWP 22977)]
[Switching to Thread 0xf7d43ae0 (LWP 22977)]

Breakpoint 1, 0x0804aa79 in main ()
Current language:  auto; currently asm
(gdb) l
1        /tmp/cc2j8MlC.s: No such file or directory.
        in /tmp/cc2j8MlC.s
(gdb)

January 01, 2009
jq Wrote:

> Reposted from digitmars.D.debugger, because there seems to be no life there:
> 
> Note that I'm seeing the same problem with gdc compiled programs.  This is on linux - debian testing, to be precise.  Thanks for any help here.
> 
> ---------
> 
> Hi.  I'm porting a program from C++ to D and finally at the point to try running it.  Needless to say, there are bugs, and I'm trying to debug them.
> 
> I've applied the patch floating around to GDB 6.8 to support D.  I then take a trivial hello world program, compile with dmd -g and run inside gdb.  Whether or not I use the D patches, I get the following behavior.
> 
> Any suggestions?
> 
> Thanks
> 
> jlquinn@cerberus:~/d$ gdb ./junk
> GNU gdb 6.8-debian
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu"...
> (gdb) b main
> Breakpoint 1 at 0x804aa79
> (gdb) run
> Starting program: /home/jlquinn/d/junk
> [Thread debugging using libthread_db enabled]
> [New Thread 0xf7d43ae0 (LWP 22977)]
> [Switching to Thread 0xf7d43ae0 (LWP 22977)]
> 
> Breakpoint 1, 0x0804aa79 in main ()
> Current language:  auto; currently asm
> (gdb) l
> 1        /tmp/cc2j8MlC.s: No such file or directory.
>         in /tmp/cc2j8MlC.s
> (gdb)
> 

For some reason you have to set breakpoints using line numbers or mangled names such as _Dmain. Also when debugging dmd-compiled binaries gdb won't show you line numbers in backtrace. The only solution that I know of is to compile with ldc. Haven't tried gdc yet.
January 01, 2009
On Wed, Dec 31, 2008 at 03:23:19PM -0500, jq wrote:
> Hi.  I'm porting a program from C++ to D and finally at the point to try running it.  Needless to say, there are bugs, and I'm trying to debug them.

I always use dmd -gc   - "debug, pretend to be C" when I'm going to be working with gdb. It isn't the prettiest output, but it works well enough for me.

-- 
Adam D. Ruppe
http://arsdnet.net