From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 13 22:08:48 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id ABB91BC8; Thu, 13 Dec 2012 22:08:48 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from aussmtpmrkps320.us.dell.com (aussmtpmrkps320.us.dell.com [143.166.224.254]) by mx1.freebsd.org (Postfix) with ESMTP id 66C488FC08; Thu, 13 Dec 2012 22:08:48 +0000 (UTC) X-Loopcount0: from 64.238.244.148 X-IronPort-AV: E=Sophos;i="4.84,276,1355119200"; d="scan'208";a="12491570" Message-ID: <50CA51AB.6060801@vangyzen.net> Date: Thu, 13 Dec 2012 16:07:39 -0600 From: Eric van Gyzen User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:14.0) Gecko/20120822 Thunderbird/14.0 MIME-Version: 1.0 To: Ed Maste Subject: Re: [PATCH] Shared library debug .symbols files References: <20121213160847.GA78448@sandvine.com> In-Reply-To: <20121213160847.GA78448@sandvine.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2012 22:08:48 -0000 On 12/13/2012 10:08, Ed Maste wrote: > I've been working generating userland debugging symbols, with the goal > that we'll build them for each release. The user could install them > along with the system, or later on when needed for debugging. The > symbols files will also be useful for profiling and tools such as > Valgrind, without needing to build and install world first. > > This patch enables .symbols files for shared libraries when DEBUG_FLAGS > is set. Future changes will be needed to address static libraries and > base system binaries, and the release build bits. > > This is a different approach to the patches Mark Johnston posted to > -hackers about two years ago. I've followed the example of kmod.mk in > generating a .debug file which is split into the two components with > objcopy at build time. (Mark's patch overloaded strip to do it at > install time.) > > Note that I used --strip-all and not --strip-debug, as the latter > results in duplication in the symtab and strtab between the shared lib > and its .symbols file. Excellent. I've wanted this for a while, and I like your approach. I have one comment below; otherwise, the patch looks fine (not that I have any authority on the subject...). > diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk > index 2c96df1..6a1b476 100644 > --- a/share/mk/bsd.lib.mk > +++ b/share/mk/bsd.lib.mk > @@ -34,14 +34,13 @@ NO_WERROR= > .endif > > .if defined(DEBUG_FLAGS) > +OBJCOPY?= objcopy > CFLAGS+= ${DEBUG_FLAGS} > > .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" > CTFFLAGS+= -g > .endif > -.endif > - > -.if !defined(DEBUG_FLAGS) > +.else > STRIP?= -s > .endif > > @@ -173,14 +172,17 @@ SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel > .endif > > .if target(beforelinking) > -${SHLIB_NAME}: ${SOBJS} beforelinking > +${SHLIB_NAME}: beforelinking > +.endif > +.if defined(DEBUG_FLAGS) > +${SHLIB_NAME}.debug: ${SOBJS} > .else > ${SHLIB_NAME}: ${SOBJS} > .endif > @${ECHO} building shared library ${SHLIB_NAME} > - @rm -f ${.TARGET} ${SHLIB_LINK} > + @rm -f ${.SHLIB_NAME} ${SHLIB_LINK} dot-SHLIB_NAME? I'm not aware of this magic. > .if defined(SHLIB_LINK) > - @ln -fs ${.TARGET} ${SHLIB_LINK} > + @ln -fs ${.SHLIB_NAME} ${SHLIB_LINK} > .endif > .if !defined(NM) > @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ > @@ -194,6 +196,15 @@ ${SHLIB_NAME}: ${SOBJS} > .if ${MK_CTF} != "no" > ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} > .endif > + > +.if defined(DEBUG_FLAGS) > +${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols > + ${OBJCOPY} --strip-all --add-gnu-debuglink=${SHLIB_NAME}.symbols\ > + ${SHLIB_NAME}.debug ${.TARGET} > + > +${SHLIB_NAME}.symbols: > + ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.debug ${.TARGET} > +.endif > .endif > > .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" > @@ -270,6 +281,11 @@ _libinstall: > ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ > ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ > ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} > +.if defined(DEBUG_FLAGS) > + ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ > + ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ > + ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR} > +.endif > .if defined(SHLIB_LINK) > # ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building > # and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >