Thread overview
using gdb with DMD on OS X
Mar 16, 2009
John Stoneham
Oct 08, 2011
Granville Barnett
Oct 08, 2011
Granville Barnett
Jun 02, 2012
timotheecour
March 16, 2009
I've been messing around with this for a couple of hours, and I'm having difficulty determining whether gdb on OS X can be used with DMD at all (it seems to work ok with gdc). I've tried compiling with both -g and -gc switches.

The first problem is that you can't set breakpoints, with gdb complaining "No source file named" whatever. Using absolute pathnames with the break or directory commands doesn't help:

  obijohn:~/projects/d$ gdb hi
  [... copyright notice for gdb ...]
  (gdb) break hi.d:5
  No source file named hi.d.
  Make breakpoint pending on future shared library load? (y or [n])
  (gdb) directory ~/projects/d
  Source directories searched: /Users/obijohn/projects/d:$cdir:$cwd
  (gdb) pwd
  Working directory /Users/obijohn/projects/d.
  (gdb) break hi.d:5
  No source file named hi.d.
  Make breakpoint pending on future shared library load? (y or [n])
  (gdb) break "~/projects/d/hi.d:5"
  No source file named ~/projects/d/hi.d.
  Make breakpoint pending on future shared library load? (y or [n])
  (gdb) break "/Users/obijohn/projects/d/hi.d:5"
  No source file named /Users/obijohn/projects/d/hi.d.
  Make breakpoint pending on future shared library load? (y or [n])

Since this problem doesn't exist when compiling with gdc, I'm assuming it's a dmd issue (perhaps relating to the paths used in the symbolic information?).

If this is a gdb issue, then that's a bigger problem since we're stuck with the version that Apple supplies with XCode (can't update to gdb-6.8 since the gnu sources won't compile on OS X, there's no fink or macports gdb available, and the latest Apple version is 6.3.5).

Anyone had any luck with this?
October 08, 2011
On 17/03/2009 04:41, John Stoneham wrote:
> I've been messing around with this for a couple of hours, and I'm having difficulty determining whether gdb on OS X can be used with DMD at all (it seems to work ok with gdc). I've tried compiling with both -g and -gc switches.
>
> The first problem is that you can't set breakpoints, with gdb complaining "No source file named" whatever. Using absolute pathnames with the break or directory commands doesn't help:
>
>    obijohn:~/projects/d$ gdb hi
>    [... copyright notice for gdb ...]
>    (gdb) break hi.d:5
>    No source file named hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>    (gdb) directory ~/projects/d
>    Source directories searched: /Users/obijohn/projects/d:$cdir:$cwd
>    (gdb) pwd
>    Working directory /Users/obijohn/projects/d.
>    (gdb) break hi.d:5
>    No source file named hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>    (gdb) break "~/projects/d/hi.d:5"
>    No source file named ~/projects/d/hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>    (gdb) break "/Users/obijohn/projects/d/hi.d:5"
>    No source file named /Users/obijohn/projects/d/hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>
> Since this problem doesn't exist when compiling with gdc, I'm assuming it's a dmd issue (perhaps relating to the paths used in the symbolic information?).
>
> If this is a gdb issue, then that's a bigger problem since we're stuck with the version that Apple supplies with XCode (can't update to gdb-6.8 since the gnu sources won't compile on OS X, there's no fink or macports gdb available, and the latest Apple version is 6.3.5).
>
> Anyone had any luck with this?
There is gdb 7.3 in macports but the name of the binary (once built) will be ggdb.

https://trac.macports.org/browser/trunk/dports/devel/gdb/Portfile


October 08, 2011
On 17/03/2009 04:41, John Stoneham wrote:
> I've been messing around with this for a couple of hours, and I'm having difficulty determining whether gdb on OS X can be used with DMD at all (it seems to work ok with gdc). I've tried compiling with both -g and -gc switches.
>
> The first problem is that you can't set breakpoints, with gdb complaining "No source file named" whatever. Using absolute pathnames with the break or directory commands doesn't help:
>
>    obijohn:~/projects/d$ gdb hi
>    [... copyright notice for gdb ...]
>    (gdb) break hi.d:5
>    No source file named hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>    (gdb) directory ~/projects/d
>    Source directories searched: /Users/obijohn/projects/d:$cdir:$cwd
>    (gdb) pwd
>    Working directory /Users/obijohn/projects/d.
>    (gdb) break hi.d:5
>    No source file named hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>    (gdb) break "~/projects/d/hi.d:5"
>    No source file named ~/projects/d/hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>    (gdb) break "/Users/obijohn/projects/d/hi.d:5"
>    No source file named /Users/obijohn/projects/d/hi.d.
>    Make breakpoint pending on future shared library load? (y or [n])
>
> Since this problem doesn't exist when compiling with gdc, I'm assuming it's a dmd issue (perhaps relating to the paths used in the symbolic information?).
>
> If this is a gdb issue, then that's a bigger problem since we're stuck with the version that Apple supplies with XCode (can't update to gdb-6.8 since the gnu sources won't compile on OS X, there's no fink or macports gdb available, and the latest Apple version is 6.3.5).
>
> Anyone had any luck with this?
Apologies. Just seen when this was posted ;-(
June 02, 2012
did it work for you? gdb still gives me mangled symbols on osx
(even gdb 7.3 installed from source)