From owner-freebsd-hackers Sun Jul 29 10:23:57 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by hub.freebsd.org (Postfix) with ESMTP id 6875437B401 for ; Sun, 29 Jul 2001 10:23:51 -0700 (PDT) (envelope-from sheldonh@starjuice.net) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.31 #1) id 15QuJ8-000LNb-00 for hackers@FreeBSD.org; Sun, 29 Jul 2001 19:24:50 +0200 From: Sheldon Hearn To: hackers@FreeBSD.org Subject: Why objcopy --strip-debug instead of strip? Date: Sun, 29 Jul 2001 19:24:49 +0200 Message-ID: <82186.996427489@axl.seasidesoftware.co.za> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi folks, When the kernel is built as kernel.debug, why is it passed through objcopy --strip-debug before being installed, instead of being passed through strip? Background: I recently found that the Handbook instructions for "Debugging Loadable Modules Using GDB" is mostly useless for post-mortem crash dump analysis, because buildkernel doesn't build modules with debugging support, even when CONFIGARGS=-g. The attached patch (for the i386 only) fixes this so that, if kernel.debug is built, foo.ko.debug etc. are built. For each foo.ko.debug, we produce foo.ko with objcopy --strip-debug and install foo.ko. What I'm unsure of is why it's worth going to all this trouble. Why not simply build all the modules with debugging support compiled in (assuming debugging support was requested for the kernel), and strip them at install time (install -s)? Ciao, Sheldon. Index: /usr/src/sys/conf/Makefile.i386 =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.i386,v retrieving revision 1.240 diff -u -d -r1.240 Makefile.i386 --- /usr/src/sys/conf/Makefile.i386 2001/07/26 23:04:46 1.240 +++ /usr/src/sys/conf/Makefile.i386 2001/07/29 16:51:56 @@ -272,6 +272,9 @@ .if defined(MODULES_OVERRIDE) MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" .endif +.if defined(DEBUG) +MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}" +.endif modules: @mkdir -p ${.OBJDIR}/modules Index: /usr/src/sys/conf/kmod.mk =================================================================== RCS file: /home/ncvs/src/sys/conf/kmod.mk,v retrieving revision 1.104 diff -u -d -r1.104 kmod.mk --- /usr/src/sys/conf/kmod.mk 2001/07/18 09:59:55 1.104 +++ /usr/src/sys/conf/kmod.mk 2001/07/29 17:15:59 @@ -77,6 +77,7 @@ KMODLOAD?= /sbin/kldload KMODUNLOAD?= /sbin/kldunload +OBJCOPY?= objcopy TARGET_ARCH?= ${MACHINE_ARCH} @@ -131,7 +132,15 @@ PROG= ${KMOD}.ko .endif -${PROG}: ${KMOD}.kld +.if !defined(DEBUG) +FULLPROG= ${PROG} +.else +FULLPROG= ${PROG}.debug +${PROG}: ${FULLPROG} + ${OBJCOPY} --strip-debug ${FULLPROG} ${PROG} +.endif + +${FULLPROG}: ${KMOD}.kld ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld ${KMOD}.kld: ${OBJS} @@ -188,7 +197,7 @@ ${ECHO} ${.TARGET} "->" $$path ; \ ln -s $$path ${.TARGET} -CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o +CLEANFILES+= ${PROG} ${FULLPROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o .if !target(install) .if !target(beforeinstall) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message