diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 336d055..90e7269 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -18,6 +18,46 @@ aout .. .. + debug + bin + .. + boot + .. + lib + geom + .. + .. + libexec + .. + sbin + .. + usr + bin + .. + games + .. + lib + engines + .. + .. + lib32 + .. + libexec + .. + bsdinstall + .. + lpr + ru + .. + .. + sendmail + .. + sm.bin + .. + sbin + .. + .. + .. dtrace .. engines diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc index c40e9b8..5b11bb4 100644 --- a/gnu/usr.bin/gdb/Makefile.inc +++ b/gnu/usr.bin/gdb/Makefile.inc @@ -36,7 +36,7 @@ GDB_CROSS_DEBUGGER= .PATH: ${CNTRB_GDB}/gdb ${CNTRB_GDB}/gdb/cli ${CNTRB_GDB}/gdb/mi \ ${CNTRB_GDB}/gdb/signals ${CNTRB_GDB}/gdb/tui ${TARGET_SUBDIR} -CFLAGS+= -DHAVE_CONFIG_H -DRL_NO_COMPAT -DMI_OUT=1 -DTUI=1 +CFLAGS+= -DHAVE_CONFIG_H -DRL_NO_COMPAT -DMI_OUT=1 -DTUI=1 -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/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index faa117f..93f4295 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -383,6 +383,12 @@ When set, it also enforces the following options: .It .Va WITHOUT_GROFF .El +.It Va WITH_DEBUG_FILES +Set to strip debug info into a separate file for each executable binary +and shared library. The debug files will be placed in a subdirectory of +.Pa /usr/lib/debug +and are located automatically by +.Xr gdb 1 . .It Va WITHOUT_DICT .\" from FreeBSD: head/tools/build/options/WITHOUT_DICT 156932 2006-03-21 07:50:50Z ru Set to not build the Webster dictionary files. diff --git a/share/mk/bsd.crunchgen.mk b/share/mk/bsd.crunchgen.mk index 95f1aa3..a0d8d19 100644 --- a/share/mk/bsd.crunchgen.mk +++ b/share/mk/bsd.crunchgen.mk @@ -47,6 +47,9 @@ CRUNCH_GENERATE_LINKS?= yes CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h +# Don't try to extract debug info from ${PROG}. +.undef MK_DEBUG_FILES + # Program names and their aliases contribute hardlinks to 'rescue' executable, # except for those that get suppressed. .for D in $(CRUNCH_SRCDIRS) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index aa3567b..acb201a 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -43,6 +43,10 @@ CTFFLAGS+= -g STRIP?= -s .endif +.if defined(MK_DEBUG_FILES) +CFLAGS+= -g +.endif + .include # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries @@ -173,8 +177,8 @@ SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel .if target(beforelinking) ${SHLIB_NAME}: beforelinking .endif -.if defined(DEBUG_FLAGS) -${SHLIB_NAME}.debug: ${SOBJS} +.if defined(MK_DEBUG_FILES) +${SHLIB_NAME}.full: ${SOBJS} .else ${SHLIB_NAME}: ${SOBJS} .endif @@ -196,13 +200,13 @@ ${SHLIB_NAME}: ${SOBJS} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} .endif -.if defined(DEBUG_FLAGS) -${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols - ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \ - ${SHLIB_NAME}.debug ${.TARGET} +.if defined(MK_DEBUG_FILES) +${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}.debug - ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.debug ${.TARGET} +${SHLIB_NAME}.debug: ${SHLIB_NAME}.full + ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.full ${.TARGET} .endif .endif @@ -280,10 +284,16 @@ _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} \ - ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR} +.if defined(MK_DEBUG_FILES) +.if defined(SHLIBDIR) && ${SHLIBDIR:M/usr/local/*} == "" + -${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${NOBINMODE} \ + ${_INSTALLFLAGS} ${SHLIB_NAME}.debug \ + ${DESTDIR}${DEBUGDIR}${SHLIBDIR}/${SHLIB_NAME}.debug +.else + -${INSTALL} -d -o ${LIBOWN} -g ${LIBGRP} -m ${NOBINMODE} \ + ${_INSTALLFLAGS} ${SHLIB_NAME}.debug \ + ${DESTDIR}${SHLIBDIR} +.endif .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 78af8fb..cf83264 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 @@ -427,6 +432,7 @@ __DEFAULT_NO_OPTIONS = \ BSD_GREP \ CLANG_EXTRAS \ CTF \ + DEBUG_FILES \ HESIOD \ ICONV \ IDEA \ diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 950d381..8e4e2e4 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -22,14 +22,16 @@ CXXFLAGS+=${DEBUG_FLAGS} .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" CTFFLAGS+= -g .endif +.else +STRIP?= -s .endif -.if defined(CRUNCH_CFLAGS) -CFLAGS+=${CRUNCH_CFLAGS} +.if defined(MK_DEBUG_FLAGS) +CFLAGS+= -g .endif -.if !defined(DEBUG_FLAGS) -STRIP?= -s +.if defined(CRUNCH_CFLAGS) +CFLAGS+=${CRUNCH_CFLAGS} .endif .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") @@ -48,7 +50,11 @@ OBJS+= ${SRCS:N*.h:R:S/$/.o/g} .if target(beforelinking) ${PROG}: beforelinking .endif +.if defined(MK_DEBUG_FILES) +${PROG}.full: ${OBJS} +.else ${PROG}: ${OBJS} +.endif .if defined(PROG_CXX) ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .else @@ -77,7 +83,11 @@ OBJS= ${PROG}.o .if target(beforelinking) ${PROG}: beforelinking .endif +.if defined(MK_DEBUG_FILES) +${PROG}.full: ${OBJS} +.else ${PROG}: ${OBJS} +.endif .if defined(PROG_CXX) ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .else @@ -98,6 +108,18 @@ ${PROG}: ${OBJS} MAN= ${PROG}.1 MAN1= ${MAN} .endif + +PROGNAME?= ${PROG} + +.if defined(MK_DEBUG_FILES) +${PROG}: ${PROG}.full ${PROGNAME}.debug + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \ + ${PROG}.full ${.TARGET} || cp -f ${PROG}.full ${.TARGET} + +${PROGNAME}.debug: ${PROG}.full + ${OBJCOPY} --only-keep-debug ${PROG}.full ${.TARGET} || \ + touch ${.TARGET} +.endif .endif # defined(PROG) all: objwarn ${PROG} ${SCRIPTS} @@ -106,7 +128,10 @@ all: _manpages .endif .if defined(PROG) -CLEANFILES+= ${PROG} +CLEANFILES+= ${PROG} +.if defined(MK_DEBUG_FILES) +CLEANFILES+= ${PROG}.full ${PROGNAME}.debug +.endif .endif .if defined(OBJS) @@ -152,12 +177,16 @@ realinstall: _proginstall .ORDER: beforeinstall _proginstall _proginstall: .if defined(PROG) -.if defined(PROGNAME) ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} +.if defined(MK_DEBUG_FILES) +.if defined(BINDIR) && ${BINDIR:M/usr/local/*} == "" + -${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \ + ${PROGNAME}.debug ${DESTDIR}${DEBUGDIR}${BINDIR}/${PROGNAME}.debug .else - ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR} + -${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \ + ${PROGNAME}.debug ${DESTDIR}${BINDIR} +.endif .endif .endif .endif # !target(realinstall)