Thread overview
Linux DWARF2 Line Numbering not working
Feb 28, 2005
John Demme
Feb 28, 2005
John Demme
Mar 01, 2005
John Demme
February 28, 2005
When I compile this file with:
dmd -g test.d
using DMD 0.113 on Linux, then run
gdb test
and at the gdb command prompt run:
(gdb) b test.d:7
To set a breakpoint at line 7, it gives me:
No line 7 in file "test.d".
According to emacs, line 7 is the second writefln line.


I've not yet been able to get linux debugging to work, and worse yet, I haven't even been able to get any responses about this.  Supposedly, the DWARF2 line number info was added in DMD 0.103, but doesn't work.

The unfortunate part is that I've been posting about this for some time, and haven't been able to get a single person to respond about it.  Can anyone even verify that this isn't just my computer?  Has anyone else had success with Linux Debugging?

This total lack of responsiveness is really starting to get to me.

John Demme


February 28, 2005
John Demme wrote:

> When I compile this file with:
> dmd -g test.d
> using DMD 0.113 on Linux, then run
> gdb test
> and at the gdb command prompt run:
> (gdb) b test.d:7
> To set a breakpoint at line 7, it gives me:
> No line 7 in file "test.d".
> According to emacs, line 7 is the second writefln line.

Same behaviour in DMD 0.114, on Fedora Core 1.

> The unfortunate part is that I've been posting about this for some time, and haven't been able to get a single person to respond about it.  Can anyone even verify that this isn't just my computer?  Has anyone else had success with Linux Debugging?

However, the same program works fine with GDC 0.10:

(gdb) b test.d:7
Breakpoint 1 at 0x80495f3: file test.d, line 7.
(gdb) run
Starting program: /tmp/test
[Thread debugging using libthread_db enabled]
[New Thread -1084688992 (LWP 21617)]
5
[Switching to Thread -1084688992 (LWP 21617)]

Breakpoint 1, _Dmain () at test.d:7
7         writefln("%d", a);


So you might consider changing compilers meanwhile ?

--anders
February 28, 2005
I've been trying GDC as well, and it seems to work pretty well with small programs, but either it's got some issues as well, or I'm having some other problems with larger programs, like ones that use Mango.

Thanks for the reply,
John

Anders F Björklund wrote:
> John Demme wrote:
> 
>> When I compile this file with:
>> dmd -g test.d
>> using DMD 0.113 on Linux, then run
>> gdb test
>> and at the gdb command prompt run:
>> (gdb) b test.d:7
>> To set a breakpoint at line 7, it gives me:
>> No line 7 in file "test.d".
>> According to emacs, line 7 is the second writefln line.
> 
> 
> Same behaviour in DMD 0.114, on Fedora Core 1.
> 
>> The unfortunate part is that I've been posting about this for some time, and haven't been able to get a single person to respond about it.  Can anyone even verify that this isn't just my computer?  Has anyone else had success with Linux Debugging?
> 
> 
> However, the same program works fine with GDC 0.10:
> 
> (gdb) b test.d:7
> Breakpoint 1 at 0x80495f3: file test.d, line 7.
> (gdb) run
> Starting program: /tmp/test
> [Thread debugging using libthread_db enabled]
> [New Thread -1084688992 (LWP 21617)]
> 5
> [Switching to Thread -1084688992 (LWP 21617)]
> 
> Breakpoint 1, _Dmain () at test.d:7
> 7         writefln("%d", a);
> 
> 
> So you might consider changing compilers meanwhile ?
> 
> --anders
March 01, 2005
John Demme wrote:

> I've been trying GDC as well, and it seems to work pretty well with small programs, but either it's got some issues as well, or I'm having some other problems with larger programs, like ones that use Mango.

Hear you on the Mango problems...


Well, DMD got tracing (-gt) fixed recently - maybe the debugging
support (-g) can be fixed in a short matter of time as well... ?

The release notes just say:
> -g is not implemented, because I haven't figured out how to
> do it yet. gdb still works, though, at the global symbol level.

--anders
March 01, 2005
Anders F Björklund wrote:
> John Demme wrote:
> 
>> I've been trying GDC as well, and it seems to work pretty well with small programs, but either it's got some issues as well, or I'm having some other problems with larger programs, like ones that use Mango.
> 
> 
> Hear you on the Mango problems...
> 
> 
> Well, DMD got tracing (-gt) fixed recently - maybe the debugging
> support (-g) can be fixed in a short matter of time as well... ?
> 
> The release notes just say:
> 
>> -g is not implemented, because I haven't figured out how to
>> do it yet. gdb still works, though, at the global symbol level.
> 

Right, but if you look at the Changelog, line numbering was added in 0.103.
March 01, 2005
John Demme wrote:

>> The release notes just say:
>>
>>> -g is not implemented, because I haven't figured out how to
>>> do it yet. gdb still works, though, at the global symbol level.
> 
> Right, but if you look at the Changelog, line numbering was added in 0.103.

Interesting, it seems to include *some* line numbers:

> import std.stdio;
> int main()
> {
>   writefln("Hello, World!");
>   return 0;
> }

dmd -g -release -c hello.d

objdump -l -d hello.o

> hello.o:     file format elf32-i386
> 
> Disassembly of section .text:
> 
> 00000000 <gcc2_compiled.>:
> _Dmain():
> /tmp/hello.d:2
>    0:   c3 60 b8 38 00 00 00 b9 00 00 00 00 8b 11 89 10     .`.8............
> gcc2_compiled.():
>   10:   89 01 61 c3                                         ..a.
> Disassembly of section .gnu.linkonce.t_Dmain:
> 
> 00000000 <_Dmain>:
> _Dmain():
>    0:   55                      push   %ebp
>    1:   8b ec                   mov    %esp,%ebp
> /tmp/hello.d:4
>    3:   ff 35 14 00 00 00       pushl  0x14
>    9:   ff 35 10 00 00 00       pushl  0x10
>    f:   ff 35 04 00 00 00       pushl  0x4
>   15:   ff 35 00 00 00 00       pushl  0x0
>   1b:   e8 fc ff ff ff          call   1c <_Dmain+0x1c>
>   20:   31 c0                   xor    %eax,%eax
>   22:   83 c4 10                add    $0x10,%esp
>   25:   5d                      pop    %ebp
>   26:   c3                      ret    

As opposed to:

> #include <stdio.h>
> int main()
> {
>   printf("Hello, World!\n");
>   return 0;
> }

gcc -g -c chello.c

objdump -l -d chello.o

> chello.o:     file format elf32-i386
> 
> Disassembly of section .text:
> 
> 00000000 <main>:
> main():
> /tmp/chello.c:3
>    0:   55                      push   %ebp
>    1:   89 e5                   mov    %esp,%ebp
>    3:   83 ec 08                sub    $0x8,%esp
>    6:   83 e4 f0                and    $0xfffffff0,%esp
>    9:   b8 00 00 00 00          mov    $0x0,%eax
>    e:   83 c0 0f                add    $0xf,%eax
>   11:   83 c0 0f                add    $0xf,%eax
>   14:   c1 e8 04                shr    $0x4,%eax
>   17:   c1 e0 04                shl    $0x4,%eax
>   1a:   29 c4                   sub    %eax,%esp
> /tmp/chello.c:4
>   1c:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
>   23:   e8 fc ff ff ff          call   24 <main+0x24>
> /tmp/chello.c:5
>   28:   b8 00 00 00 00          mov    $0x0,%eax
> /tmp/chello.c:6
>   2d:   c9                      leave    2e:   c3                      ret    

--anders