Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Enable split-debug files for kernels. Enabled by default wit...
details: https://anonhg.NetBSD.org/src/rev/552b846b434f
branches: trunk
changeset: 1029280:552b846b434f
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 29 22:22:12 2021 +0000
description:
Enable split-debug files for kernels. Enabled by default with MKDEBUG=yes.
diffstat:
build.sh | 5 +++--
distrib/sets/lists/debug/mi | 3 ++-
distrib/sets/sets.subr | 41 +++++++++++++++++++++++++++++++++++------
etc/Makefile | 22 ++++++++++++++++++++--
sys/conf/Makefile.kern.inc | 31 ++++++++++++++++++++++++-------
5 files changed, 84 insertions(+), 18 deletions(-)
diffs (249 lines):
diff -r 8ad7d33aa1c5 -r 552b846b434f build.sh
--- a/build.sh Wed Dec 29 18:13:43 2021 +0000
+++ b/build.sh Wed Dec 29 22:22:12 2021 +0000
@@ -1,5 +1,5 @@
#! /usr/bin/env sh
-# $NetBSD: build.sh,v 1.359 2021/10/04 21:02:40 andvar Exp $
+# $NetBSD: build.sh,v 1.360 2021/12/29 22:22:12 christos Exp $
#
# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -1974,7 +1974,7 @@
eval cat <<EOF ${makewrapout}
#! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from: \$NetBSD: build.sh,v 1.359 2021/10/04 21:02:40 andvar Exp $
+# Generated from: \$NetBSD: build.sh,v 1.360 2021/12/29 22:22:12 christos Exp $
# with these arguments: ${_args}
#
@@ -2111,6 +2111,7 @@
bomb "${toolprefix}config failed for ${kernelconf}"
make_in_dir "${kernelbuildpath}" depend
make_in_dir "${kernelbuildpath}" all
+ make_in_dir "${kernelbuildpath}" debuginstall
if [ "${runcmd}" != "echo" ]; then
statusmsg "Kernels built from ${kernelconf}:"
diff -r 8ad7d33aa1c5 -r 552b846b434f distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Wed Dec 29 18:13:43 2021 +0000
+++ b/distrib/sets/lists/debug/mi Wed Dec 29 22:22:12 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.369 2021/12/07 17:39:53 brad Exp $
+# $NetBSD: mi,v 1.370 2021/12/29 22:22:13 christos Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile
@@ -325,6 +325,7 @@
./usr/libdata/debug/bin/test.debug comp-util-debug debug
./usr/libdata/debug/libexec/lfs_cleanerd.debug comp-sysutil-debug debug
./usr/libdata/debug/netbsd comp-sysutil-debug debug,kernel_dir
+./usr/libdata/debug/netbsd-CONFIG.debug comp-sysutil-debug debug
./usr/libdata/debug/sbin/amrctl.debug comp-sysutil-debug debug
./usr/libdata/debug/sbin/apmlabel.debug comp-sysutil-debug debug
./usr/libdata/debug/sbin/atactl.debug comp-sysutil-debug debug
diff -r 8ad7d33aa1c5 -r 552b846b434f distrib/sets/sets.subr
--- a/distrib/sets/sets.subr Wed Dec 29 18:13:43 2021 +0000
+++ b/distrib/sets/sets.subr Wed Dec 29 22:22:12 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: sets.subr,v 1.197 2021/09/25 21:26:03 maya Exp $
+# $NetBSD: sets.subr,v 1.198 2021/12/29 22:22:13 christos Exp $
#
#
@@ -192,7 +192,7 @@
# In each file, a record consists of a path and a System Package name,
# separated by whitespace. E.g.,
#
-# # $NetBSD: sets.subr,v 1.197 2021/09/25 21:26:03 maya Exp $
+# # $NetBSD: sets.subr,v 1.198 2021/12/29 22:22:13 christos Exp $
# . base-sys-root [keyword[,...]]
# ./altroot base-sys-root
# ./bin base-sys-root
@@ -263,18 +263,33 @@
else
verbose=true
fi
+ local CONFIGS="$( list_kernel_configs )"
print_set_lists "$@" | \
${AWK} -v obsolete=${obsolete} '
function addkmod(line, fname, prefix, pat, patlen) {
if (substr(line, 1, patlen) != pat) {
- return;
+ return
}
for (d in kmodarchdirs) {
xd = prefix kmodarchdirs[d]
- xfile = xd substr(line, patlen + 1)
- tmp = xd substr(fname, patlen + 1)
- list[xfile] = tmp;
+ xline = xd substr(line, patlen + 1)
+ xfname = xd substr(fname, patlen + 1)
+ list[xline] = xfname
+ }
+ }
+ function adddebugkernel(line, fname, pat, patlen) {
+ if (substr(line, 1, patlen) != pat) {
+ return 0
}
+ split("'"${CONFIGS}"'", configs)
+ for (d in configs) {
+ xfname = fname
+ sub("CONFIG", configs[d], xfname)
+ xline = line;
+ sub("CONFIG", configs[d], xline)
+ list[xline] = xfname
+ }
+ return 1
}
BEGIN {
if (obsolete)
@@ -327,6 +342,10 @@
kmoddbpat = kmoddbprefix ENVIRON["MACHINE"]
l_kmoddbpat = length(kmoddbpat)
}
+ if ("debug" in wanted) {
+ debugkernelname = "./usr/libdata/debug/netbsd-CONFIG.debug"
+ l_debugkernelname = length(debugkernelname);
+ }
if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
if ("binutils" in wanted)
@@ -424,6 +443,8 @@
next
if (!show)
next
+ if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname))
+ next
list[$1] = $0
if (havekmod > 0) {
@@ -647,6 +668,14 @@
done | ${XARGS} ${SED} ${SUBST}
}
+
+list_kernel_configs()
+{
+ (cd ${NETBSDSRCDIR}/etc
+ MAKEFLAGS= \
+ ${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}')
+}
+
# arch_to_cpu mach
#
# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
diff -r 8ad7d33aa1c5 -r 552b846b434f etc/Makefile
--- a/etc/Makefile Wed Dec 29 18:13:43 2021 +0000
+++ b/etc/Makefile Wed Dec 29 22:22:12 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.455 2021/12/23 14:50:59 christos Exp $
+# $NetBSD: Makefile,v 1.456 2021/12/29 22:22:13 christos Exp $
# from: @(#)Makefile 8.7 (Berkeley) 5/25/95
# Environment variables without default values:
@@ -158,6 +158,7 @@
${MAKEDIRTARGET} ${NETBSDSRCDIR} include _DISTRIB=
${MAKEDIRTARGET} ${NETBSDSRCDIR} install _DISTRIB=
.endif # !INSTALL_DONE
+ ${MAKEDIRTARGET} . install-debugkernels
${MAKEDIRTARGET} . install-etc-files
. if ${MKX11} != "no"
${MAKEDIRTARGET} ${NETBSDSRCDIR}/external/mit/xorg distribution
@@ -596,7 +597,8 @@
${MAKE} -C ${KERNOBJDIR}/${configfile:C/.*\///} distclean
.endif
${MAKE} -C ${KERNOBJDIR}/${configfile:C/.*\///} depend && \
- ${MAKE} -C ${KERNOBJDIR}/${configfile:C/.*\///}
+ ${MAKE} -C ${KERNOBJDIR}/${configfile:C/.*\///} && \
+ ${MAKE} -C ${KERNOBJDIR}/${configfile:C/.*\///} debuginstall
.endfor # ALL_KERNELS # }
.endif # KERNELS_DONE # }
@@ -693,6 +695,22 @@
.endfor
.endfor # KERNEL_SETS EXTRA_KERNELS # }
+# install-debugkernels:
+# Create fake kernel debug files to satisfy the sets requirements
+# They will be later replaced with the real ones if we are building
+# kernels. This mess is needed because checkflist runs before the
+# kernels are built. It should really run before the sets are build.
+install-debugkernels:
+.if ${MKDEBUG:Uno} == "yes"
+. for k in ${ALL_KERNELS}
+install-debugkernels: ${DESTDIR}${DEBUGDIR}/netbsd-${k}.debug
+
+${DESTDIR}${DEBUGDIR}/netbsd-${k}.debug:
+ ${_MKTARGET_INSTALL}
+ touch ${.TARGET}
+. endfor
+.endif
+
# snap_md_post --
# Machine dependent distribution media operations.
# Overridden by etc.$MACHINE/Makefile.inc
diff -r 8ad7d33aa1c5 -r 552b846b434f sys/conf/Makefile.kern.inc
--- a/sys/conf/Makefile.kern.inc Wed Dec 29 18:13:43 2021 +0000
+++ b/sys/conf/Makefile.kern.inc Wed Dec 29 22:22:12 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.kern.inc,v 1.285 2021/12/20 20:33:20 christos Exp $
+# $NetBSD: Makefile.kern.inc,v 1.286 2021/12/29 22:22:13 christos Exp $
#
# This file contains common `MI' targets and definitions and it is included
# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -18,7 +18,7 @@
# all ports are expected to include bsd.own.mk for toolchain settings
# Default DEBUG to -g if kernel debug info is requested by MKDEBUGKERNEL=yes
-.if defined(MKDEBUGKERNEL) && ${MKDEBUGKERNEL} == "yes"
+.if ${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"
DEBUG?=-g
.endif
@@ -243,16 +243,29 @@
SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@
-SYSTEM_LD_TAIL_DEBUG?=&& \
- echo mv -f $@ $@.gdb && mv -f $@ $@.gdb && \
- echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb && \
- ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb && \
- chmod 755 $@ $@.gdb
+
+SYSTEM_LD_TAIL_DEBUG?=&& set -x &&\
+ mv -f $@ $@.gdb && \
+ ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_BUILD}.debug && \
+ ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
+ --add-gnu-debuglink=$@-${KERNEL_BUILD}.debug $@.gdb $@ && \
+ chmod 755 $@ $@.gdb $@-${KERNEL_BUILD}.debug
+
LINKFLAGS_NORMAL?= -S
STRIPFLAGS?= -g
DEBUG?=
.if !empty(DEBUG:M-g*)
+
+# XXX: KERNEL_DIR?
+debuginstall: install-kernel-debug
+.for k in ${KERNELS}
+install-kernel-debug: ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_BUILD}.debug
+
+${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_BUILD}.debug: ${k}-${KERNEL_BUILD}.debug
+ install -c -o root -g bin -m 444 ${.ALLSRC} ${.TARGET}
+.endfor
+
SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
LINKFLAGS+= ${LINKFLAGS_DEBUG}
EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
@@ -262,6 +275,10 @@
LINKFLAGS+= ${LINKFLAGS_NORMAL}
.endif
+.if !target(debuginstall)
+debuginstall:
+.endif
+
SYSTEM_LD_HEAD+= ${SYSTEM_LD_HEAD_EXTRA}
SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL}
SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL}
Home |
Main Index |
Thread Index |
Old Index