From owner-svn-src-head@freebsd.org Wed Mar 20 20:42:46 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3C541535856; Wed, 20 Mar 2019 20:42:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FCCC8100F; Wed, 20 Mar 2019 20:42:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 36843260B4; Wed, 20 Mar 2019 20:42:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2KKgjuP027418; Wed, 20 Mar 2019 20:42:45 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2KKgi4m027416; Wed, 20 Mar 2019 20:42:44 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201903202042.x2KKgi4m027416@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 20 Mar 2019 20:42:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345348 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 345348 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5FCCC8100F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2019 20:42:46 -0000 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 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}