views:

341

answers:

2

I have a patched gdb 6.8, but I can't get any debugging to work. Given this test file:

import std.stdio;

void main()
{
    float f = 3.0;
    int i = 1;
    writeln(f, " ", i);
    f += cast(float)(i / 10.0);
    writeln(f, " ", i);
    i++;
    f += cast(float)(i / 10.0);
    writeln(f, " ", i);
    i += 2;
    f += cast(float)(i / 5.0);
    writeln(f, " ", i);
}

And attempting to debug on the command line:

bash-4.0 [d]$ dmd -g test.d  # '-gc' shows the same behaviour.
bash-4.0 [d]$ ~/src/gdb-6.8/gdb/gdb test
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html&gt;
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 "i686-pc-linux-gnu"...
(gdb) list
1 ../sysdeps/i386/elf/start.S: No such file or directory.
 in ../sysdeps/i386/elf/start.S

And debugging a project with Eclipse

Using -gc:

Dwarf Error: Cannot find DIE at 0x134e4 referenced from DIE at 0x12bd4 [in module /home/bernard/projects/drl/drl.i386]
(gdb) Dwarf Error: Cannot find DIE at 0x1810 referenced from DIE at 0x1b8 [in module /home/bernard/projects/drl/drl.i386]

Using -g:

(gdb) Die: DW_TAG_<unknown> (abbrev = 7, offset = 567)
 has children: FALSE
 attributes:
  DW_AT_byte_size (DW_FORM_data1) constant: 4
  DW_AT_type (DW_FORM_ref4) constant ref: 561 (adjusted)
  DW_AT_containing_type (DW_FORM_ref4) constant ref: 539 (adjusted)
Dwarf Error: Cannot find type of die [in module /home/bernard/projects/drl/drl.i386]

I've seen quite a few posts like this on the Digital Mars newsgroup, but all are seemingly ignored. Can anyone shed some light on the situation?

I know of ZeroBUGS, but I really want to get gdb working.

Update:

Thanks to luca_, on IRC (freenode, #D), I got the simple case (one file) working:

(gdb) list Dmain
1 void main()
2 {
3     float f = 3.0;
4     int i = 1;
5     f += cast(float)(i / 10.0);
6     i++;
7     f += cast(float)(i / 10.0);
8     i += 2;
9     f += cast(float)(i / 5.0);
10 }
(gdb) break  3

Unfortunately, my project made up of multiple files dies with a DWARF error.

EDIT:

As of 2.036 (I think), the GDB debugging information produced by DMD is correct, and should work as expected.

+1  A: 

You may have stumbled on a GDB bug, which was recently fixed here.

To get the fix, you would have to build GDB from CVS Head. Instructions on how to get it are here.

If that doesn't fix the problem, it may be due to another bug in GDB, or it may be that dmd emits incorrect DWARF debug info. I suggest opening a bug in GDB bugzilla and attaching your small executable (and all runtime libraries it requires).

Employed Russian
Unfortunately, CVS Head exhibits the same problems. This: http://d.puremagic.com/issues/show_bug.cgi?id=1079 makes me think it could be an issue with gdb. That said, ZeroBUGS works (or worked -- it won't run on this machine (and plus, Descent doesn't support it, hence wanting to get gdb working)), so it could be gdb all the same. I might have to learn of DWARF and dmd and gdb and see what I can do. No debugging bites the big one. I can't even get a stack strace (If I'm lucky, the very top function may show up)! Thanks for the info though. Gives me more places to look.
Bernard
A: 

The answer, it seems, is to use GDC, if you can stand going back to D 2.015 (this is for D2, I have no idea how old the D1 stuff is). GDB works great.

Bernard