From owner-svn-src-all@freebsd.org Tue Apr 25 18:08:58 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19A54D50A01; Tue, 25 Apr 2017 18:08:58 +0000 (UTC) (envelope-from jhb@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 mx1.freebsd.org (Postfix) with ESMTPS id E84251F02; Tue, 25 Apr 2017 18:08:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3PI8uVP007253; Tue, 25 Apr 2017 18:08:56 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3PI8uAj007246; Tue, 25 Apr 2017 18:08:56 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201704251808.v3PI8uAj007246@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 25 Apr 2017 18:08:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317416 - in head: gnu/usr.bin/gdb share/mk tools/build/mk tools/build/options usr.sbin/crashinfo X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Apr 2017 18:08:58 -0000 Author: jhb Date: Tue Apr 25 18:08:56 2017 New Revision: 317416 URL: https://svnweb.freebsd.org/changeset/base/317416 Log: Add a new GDB_LIBEXEC option to install gdb and kgdb to /usr/libexec. When this option is enabled, only gdb and kgdb are installed to /usr/libexec for use by crashinfo(8). Other bits of GDB such as gdbserver and gdbtui are not installed. For this option to be effective, GDB must be enabled. Rework r317094 to re-enable GDB on all platforms but enable GDB_LIBEXEC on platforms for which the GDB in ports is a superset of functionality. Reviewed by: emaste, kib Suggested by: kib Relnotes: yes Differential Revision: https://reviews.freebsd.org/D10449 Added: head/tools/build/options/WITHOUT_GDB_LIBEXEC (contents, props changed) head/tools/build/options/WITH_GDB_LIBEXEC (contents, props changed) Modified: head/gnu/usr.bin/gdb/Makefile head/gnu/usr.bin/gdb/Makefile.inc head/share/mk/src.opts.mk head/tools/build/mk/OptionalObsoleteFiles.inc head/usr.sbin/crashinfo/crashinfo.sh Modified: head/gnu/usr.bin/gdb/Makefile ============================================================================== --- head/gnu/usr.bin/gdb/Makefile Tue Apr 25 18:07:48 2017 (r317415) +++ head/gnu/usr.bin/gdb/Makefile Tue Apr 25 18:08:56 2017 (r317416) @@ -1,9 +1,15 @@ # $FreeBSD$ -SUBDIR= libgdb gdb gdbtui kgdb +.include + +SUBDIR= libgdb gdb kgdb + +.if ${MK_GDB_LIBEXEC} == "no" +SUBDIR+= gdbtui .if exists(${.CURDIR}/gdbserver/reg-${MACHINE_CPUARCH}.c) SUBDIR+=gdbserver .endif +.endif .include Modified: head/gnu/usr.bin/gdb/Makefile.inc ============================================================================== --- head/gnu/usr.bin/gdb/Makefile.inc Tue Apr 25 18:07:48 2017 (r317415) +++ head/gnu/usr.bin/gdb/Makefile.inc Tue Apr 25 18:08:56 2017 (r317416) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + VERSION= "6.1.1 [FreeBSD]" VENDOR= marcel @@ -53,6 +55,9 @@ GENSRCS+= nm.h tm.h CFLAGS+= -DCROSS_DEBUGGER -I${BMAKE_ROOT:H:H} GDB_SUFFIX= -${TARGET_ARCH} MAN= +.elif ${MK_GDB_LIBEXEC} != "no" +BINDIR?= /usr/libexec +MAN= .endif .include "${TARGET_SUBDIR}/Makefile" Modified: head/share/mk/src.opts.mk ============================================================================== --- head/share/mk/src.opts.mk Tue Apr 25 18:07:48 2017 (r317415) +++ head/share/mk/src.opts.mk Tue Apr 25 18:08:56 2017 (r317416) @@ -97,6 +97,7 @@ __DEFAULT_YES_OPTIONS = \ FTP \ GAMES \ GCOV \ + GDB \ GNU_DIFF \ GNU_GREP \ GPIO \ @@ -267,9 +268,9 @@ BROKEN_OPTIONS+=LLDB # does not yet contain kernel support for arm, and sparc64 kernel support # has not been tested. .if ${__T:Marm*} != "" || ${__T} == "sparc64" -__DEFAULT_YES_OPTIONS+=GDB +__DEFAULT_NO_OPTIONS+=GDB_LIBEXEC .else -__DEFAULT_NO_OPTIONS+=GDB +__DEFAULT_YES_OPTIONS+=GDB_LIBEXEC .endif # Only doing soft float API stuff on armv6 .if ${__T} != "armv6" Modified: head/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- head/tools/build/mk/OptionalObsoleteFiles.inc Tue Apr 25 18:07:48 2017 (r317415) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Tue Apr 25 18:08:56 2017 (r317416) @@ -2431,7 +2431,7 @@ OLD_FILES+=usr/bin/gcov OLD_FILES+=usr/share/man/man1/gcov.1.gz .endif -.if ${MK_GDB} == no +.if ${MK_GDB} == no || ${MK_GDB_LIBEXEC} == yes OLD_FILES+=usr/bin/gdb OLD_FILES+=usr/bin/gdbserver OLD_FILES+=usr/bin/gdbtui @@ -2441,6 +2441,11 @@ OLD_FILES+=usr/share/man/man1/gdbserver. OLD_FILES+=usr/share/man/man1/kgdb.1.gz .endif +.if ${MK_GDB} == no || ${MK_GDB_LIBEXEC} == no +OLD_FILES+=usr/libexec/gdb +OLD_FILES+=usr/libexec/kgdb +.endif + .if ${MK_GPIO} == no OLD_FILES+=usr/include/libgpio.h OLD_FILES+=usr/lib/libgpio.a Added: head/tools/build/options/WITHOUT_GDB_LIBEXEC ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITHOUT_GDB_LIBEXEC Tue Apr 25 18:08:56 2017 (r317416) @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to install +.Xr gdb 1 +into +.Pa /usr/bin . Added: head/tools/build/options/WITH_GDB_LIBEXEC ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_GDB_LIBEXEC Tue Apr 25 18:08:56 2017 (r317416) @@ -0,0 +1,10 @@ +.\" $FreeBSD$ +Set to install +.Xr gdb 1 +into +.Pa /usr/libexec . +This permits +.Xr gdb 1 +to be used as a fallback for +.Xr crashinfo 8 +if a newer version is not installed. Modified: head/usr.sbin/crashinfo/crashinfo.sh ============================================================================== --- head/usr.sbin/crashinfo/crashinfo.sh Tue Apr 25 18:07:48 2017 (r317415) +++ head/usr.sbin/crashinfo/crashinfo.sh Tue Apr 25 18:08:56 2017 (r317416) @@ -35,6 +35,19 @@ usage() exit 1 } +# Find a gdb binary to use and save the value in GDB. +find_gdb() +{ + local binary + + for binary in /usr/local/bin/gdb /usr/libexec/gdb /usr/bin/gdb; do + if [ -x ${binary} ]; then + GDB=${binary} + return + fi + done +} + # Run a single gdb command against a kernel file in batch mode. # The kernel file is specified as the first argument and the command # is given in the remaining arguments. @@ -44,10 +57,10 @@ gdb_command() k=$1 ; shift - if [ -x /usr/local/bin/gdb ]; then - /usr/local/bin/gdb -batch -ex "$@" $k + if [ ${GDB} = /usr/local/bin/gdb ]; then + ${GDB} -batch -ex "$@" $k else - echo -e "$@" | /usr/bin/gdb -x /dev/stdin -batch $k + echo -e "$@" | ${GDB} -x /dev/stdin -batch $k fi } @@ -140,6 +153,12 @@ INFO=$CRASHDIR/info.$DUMPNR FILE=$CRASHDIR/core.txt.$DUMPNR HOSTNAME=`hostname` +find_gdb +if [ -z "$GDB" ]; then + echo "Unable to find a kernel debugger." + exit 1 +fi + if [ ! -e $VMCORE ]; then echo "$VMCORE not found" exit 1 @@ -189,11 +208,7 @@ file=`mktemp /tmp/crashinfo.XXXXXX` if [ $? -eq 0 ]; then echo "bt" >> $file echo "quit" >> $file - if [ -x /usr/local/bin/kgdb ]; then - /usr/local/bin/kgdb $KERNEL $VMCORE < $file - else - kgdb $KERNEL $VMCORE < $file - fi + ${GDB%gdb}kgdb $KERNEL $VMCORE < $file rm -f $file echo fi