summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/gdb/Makefile8
-rw-r--r--gnu/usr.bin/gdb/Makefile.inc5
-rw-r--r--share/mk/src.opts.mk5
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc7
-rw-r--r--tools/build/options/WITHOUT_GDB_LIBEXEC5
-rw-r--r--tools/build/options/WITH_GDB_LIBEXEC10
-rwxr-xr-xusr.sbin/crashinfo/crashinfo.sh31
7 files changed, 59 insertions, 12 deletions
diff --git a/gnu/usr.bin/gdb/Makefile b/gnu/usr.bin/gdb/Makefile
index 35ee5fb22a8d..7598a196300a 100644
--- a/gnu/usr.bin/gdb/Makefile
+++ b/gnu/usr.bin/gdb/Makefile
@@ -1,9 +1,15 @@
# $FreeBSD$
-SUBDIR= libgdb gdb gdbtui kgdb
+.include <src.opts.mk>
+
+SUBDIR= libgdb gdb kgdb
+
+.if ${MK_GDB_LIBEXEC} == "no"
+SUBDIR+= gdbtui
.if exists(${.CURDIR}/gdbserver/reg-${MACHINE_CPUARCH}.c)
SUBDIR+=gdbserver
.endif
+.endif
.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc
index 6e022fcdc952..11452179cd83 100644
--- a/gnu/usr.bin/gdb/Makefile.inc
+++ b/gnu/usr.bin/gdb/Makefile.inc
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <src.opts.mk>
+
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"
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index d42730c3bbb8..70c6f83f3f49 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -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"
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 271b1b5094c5..7e3392b70339 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -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.1.gz
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
diff --git a/tools/build/options/WITHOUT_GDB_LIBEXEC b/tools/build/options/WITHOUT_GDB_LIBEXEC
new file mode 100644
index 000000000000..4fbe30cb846e
--- /dev/null
+++ b/tools/build/options/WITHOUT_GDB_LIBEXEC
@@ -0,0 +1,5 @@
+.\" $FreeBSD$
+Set to install
+.Xr gdb 1
+into
+.Pa /usr/bin .
diff --git a/tools/build/options/WITH_GDB_LIBEXEC b/tools/build/options/WITH_GDB_LIBEXEC
new file mode 100644
index 000000000000..7ba0bf1d9508
--- /dev/null
+++ b/tools/build/options/WITH_GDB_LIBEXEC
@@ -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.
diff --git a/usr.sbin/crashinfo/crashinfo.sh b/usr.sbin/crashinfo/crashinfo.sh
index 24bd180d21cd..2326630cdef2 100755
--- a/usr.sbin/crashinfo/crashinfo.sh
+++ b/usr.sbin/crashinfo/crashinfo.sh
@@ -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