Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Feb 2011 23:18:04 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r218984 - head/lib/librt
Message-ID:  <4D65879C.8090607@FreeBSD.org>
In-Reply-To: <20110224084812.F1571@besplex.bde.org>
References:  <201102232117.p1NLHcuE011679@svn.freebsd.org> <20110224084812.F1571@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2011-02-23 23:04, Bruce Evans wrote:
> Hard-coded -g is a style bug, but I wonder if this works even with -g in
> DEBUG_FLAGS.

Yes, it works, I tested it.  The issue is that bsd.lib.mk contains this
fragment:

.if defined(WITH_CTF)
.undef NO_CTF
.endif

.if defined(DEBUG_FLAGS)
CFLAGS+= ${DEBUG_FLAGS}

.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "")
CTFFLAGS+= -g
.endif
.endif

E.g. if you put '-g' in CFLAGS, this fragment will fail to add the
required '-g to CTFFLAGS.  On the other hand, if you add '-g' to
DEBUG_FLAGS, '-g' will be added to both CFLAGS and CTFFLAGS.


> This may be related to the bug that -g is broken if the compilation is
> via an intermediate asm file:
>
>   	"cc -g -o foo foo.c"  != "cc -g -S foo.c; cc -g -o foo foo.s"
>
> The former works, but the latter gives:
>
> % Script started on Wed Feb 23 21:47:19 2011
> %
> % pts/0:bde@ref9-i386:~/r>  gdb foo
> % GNU gdb 6.1.1 [FreeBSD]
> % Copyright 2004 Free Software Foundation, Inc.
> % GDB is free software, covered by the GNU General Public License, and you are
> % welcome to change it and/or distribute copies of it under certain conditions.
> % Type "show copying" to see the conditions.
> % There is absolutely no warranty for GDB.  Type "show warranty" for details.
> % This GDB was configured as "i386-marcel-freebsd"...Dwarf Error: Could not find abbrev number 47 [in module /dumpster/home/bde/r/foo]
> %
> % (gdb) q
> % pts/0:bde@ref9-i386:~/r>  exit

Seems to work fine here (tree as of r218915, so with binutils 2.17.50):

$ cc -g -S hello.c
$ cc -g hello.s -o hello
$ file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 9.0 (900033), not stripped
$ gdb ./hello
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) list
1       #include <stdio.h>
2
3       int main(void)
4       {
5               puts("Hello World!");
6
7               return 0;
8       }
(gdb)


> Perhaps you already fixed this by importing newer binutils.

Apparently, yes.  Maybe ref9-i386 should be updated again. :)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D65879C.8090607>