On Thu, Apr 16, 2009 at 06:36:19PM +0100, Darren J Moffat wrote:
> James Carlson wrote:
>> Mike.Sullivan at sun.com writes:
>>> but it used to be that you weren't supposed to have DEBUG code make
>>> it lots slower, as that discourages people from running DEBUG kernels
>>> for normal use which does help. What 'lots' means these days I don't know,
>>> but while I'd probably not worry much about asserts I'd probably put
>>> things like
>>>     #ifdef DEBUG
>>>             /* spend minutes validating all my structures */
>>>     #endif
>
> There is certainly some of this in the ZFS code but....
>
>>> under another debug variables control that is not enabled by default.
>>
>> That's certainly what we do in other areas.  It's an important design
>> note that the "variables" here should not be compilation-time symbols
>> (i.e., no ifdef'd debug code) but instead be run-time tweaks; either
>> global variables that can be poked by 'mdb' or special debug commands.
>
> They are enabled by doing tweaks on zfs_flags.
>> One thing that's missing here is a translation of #define DEBUG into
>> #undef NDEBUG for user space programs.  I think that'd be a really
>> welcome addition to the system.
>
> Rather than tweaking Makefiles I do this in my environment by (ab)using 
> $COPTFLAG eg for userland:
>       export COPTFLAG="-g -DDEBUG"

I do that also when I need to debug Kerberos in userspace however
recently I noticed that this causes linking breakage in the onnv
workspace thus I opened this compiler bug:

6827339 link phase fails when objects compiled with -g

The workaround that Rod Evans suggested is also setting XFFLAG=''.

> Another thing I've always wanted to get around to doing for userland is to 
> have it all built with "-g" when we run a debug nightly.  There are 
> sometimes issues if you have "-g" set for all of userspace build.

Yeah, I've wanted this also since debugging krb sometimes requires
stepping through a number of libs.  I've been using a script, make_krb,
which can compile these libs with COPTFLAG="-g -DDEBUG" set.

I also use a shell script wrapper for calling dmake with various debug
options called dbgmake.  It's basically:

MAKE=${MAKE:-dmake}
# Keep libraries from having their stab section stripped (bug 5042640)
# which dbx needs to debug libs.
export STRIPSTABS_KEEP_STABS="1"
export STRIP='/usr/bin/true' # just to make sure no stripping occurs

# XXX the XFFLAG='' is a compiler bug work around
if [[ $PWD == *krb5* ]]
then
    # krb can use special debug KRB5_DEFS make env. var.
    $MAKE "$@" COPTFLAG='-g -DDEBUG' XFFLAG='' \
        COPTFLAG64='-g -DDEBUG' \
        sparc_C_PICFLAGS='-K PIC' \
        KRB5_DEFS='-DDEBUG -DKRB5_LOG_LVL=3'
else
    $MAKE "$@" COPTFLAG='-g -DDEBUG' COPTFLAG64='-g -DDEBUG' \
        sparc_C_PICFLAGS='-K PIC' XFFLAG='' 
fi

-- 
Will Fiveash
Sun Microsystems Inc.
http://opensolaris.org/os/project/kerberos/

Reply via email to