D2 and gdb

Robert Clipsham robert at octarineparrot.com
Tue Jan 25 14:33:06 PST 2011


On 25/01/11 20:44, vnm wrote:
> Hi!
>
> Is there any support of D2 in gdb 7.2 ?
>
> Little example to clarify my question:
>
> ------------------------------------------------------------
>
> // file main.d
> int glVar = 0xAAAAAAAA;
>
> void main()
> {
> glVar = 0xBBBBBBBB;
> }
>
> ------------------------------------------------------------
>
> I compiled it using command "dmd -gc -debug main.d";
> then I load it to gdb and trying to debug application:
>
> ------------------------------------------------------------
>
> vnm at vnm:~/proj/d_gdb_test$ gdb main
> GNU gdb (GDB) 7.2-ubuntu
> Copyright (C) 2010 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> 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-linux-gnu".
> For bug reporting instructions, please see:
> ...
> Reading symbols from /home/vnm/proj/d_gbb_test/main...done.
> (gdb) b main
> Breakpoint 1 at 0x804b667
> (gdb) r
> Starting program: /home/vnm/proj/d_gbb_test/main
> [Thread debugging using libthread_db enabled]
>
> Breakpoint 1, 0x0804b667 in main ()
> (gdb) info line
> No line number information available.
> (gdb) info variables glVar
> All variables matching regular expression "glVar":
>
> File main.d:
> int _D4main5glVari;
>
> ------------------------------------------------------------
>
> Why gdb can't show line information and why it shows symbols in mangled
> form ? Is this software issues or I'm doing something wrong ?
> AFAIK, gdb 7.2 integrated some patch for D support (including symbols
> demangling feature). This patch was D1 only ?

As Steven has already stated, you need to use 'b _Dmain', then it will 
work as expected. When you do 'b main' it breaks at the runtime main() 
function, which handles things like uncaught exceptions, runtime 
initialisation, static constructors and destructors, unittest running 
etc. As the version of druntime that dmd is linking to has no debugging 
information, you end up with the above issues.

Hope this helps.

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d-learn mailing list