Date: Wed, 20 Mar 2019 20:42:44 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345348 - head/sys/conf Message-ID: <201903202042.x2KKgi4m027416@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Wed Mar 20 20:42:44 2019 New Revision: 345348 URL: https://svnweb.freebsd.org/changeset/base/345348 Log: Use -fdebug-prefix-map to map auto-generated kernel build paths. The kernel build uses symlinks to make MD #includes like <machine/pcpu.h> work. Debug info ends up referencing these symlinks in a relative path, so debuggers generally don't know how to find the corresponding headers. Address this by using -fdebug-prefix-map to map relative paths through the symlinks to their absolute paths in the source tree. This is consistent with how regular source file paths are defined in the kernel's debug info. Also map the current directory to an absolute path to the object directory. This gives debuggers a chance to find auto-generated files like vnode_if.c if the object directory is available. Reviewed by: emaste, jhb (previous version) MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19633 Modified: head/sys/conf/kern.post.mk head/sys/conf/kmod.mk Modified: head/sys/conf/kern.post.mk ============================================================================== --- head/sys/conf/kern.post.mk Wed Mar 20 20:36:46 2019 (r345347) +++ head/sys/conf/kern.post.mk Wed Mar 20 20:42:44 2019 (r345348) @@ -328,6 +328,11 @@ ${__obj}: ${OBJS_DEPEND_GUESS.${__obj}} .depend: .PRECIOUS ${SRCS} +.if ${COMPILER_TYPE} == "clang" || \ + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60000) +_MAP_DEBUG_PREFIX= yes +.endif + _ILINKS= machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+= ${MACHINE_CPUARCH} @@ -337,11 +342,24 @@ _ILINKS+= x86 .endif # Ensure that the link exists without depending on it when it exists. +# Ensure that debug info references the path in the source tree. .for _link in ${_ILINKS} .if !exists(${.OBJDIR}/${_link}) ${SRCS} ${CLEAN:M*.o}: ${_link} .endif +.if defined(_MAP_DEBUG_PREFIX) +.if ${_link} == "machine" +CFLAGS+= -fdebug-prefix-map=./machine=${SYSDIR}/${MACHINE}/include +.else +CFLAGS+= -fdebug-prefix-map=./${_link}=${SYSDIR}/${_link}/include +.endif +.endif .endfor + +.if defined(_MAP_DEBUG_PREFIX) +# Ensure that DWARF info contains a full path for auto-generated headers. +CFLAGS+= -fdebug-prefix-map=.=${.OBJDIR} +.endif ${_ILINKS}: @case ${.TARGET} in \ Modified: head/sys/conf/kmod.mk ============================================================================== --- head/sys/conf/kmod.mk Wed Mar 20 20:36:46 2019 (r345347) +++ head/sys/conf/kmod.mk Wed Mar 20 20:42:44 2019 (r345348) @@ -267,6 +267,11 @@ ${FULLPROG}: ${OBJS} ${OBJCOPY} --strip-debug ${.TARGET} .endif +.if ${COMPILER_TYPE} == "clang" || \ + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60000) +_MAP_DEBUG_PREFIX= yes +.endif + _ILINKS=machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+=${MACHINE_CPUARCH} @@ -283,11 +288,24 @@ beforebuild: ${_ILINKS} # Ensure that the links exist without depending on it when it exists which # causes all the modules to be rebuilt when the directory pointed to changes. +# Ensure that debug info references the path in the source tree. .for _link in ${_ILINKS} .if !exists(${.OBJDIR}/${_link}) OBJS_DEPEND_GUESS+= ${_link} .endif +.if defined(_MAP_DEBUG_PREFIX) +.if ${_link} == "machine" +CFLAGS+= -fdebug-prefix-map=./machine=${SYSDIR}/${MACHINE}/include +.else +CFLAGS+= -fdebug-prefix-map=./${_link}=${SYSDIR}/${_link}/include +.endif +.endif .endfor + +.if defined(_MAP_DEBUG_PREFIX) +# Ensure that DWARF info contains a full path for auto-generated headers. +CFLAGS+= -fdebug-prefix-map=.=${.OBJDIR} +.endif .NOPATH: ${_ILINKS}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903202042.x2KKgi4m027416>