Re: --enable-debug does not work with gcc - Mailing list pgsql-hackers

From Tom Lane
Subject Re: --enable-debug does not work with gcc
Date
Msg-id 15034.1170429785@sss.pgh.pa.us
Whole thread Raw
In response to Re: --enable-debug does not work with gcc  (NikhilS <nikkhils@gmail.com>)
Responses Re: --enable-debug does not work with gcc  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
NikhilS <nikkhils@gmail.com> writes:
> True, this is how I myself circumvent this problem too. But IMHO,
> explicitly passing CFLAGS when we are invoking --enable-debug (which does
> add -g, but leaves some optimization flag around which deters debugging)
> does not seem correct?

If we did what you suggest, then --enable-debug would cause performance
degradation, which would cause people to not use it, which would result
in most binaries being completely undebuggable rather than only partially.
Doesn't sound like a good tradeoff to me.

Personally, in my development tree I use a Makefile.custom containing

# back off optimization unless profiling
ifeq ($(PROFILE),)  CFLAGS:= $(patsubst -O2,-O1,$(CFLAGS))
endif

-O1 still generates "uninitialized variable" warnings but the code is a
lot saner to step through ... not perfect, but saner.  It's been a
workable compromise for a long time.  I don't recommend developing with
-O0, exactly because it disables some mighty valuable warnings.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Function proposal to find the type of a datum
Next
From: Kate F
Date:
Subject: Re: Function proposal to find the type of a datum