[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: [PATCH] Add WITH_DEBUG_FILES knob to enable separate debug files
From:       Ed Maste <emaste () freebsd ! org>
Date:       2013-03-27 0:56:54
Message-ID: CAPyFy2AY02mPQ7txbwhkAHj6JQjtw5p35tORC4aFE1moK-+ZKw () mail ! gmail ! com
[Download RAW message or body]

On 22 December 2012 11:46, Ed Maste <emaste@freebsd.org> wrote:
> When this knob is set standalone debug files for shared objects are
> built and installed in /usr/lib/debug/<so pathname>.debug.  GDB
> searches this path for debug data.

I'm picking this up again - here is a new version of the patch, which
should address the base/ports issue and other problems.  Here's what
it does:

    - Add WITH_DEBUG_FILES src.conf knob to control standalone debug file
      generation, instead of using standalone files whenever DEBUG_FLAGS is set.

    - Switch debug file extension from .symbols to .debug, for consistency with
      other users of this feature.

    - Store debug files under /usr/lib/debug for base system components, and in
      a .debug subdirectory for other share/mk consumers.

    - Switch gdb to use the default standalone debug directory of
/usr/lib/debug.

Also available at
http://people.freebsd.org/~emaste/patches/shlib-debug-symbols.diff.
Changes to bsd.prog.mk will come after.

["shlib-debug-symbols.diff" (application/octet-stream)]

diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist
index 299389f..6e2664c 100644
--- a/etc/mtree/BSD.usr.dist
+++ b/etc/mtree/BSD.usr.dist
@@ -18,6 +18,22 @@
             aout
             ..
         ..
+        debug
+            boot
+            ..
+            lib
+                geom
+                ..
+            ..
+            usr
+                lib
+                    engines
+                    ..
+                ..
+                lib32
+                ..
+            ..
+        ..
         dtrace
         ..
         engines
diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc
index c40e9b8..ae0a1ce 100644
--- a/gnu/usr.bin/gdb/Makefile.inc
+++ b/gnu/usr.bin/gdb/Makefile.inc
@@ -37,6 +37,7 @@ GDB_CROSS_DEBUGGER=
 	${CNTRB_GDB}/gdb/signals ${CNTRB_GDB}/gdb/tui ${TARGET_SUBDIR}
 
 CFLAGS+= -DHAVE_CONFIG_H -DRL_NO_COMPAT -DMI_OUT=1 -DTUI=1
+CFLAGS+= -DDEBUGDIR=\"/usr/lib/debug\"
 CFLAGS+= -I.
 CFLAGS+= -I${TARGET_SUBDIR}
 CFLAGS+= -I${BMAKE_BU}/libbfd -I${BMAKE_BU}/libbfd/${TARGET_CPUARCH}
diff --git a/gnu/usr.bin/gdb/arch/amd64/config.h b/gnu/usr.bin/gdb/arch/amd64/config.h
index ac81c54..674f818 100644
--- a/gnu/usr.bin/gdb/arch/amd64/config.h
+++ b/gnu/usr.bin/gdb/arch/amd64/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_i386_arch
 
diff --git a/gnu/usr.bin/gdb/arch/arm/config.h b/gnu/usr.bin/gdb/arch/arm/config.h
index e1b128c..b2481f8 100644
--- a/gnu/usr.bin/gdb/arch/arm/config.h
+++ b/gnu/usr.bin/gdb/arch/arm/config.h
@@ -451,9 +451,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_arm_arch
 
diff --git a/gnu/usr.bin/gdb/arch/i386/config.h b/gnu/usr.bin/gdb/arch/i386/config.h
index f21da4c..e849e0a 100644
--- a/gnu/usr.bin/gdb/arch/i386/config.h
+++ b/gnu/usr.bin/gdb/arch/i386/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_i386_arch
 
diff --git a/gnu/usr.bin/gdb/arch/ia64/config.h b/gnu/usr.bin/gdb/arch/ia64/config.h
index 5faa96b..4cc29f9 100644
--- a/gnu/usr.bin/gdb/arch/ia64/config.h
+++ b/gnu/usr.bin/gdb/arch/ia64/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_ia64_arch
 
diff --git a/gnu/usr.bin/gdb/arch/mips/config.h b/gnu/usr.bin/gdb/arch/mips/config.h
index 41a6731..2b375a6 100644
--- a/gnu/usr.bin/gdb/arch/mips/config.h
+++ b/gnu/usr.bin/gdb/arch/mips/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_mips_arch
 
diff --git a/gnu/usr.bin/gdb/arch/powerpc/config.h b/gnu/usr.bin/gdb/arch/powerpc/config.h
index f169fad..37416a7 100644
--- a/gnu/usr.bin/gdb/arch/powerpc/config.h
+++ b/gnu/usr.bin/gdb/arch/powerpc/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_rs6000_arch
 
diff --git a/gnu/usr.bin/gdb/arch/powerpc64/config.h b/gnu/usr.bin/gdb/arch/powerpc64/config.h
index d8b9b6d..58843fb 100644
--- a/gnu/usr.bin/gdb/arch/powerpc64/config.h
+++ b/gnu/usr.bin/gdb/arch/powerpc64/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_rs6000_arch
 
diff --git a/gnu/usr.bin/gdb/arch/sparc64/config.h b/gnu/usr.bin/gdb/arch/sparc64/config.h
index 5527a79..974e426 100644
--- a/gnu/usr.bin/gdb/arch/sparc64/config.h
+++ b/gnu/usr.bin/gdb/arch/sparc64/config.h
@@ -439,9 +439,6 @@
 /* Name of this package.  */
 #define PACKAGE "gdb"
 
-/* Global directory for separate debug files.  */
-#define DEBUGDIR "/usr/local/lib/debug"
-
 /* Define to BFD's default architecture.  */
 #define DEFAULT_BFD_ARCH bfd_sparc_arch
 
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 3664210..be893cd 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -43,6 +43,11 @@ CTFFLAGS+= -g
 STRIP?=	-s
 .endif
 
+.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g)
+CFLAGS+= -g
+CTFFLAGS+= -g
+.endif
+
 .include <bsd.libnames.mk>
 
 # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
@@ -114,8 +119,17 @@ PO_FLAG=-pg
 all: objwarn
 
 .if defined(SHLIB_NAME)
-.if defined(DEBUG_FLAGS)
-SHLIB_NAME_FULL=${SHLIB_NAME}.debug
+.if ${MK_DEBUG_FILES} != "no"
+SHLIB_NAME_FULL=${SHLIB_NAME}.full
+# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
+.if ${SHLIBDIR} == "/boot" ||\
+    ${SHLIBDIR:C/\/lib(\/.*)?$/\/lib/} == "/lib" ||\
+    ${SHLIBDIR:C/\/usr\/lib(32)?(\/.*)?/\/usr\/lib/} == "/usr/lib"
+DEBUGFILEDIR=${DEBUGDIR}${SHLIBDIR}
+.else
+DEBUGFILEDIR=${SHLIBDIR}/.debug
+DEBUGFILEMKDIR=yes
+.endif
 .else
 SHLIB_NAME_FULL=${SHLIB_NAME}
 .endif
@@ -201,12 +215,12 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
 	${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
 .endif
 
-.if defined(DEBUG_FLAGS)
-${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols
-	${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \
+.if ${MK_DEBUG_FILES} != "no"
+${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
+	${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \
 	    ${SHLIB_NAME_FULL} ${.TARGET}
 
-${SHLIB_NAME}.symbols: ${SHLIB_NAME_FULL}
+${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL}
 	${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}
 .endif
 .endif
@@ -285,10 +299,13 @@ _libinstall:
 	${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
 	    ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
-.if defined(DEBUG_FLAGS)
+.if ${MK_DEBUG_FILES} != "no"
+.if ${DEBUGFILEMKDIR} == "yes"
+	mkdir -p ${DESTDIR}${DEBUGFILEDIR}
+.endif
 	${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} \
-	    ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR}
+	    ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}
 .endif
 .if defined(SHLIB_LINK)
 # ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building
diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
index f1a15d6..6a14b8a 100644
--- a/share/mk/bsd.own.mk
+++ b/share/mk/bsd.own.mk
@@ -43,6 +43,9 @@
 # LIBMODE	Library mode. [${NOBINMODE}]
 #
 #
+# DEBUGDIR	Base path for standalone debug files. [/usr/lib/debug]
+#
+#
 # KMODDIR	Base path for loadable kernel modules
 #		(see kld(4)). [/boot/kernel]
 #
@@ -147,6 +150,8 @@ LIBOWN?=	${BINOWN}
 LIBGRP?=	${BINGRP}
 LIBMODE?=	${NOBINMODE}
 
+DEBUGDIR?=	/usr/lib/debug
+
 
 # Share files
 SHAREDIR?=	/usr/share
@@ -366,6 +371,7 @@ __DEFAULT_NO_OPTIONS = \
     BSD_GREP \
     CLANG_EXTRAS \
     CTF \
+    DEBUG_FILES \
     GPL_DTC \
     HESIOD \
     ICONV \
diff --git a/tools/build/options/WITH_DEBUG_FILES b/tools/build/options/WITH_DEBUG_FILES
new file mode 100644
index 0000000..a641c6f
--- /dev/null
+++ b/tools/build/options/WITH_DEBUG_FILES
@@ -0,0 +1,6 @@
+.\" $FreeBSD$
+Set to strip debug info into a separate file for each shared library.
+The debug files will be placed in a subdirectory of
+.Pa /usr/lib/debug
+and are located automatically by
+.Xr gdb 1 .


_______________________________________________
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"

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic