www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GDB - lets make D support awesome

reply "Iain Buclaw" <ibuclaw ubuntu.com> writes:
Hi,

I've created a gdb fork on github and will be giving d-lang 
support some love - with the intention of pushing patches back to 
gdb development as soon as possible.  The bulk of the work will 
be done over the next fortnight, but for some other work (see 
buglink) will take a couple more months to roll out as changes on 
both gdb and compilers need to be aligned up.

https://d.puremagic.com/issues/show_bug.cgi?id=9800


If anybody is interesting in helping out.  Would be great to get 
people developing, testing, and sending suggestions for 
features/fixes on it.  Especially users of dmd/ldc to jump on 
board to ensure that changes done don't break the existing 
support that you may have.


Note #numero uno:
To anyone who wants to send patches, do bare in mind that GDB is 
a GPLv3+ project, and any significant contributions require you 
to sign FSF copyright assignment papers.  If you do not agree 
with GPLv3+ or are unable to, or don't agree with reassigning 
your copyright (eg: your company owns your IP), then this project 
is not for you.

For those who can contribute, feel free to fork me here:
https://github.com/ibuclaw/gdb


Note #numero due:
There are a few bug reports here and there, and a few ideas I've 
got scribbled down around the place.  A new DIP should perhaps be 
created to consolidate all these thoughts together.


Note #numero tre:
Any changes to the DWARF specification will need to be raised as 
a new issue with details of change and relevant sections.  Lets 
go through the proper channels this time round rather than 
inventing tags/attributes on the fly.


That is all.
Nov 18 2013
next sibling parent reply "Iain Buclaw" <ibuclaw ubuntu.com> writes:
On Monday, 18 November 2013 at 10:41:26 UTC, Iain Buclaw wrote:
 For those who can contribute, feel free to fork me here:
 https://github.com/ibuclaw/gdb
For those that want to test, here's the checkout/build steps. # Checkout git clone https://github.com/ibuclaw/gdb.git mkdir gdb/objdir # Build cd gdb/objdir ../configure --prefix=/usr make all-gdb # Install sudo make install-gdb Regards Iain.
Nov 18 2013
parent reply "Iain Buclaw" <ibuclaw ubuntu.com> writes:
For those that like gdb, you may also be interesting in using 
cgdb (if you haven't already come across it).

Fresh copy has latest support with D syntax highlighting:

https://github.com/cgdb/cgdb
Nov 18 2013
parent Samuel Lampa <samuel.lampa gmail.com> writes:
On 2013-11-18 12:05, Iain Buclaw wrote:
 For those that like gdb, you may also be interesting in using cgdb (if 
 you haven't already come across it).

 Fresh copy has latest support with D syntax highlighting:

 https://github.com/cgdb/cgdb 
Agreed. cgdb is sweet stuff. It was what made gdb debugging usable for me. // Samuel
Nov 19 2013
prev sibling next sibling parent Bruno Medeiros <brunodomedeiros+dng gmail.com> writes:
On 18/11/2013 10:41, Iain Buclaw wrote:
 Especially users of dmd/ldc to jump on board to ensure that changes done
 don't break the existing support that you may have.
Wait, you can use GDB to debug programs created with LDC? Ah, I see, the LLVM suite generates standard DWARF debug information: http://llvm.org/docs/SourceLevelDebugging.html#philosophy-behind-llvm-debugging-information I need to try out this in practice and see how well it works. -- Bruno Medeiros - Software Engineer
Nov 18 2013
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 11/18/2013 2:41 AM, Iain Buclaw wrote:
 Hi,

 I've created a gdb fork on github and will be giving d-lang support some love -
 with the intention of pushing patches back to gdb development as soon as
 possible.  The bulk of the work will be done over the next fortnight, but for
 some other work (see buglink) will take a couple more months to roll out as
 changes on both gdb and compilers need to be aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800
Here's a list of symbolic debug info bugs in dmd: https://d.puremagic.com/issues/buglist.cgi?keywords=symdeb&query_format=advanced&keywords_type=allwords&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED Fixing these will, of course, also help with gdb usability.
Nov 18 2013
parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 18 November 2013 20:52, Walter Bright <newshound2 digitalmars.com> wrote:

 On 11/18/2013 2:41 AM, Iain Buclaw wrote:

 Hi,

 I've created a gdb fork on github and will be giving d-lang support some
 love -
 with the intention of pushing patches back to gdb development as soon as
 possible.  The bulk of the work will be done over the next fortnight, but
 for
 some other work (see buglink) will take a couple more months to roll out
 as
 changes on both gdb and compilers need to be aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800
Here's a list of symbolic debug info bugs in dmd: https://d.puremagic.com/issues/buglist.cgi?keywords= symdeb&query_format=advanced&keywords_type=allwords&bug_ status=NEW&bug_status=ASSIGNED&bug_status=REOPENED Fixing these will, of course, also help with gdb usability.
Yeah, I can't of course fix what debug information DMD produces, but I can make GDB better handle D types when it is passed the correct information. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Nov 18 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 18 November 2013 10:41, Iain Buclaw <ibuclaw ubuntu.com> wrote:

 Hi,

 I've created a gdb fork on github and will be giving d-lang support some
 love - with the intention of pushing patches back to gdb development as
 soon as possible.  The bulk of the work will be done over the next
 fortnight, but for some other work (see buglink) will take a couple more
 months to roll out as changes on both gdb and compilers need to be aligned
 up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800
And so it begins... https://github.com/ibuclaw/gdb/commit/dda127be8f6d2984b6f9a7d45efeb0871d82c220 (This copy of GDB will now search for 'D main' and point to its source location). -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Nov 18 2013
prev sibling next sibling parent "Nick" <nmsmith65 gmail.com> writes:
On Monday, 18 November 2013 at 10:41:26 UTC, Iain Buclaw wrote:
 Hi,

 I've created a gdb fork on github and will be giving d-lang 
 support some love - with the intention of pushing patches back 
 to gdb development as soon as possible.
This is fantastic. I commend you for this work to make D debugging much more practical!
Nov 18 2013
prev sibling next sibling parent Martin Nowak <code dawg.eu> writes:
On 11/18/2013 11:41 AM, Iain Buclaw wrote:
 Hi,

 I've created a gdb fork on github and will be giving d-lang support some
 love - with the intention of pushing patches back to gdb development as
 soon as possible.  The bulk of the work will be done over the next
 fortnight, but for some other work (see buglink) will take a couple more
 months to roll out as changes on both gdb and compilers need to be
 aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800
Great, I also want to look into this in the next few days. Mostly improving what dmd emits.
 Note #numero due:
 There are a few bug reports here and there, and a few ideas I've got
 scribbled down around the place.  A new DIP should perhaps be created to
 consolidate all these thoughts together.
Just file them in bugzilla. IMHO DIPs are for language enhancements.
 Note #numero tre:
 Any changes to the DWARF specification will need to be raised as a new
 issue with details of change and relevant sections.  Lets go through the
 proper channels this time round rather than inventing tags/attributes on
 the fly.
I didn't saw much need to extend any DWARF specs. It's all there, even arrays et.al. in DWARF4. The current D support in gdb treats every struct with a ptr and length field as array. I also prefixed the array types (_Array_char) so they can be recognized better by gdb, pretty-printing is missing though and I don't know whether the element types are correctly tagged.
Nov 21 2013
prev sibling parent reply Jerry <jlquinn optonline.net> writes:
"Iain Buclaw" <ibuclaw ubuntu.com> writes:

 Hi,

 I've created a gdb fork on github and will be giving d-lang support some love
 - with the intention of pushing patches back to gdb development as soon as
 possible.  The bulk of the work will be done over the next fortnight, but for
 some other work (see buglink) will take a couple more months to roll out as
 changes on both gdb and compilers need to be aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800


 If anybody is interesting in helping out.  Would be great to get people
 developing, testing, and sending suggestions for features/fixes on it.
 Especially users of dmd/ldc to jump on board to ensure that changes done don't
 break the existing support that you may have.
Hi Ian, Here's a first bug. I'm on Ubuntu 12.10 x86_64. Debugging isn't stepping through the code. Here's a simple example. This is with dmd 2.064.2 and a fresh clone of your git repo. junk2.d: import std.stdio; void main(string args[]) { string ss = "hi there"; writeln(ss); } jlquinn wyvern:~/mtd/tokenizer$ ~/dmd2/linux/bin64/dmd -g junk2.d jlquinn wyvern:~/mtd/tokenizer$ ~/d/bin/gdb junk2 GNU gdb (GDB) 7.6.50.20131118-cvs Copyright (C) 2013 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-unknown-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from junk2...done. (gdb) b main Breakpoint 1 at 0x4266a0 (gdb) run Starting program: /home/jlquinn/mtd/tokenizer/junk2 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, 0x00000000004266a0 in main () (gdb) s Single stepping until exit from function main, which has no line number information. hi there 0x00007ffff760eea5 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) show configuration This GDB was configured as follows: configure --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu --with-auto-load-dir=$debugdir:$datadir/auto-load --with-auto-load-safe-path=$debugdir:$datadir/auto-load --with-expat --with-gdb-datadir=/home/jlquinn/d/share/gdb (relocatable) --with-jit-reader-dir=/home/jlquinn/d/lib/gdb (relocatable) --without-libunwind-ia64 --without-lzma --with-python=/usr --with-separate-debug-dir=/home/jlquinn/d/lib/debug (relocatable) --with-zlib --without-babeltrace ("Relocatable" means the directory can be moved with the GDB installation tree, and GDB will still find it.)
Nov 27 2013
next sibling parent reply Iain Buclaw <ibuclaw gdcproject.org> writes:
On 27 November 2013 20:17, Jerry <jlquinn optonline.net> wrote:
 "Iain Buclaw" <ibuclaw ubuntu.com> writes:

 Hi,

 I've created a gdb fork on github and will be giving d-lang support some love
 - with the intention of pushing patches back to gdb development as soon as
 possible.  The bulk of the work will be done over the next fortnight, but for
 some other work (see buglink) will take a couple more months to roll out as
 changes on both gdb and compilers need to be aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800


 If anybody is interesting in helping out.  Would be great to get people
 developing, testing, and sending suggestions for features/fixes on it.
 Especially users of dmd/ldc to jump on board to ensure that changes done don't
 break the existing support that you may have.
Hi Ian, Here's a first bug. I'm on Ubuntu 12.10 x86_64. Debugging isn't stepping through the code. Here's a simple example. This is with dmd 2.064.2 and a fresh clone of your git repo. junk2.d: import std.stdio; void main(string args[]) { string ss = "hi there"; writeln(ss); }
Hi Jerry, I believe dmd is only compatible with gdb 7.5. Likewise gdc-4.7 is compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the development branch if you want gdb to work properly). For dmd, someone needs to fix dmd to work with gdb-7.6.
Nov 27 2013
next sibling parent Jerry <jlquinn optonline.net> writes:
Iain Buclaw <ibuclaw gdcproject.org> writes:

 On 27 November 2013 20:17, Jerry <jlquinn optonline.net> wrote:
 Hi Ian,  Here's a first bug.

  I'm on Ubuntu 12.10 x86_64.  Debugging isn't stepping through the code.
 Here's a simple example.  This is with dmd 2.064.2 and a fresh clone of
 your git repo.

 junk2.d:
 import std.stdio;

 void main(string args[]) {
     string ss = "hi there";
     writeln(ss);
 }
Hi Jerry, I believe dmd is only compatible with gdb 7.5. Likewise gdc-4.7 is compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the development branch if you want gdb to work properly). For dmd, someone needs to fix dmd to work with gdb-7.6.
FWIW, I had the same problem with gdb 7.5 installed on my system. I'll build gdc-4.8 and see how I do. Thanks
Nov 27 2013
prev sibling parent reply "Martin Nowak" <code dawg.eu> writes:
 I believe dmd is only compatible with gdb 7.5.  Likewise 
 gdc-4.7 is
 compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the
 development branch if you want gdb to work properly).

 For dmd, someone needs to fix dmd to work with gdb-7.6.
How is that? Did they drop support for DWARF2? Do we have a bug report for this?
Dec 02 2013
parent Iain Buclaw <ibuclaw gdcproject.org> writes:
On 3 December 2013 00:53, Martin Nowak <code dawg.eu> wrote:
 I believe dmd is only compatible with gdb 7.5.  Likewise gdc-4.7 is
 compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the
 development branch if you want gdb to work properly).

 For dmd, someone needs to fix dmd to work with gdb-7.6.
How is that? Did they drop support for DWARF2? Do we have a bug report for this?
Things are never dropped in GCC - only moved into a switch! :o) In GCC-4.8, DWARF4 became the default when generating DWARF debug information. Before GCC-4.8 the default used was DWARF2. Also GDB-7.5 has DWARF4 support, I think the problem is either because distributors turn this support off, or it is not as complete as in GDB-7.6. For clarification (incase anyone is interested) for all platforms except Darwin, -g will default to the following being turned on: -gdwarf-4 -fno-debug-types-section For Darwin, the old behaviour of GCC-4.7 is still the case: -gdwarf-2 -gstrict-dwarf But at last check, you guys separated out debugging for each platform, so you can keep the dwarf debugging as-is in the machobj generation. I don't think there is a bug report, but we can make one that says "DMD doesn't support DWARF4 (elfobj.c)"
Dec 03 2013
prev sibling next sibling parent Brad Roberts <braddr puremagic.com> writes:
On 11/27/13 1:56 PM, Iain Buclaw wrote:
 On 27 November 2013 20:17, Jerry <jlquinn optonline.net> wrote:
 "Iain Buclaw" <ibuclaw ubuntu.com> writes:

 Hi,

 I've created a gdb fork on github and will be giving d-lang support some love
 - with the intention of pushing patches back to gdb development as soon as
 possible.  The bulk of the work will be done over the next fortnight, but for
 some other work (see buglink) will take a couple more months to roll out as
 changes on both gdb and compilers need to be aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800


 If anybody is interesting in helping out.  Would be great to get people
 developing, testing, and sending suggestions for features/fixes on it.
 Especially users of dmd/ldc to jump on board to ensure that changes done don't
 break the existing support that you may have.
Hi Ian, Here's a first bug. I'm on Ubuntu 12.10 x86_64. Debugging isn't stepping through the code. Here's a simple example. This is with dmd 2.064.2 and a fresh clone of your git repo. junk2.d: import std.stdio; void main(string args[]) { string ss = "hi there"; writeln(ss); }
Hi Jerry, I believe dmd is only compatible with gdb 7.5. Likewise gdc-4.7 is compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the development branch if you want gdb to work properly). For dmd, someone needs to fix dmd to work with gdb-7.6.
This level of if this then thating with versions is pretty painful. It's something we've got to get past somehow (yeah, there's a chicken/egg issue). It's this sort of area where things don't "just work" that puts off developers.
Nov 27 2013
prev sibling parent reply Iain Buclaw <ibuclaw gdcproject.org> writes:
On 27 November 2013 23:15, Brad Roberts <braddr puremagic.com> wrote:
 On 11/27/13 1:56 PM, Iain Buclaw wrote:
 On 27 November 2013 20:17, Jerry <jlquinn optonline.net> wrote:
 "Iain Buclaw" <ibuclaw ubuntu.com> writes:

 Hi,

 I've created a gdb fork on github and will be giving d-lang support some
 love
 - with the intention of pushing patches back to gdb development as soon
 as
 possible.  The bulk of the work will be done over the next fortnight,
 but for
 some other work (see buglink) will take a couple more months to roll out
 as
 changes on both gdb and compilers need to be aligned up.

 https://d.puremagic.com/issues/show_bug.cgi?id=9800


 If anybody is interesting in helping out.  Would be great to get people
 developing, testing, and sending suggestions for features/fixes on it.
 Especially users of dmd/ldc to jump on board to ensure that changes done
 don't
 break the existing support that you may have.
Hi Ian, Here's a first bug. I'm on Ubuntu 12.10 x86_64. Debugging isn't stepping through the code. Here's a simple example. This is with dmd 2.064.2 and a fresh clone of your git repo. junk2.d: import std.stdio; void main(string args[]) { string ss = "hi there"; writeln(ss); }
Hi Jerry, I believe dmd is only compatible with gdb 7.5. Likewise gdc-4.7 is compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the development branch if you want gdb to work properly). For dmd, someone needs to fix dmd to work with gdb-7.6.
This level of if this then thating with versions is pretty painful. It's something we've got to get past somehow (yeah, there's a chicken/egg issue). It's this sort of area where things don't "just work" that puts off developers.
Actually, I might have got it backwards. :o) gdc-4.8 is not compatible with gdb-7.5, but gdb-7.6 should be backwards compatible, knock on wood. Jerry - have you tested debugging with -gc ?
Nov 28 2013
next sibling parent Jerry <jlquinn optonline.net> writes:
Iain Buclaw <ibuclaw gdcproject.org> writes:

 On 27 November 2013 23:15, Brad Roberts <braddr puremagic.com> wrote:
 On 11/27/13 1:56 PM, Iain Buclaw wrote:
 On 27 November 2013 20:17, Jerry <jlquinn optonline.net> wrote:
 Hi Ian,  Here's a first bug.

   I'm on Ubuntu 12.10 x86_64.  Debugging isn't stepping through the code.
 Here's a simple example.  This is with dmd 2.064.2 and a fresh clone of
 your git repo.

 junk2.d:
 import std.stdio;

 void main(string args[]) {
      string ss = "hi there";
      writeln(ss);
 }
Hi Jerry, I believe dmd is only compatible with gdb 7.5. Likewise gdc-4.7 is compatible with 7.5, but not 7.6 (you should use gdc-4.8 or the development branch if you want gdb to work properly). For dmd, someone needs to fix dmd to work with gdb-7.6.
This level of if this then thating with versions is pretty painful. It's something we've got to get past somehow (yeah, there's a chicken/egg issue). It's this sort of area where things don't "just work" that puts off developers.
Actually, I might have got it backwards. :o) gdc-4.8 is not compatible with gdb-7.5, but gdb-7.6 should be backwards compatible, knock on wood. Jerry - have you tested debugging with -gc ?
I tried with -gc and with -gc -g and get the same inability to find the frame base with dmd. I'll build gdc 48 tonight and try it.
Dec 02 2013
prev sibling parent "Martin Nowak" <code dawg.eu> writes:
 Jerry - have you tested debugging with -gc ?
-gc shouldn't be needed any longer.
Dec 02 2013