diff options
author | John Baldwin <jhb@FreeBSD.org> | 2017-04-25 18:08:56 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2017-04-25 18:08:56 +0000 |
commit | 73ad3fb5360333765a2c1fe0c14ea810b75fab11 (patch) | |
tree | 6367caa21b1b2dd012998cf55e2afbc5e36c74b8 /usr.sbin/crashinfo | |
parent | b3ac6549cae91b85f1a05812c4f7770830a16a38 (diff) | |
download | src-73ad3fb5360333765a2c1fe0c14ea810b75fab11.tar.gz src-73ad3fb5360333765a2c1fe0c14ea810b75fab11.zip |
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
Notes
Notes:
svn path=/head/; revision=317416
Diffstat (limited to 'usr.sbin/crashinfo')
-rwxr-xr-x | usr.sbin/crashinfo/crashinfo.sh | 31 |
1 files changed, 23 insertions, 8 deletions
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 |