debug libraries
Giorgos Keramidas
keramida at ceid.upatras.gr
Fri Feb 26 18:07:49 UTC 2010
On Thu, 25 Feb 2010 11:09:36 -0800 (PST), "Dr. Baud" <drbaud at yahoo.com> wrote:
> Apologies if this is the wrong list....
>
> Are there prepackaged debug versions of the system libraries available
> (like 'yum install *-debuginfo' in Fedora and 'apt-get install *-dbg'
> in Ubuntu)?
No, not really. You can always build a base system *with* debugging
symbols from source though. Naturally, this is not as fast to install
as a small set of pre-built packages, but it is at least possible.
For example, my laptop runs a base system _with_ debugging symbols most
of the time. To rebuild everything I made the following changes to my
'/etc/make.conf' file:
1. I enabled the DEBUG_FLAGS option, by adding the following:
DEBUG_FLAGS ?= -g
2. I checked that I am not using high optimization levels in CFLAGS or
COPTFLAGS.
3. I enabled the NO_CPU_CFLAGS and NO_CPU_COPTFLAGS options:
NO_CPU_CFLAGS= # Don't add -march=<cpu> to CFLAGS automatically
NO_CPU_COPTFLAGS= # Don't add -march=<cpu> to COPTFLAGS automatically
Then I rebuilt everything from my latest source tree at /usr/src.
The combined effect of NO_CPU_CFLAGS and DEBUG_FLAGS is that binaries
are not stripped before they are installed, and optimization flags are
not added automatically by the build system.
Note #1. The resulting binaries are *much* larger. For example the
ed(1) editor in unstripped format is 123 KB on my laptop, but stripping
it reduces its size down to 48 KB:
keramida at kobe:/tmp$ ls -ld /bin/ed
-r-xr-xr-x 2 root wheel - 123663 16 Φεβ 12:25 /bin/ed
keramida at kobe:/tmp$ cp -a /bin/ed ed
keramida at kobe:/tmp$ sudo strip -s ed
keramida at kobe:/tmp$ ls -ld ed
-r-xr-xr-x 1 keramida wheel - 48400 26 Φεβ 17:24 ed
The effect of enabling debugging flags for larger programs like gcc, gdb
or bind is much much larger than ed(1) of course.
Note #2. There's probably a measurable performance hit by running a
debugging base system, because -O2 optimizations do not get a chance to
do their magic as you build your binaries.
HTH,
Giorgos
More information about the freebsd-hackers
mailing list