diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 83d8de034caf..a7738aaf6f78 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -1,899 +1,901 @@ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin .. include private bsddialog .. bsdstat .. event1 .. gmock internal custom .. .. .. gtest internal custom .. .. .. sqlite3 .. ucl .. zstd .. .. .. lib clang 17 include cuda_wrappers bits .. .. fuzzer .. hlsl .. openmp_wrappers .. orc_rt .. ppc_wrappers .. profile .. sanitizer .. xray .. .. lib freebsd .. .. share .. .. .. compat .. dtrace .. engines-3 .. flua .. i18n .. libxo encoder .. .. ossl-modules .. .. libdata gcc .. ldscripts .. pkgconfig .. .. libexec bsdconfig 020.docsinstall include .. .. 030.packages include .. .. 040.password include .. .. 050.diskmgmt include .. .. 070.usermgmt include .. .. 080.console include .. .. 090.timezone include .. .. 110.mouse include .. .. 120.networking include .. .. 130.security include .. .. 140.startup include .. .. 150.ttys include .. .. dot include .. .. include .. includes include .. .. .. bsdinstall .. dwatch .. fwget .. hyperv .. + kgdb + .. lpr ru .. .. sendmail .. sm.bin .. zfs .. .. local .. obj nochange .. sbin .. share atf tags=package=tests .. bhyve kbdlayout .. .. bsdconfig media .. networking .. packages .. password .. startup .. timezone .. usermgmt .. .. calendar .. certs trusted tags=package=caroot .. untrusted tags=package=caroot .. .. dict .. doc IPv6 .. atf tags=package=tests .. kyua tags=package=tests .. legal .. llvm clang .. .. ncurses .. ntp drivers icons .. scripts .. .. hints .. icons .. pic .. scripts .. .. pjdfstest .. .. dtrace .. examples BSD_daemon .. FreeBSD_version .. IPv6 .. bhyve .. bootforth .. bsdconfig .. csh .. diskless .. dma .. drivers .. dwatch .. etc defaults .. .. find_interface .. flua .. hast .. hostapd .. indent .. ipfilter .. ipfw .. jails .. kld cdev module .. test .. .. dyn_sysctl .. firmware fwconsumer .. fwimage .. .. khelp .. syscall module .. test .. .. .. kyua tags=package=tests .. libusb20 .. libvgl .. mdoc .. netgraph .. perfmon .. pf .. ppi .. ppp .. printing .. scsi_target .. ses getencstat .. sesd .. setencstat .. setobjstat .. srcs .. .. smbfs print .. .. sound .. sunrpc dir .. msg .. sort .. .. tcsh .. uefisign .. ypldap .. .. firmware .. flua .. games fortune .. .. i18n csmapper APPLE .. AST .. BIG5 .. CNS .. CP .. EBCDIC .. GB .. GEORGIAN .. ISO-8859 .. ISO646 .. JIS .. KAZAKH .. KOI .. KS .. MISC .. TCVN .. .. esdb APPLE .. AST .. BIG5 .. CP .. DEC .. EBCDIC .. EUC .. GB .. GEORGIAN .. ISO-2022 .. ISO-8859 .. ISO646 .. KAZAKH .. KOI .. MISC .. TCVN .. UTF .. .. .. keys pkg revoked tags=package=runtime .. trusted tags=package=runtime .. .. .. kyua tags=package=tests misc tags=package=tests .. store tags=package=tests .. .. locale .. man man1 .. man2 .. man3 .. man3lua .. man4 aarch64 .. amd64 .. arm .. i386 .. powerpc .. .. man5 .. man6 .. man7 .. man8 amd64 .. i386 .. powerpc .. .. man9 .. .. misc fonts .. .. mk .. nls C .. af_ZA.ISO8859-1 .. af_ZA.ISO8859-15 .. af_ZA.UTF-8 .. am_ET.UTF-8 .. be_BY.CP1131 .. be_BY.CP1251 .. be_BY.ISO8859-5 .. be_BY.UTF-8 .. bg_BG.CP1251 .. bg_BG.UTF-8 .. ca_ES.ISO8859-1 .. ca_ES.ISO8859-15 .. ca_ES.UTF-8 .. cs_CZ.ISO8859-2 .. cs_CZ.UTF-8 .. da_DK.ISO8859-1 .. da_DK.ISO8859-15 .. da_DK.UTF-8 .. de_AT.ISO8859-1 .. de_AT.ISO8859-15 .. de_AT.UTF-8 .. de_CH.ISO8859-1 .. de_CH.ISO8859-15 .. de_CH.UTF-8 .. de_DE.ISO8859-1 .. de_DE.ISO8859-15 .. de_DE.UTF-8 .. el_GR.ISO8859-7 .. el_GR.UTF-8 .. en_AU.ISO8859-1 .. en_AU.ISO8859-15 .. en_AU.US-ASCII .. en_AU.UTF-8 .. en_CA.ISO8859-1 .. en_CA.ISO8859-15 .. en_CA.US-ASCII .. en_CA.UTF-8 .. en_GB.ISO8859-1 .. en_GB.ISO8859-15 .. en_GB.US-ASCII .. en_GB.UTF-8 .. en_IE.UTF-8 .. en_NZ.ISO8859-1 .. en_NZ.ISO8859-15 .. en_NZ.US-ASCII .. en_NZ.UTF-8 .. en_US.ISO8859-1 .. en_US.ISO8859-15 .. en_US.UTF-8 .. es_ES.ISO8859-1 .. es_ES.ISO8859-15 .. es_ES.UTF-8 .. et_EE.ISO8859-15 .. et_EE.UTF-8 .. fi_FI.ISO8859-1 .. fi_FI.ISO8859-15 .. fi_FI.UTF-8 .. fr_BE.ISO8859-1 .. fr_BE.ISO8859-15 .. fr_BE.UTF-8 .. fr_CA.ISO8859-1 .. fr_CA.ISO8859-15 .. fr_CA.UTF-8 .. fr_CH.ISO8859-1 .. fr_CH.ISO8859-15 .. fr_CH.UTF-8 .. fr_FR.ISO8859-1 .. fr_FR.ISO8859-15 .. fr_FR.UTF-8 .. gl_ES.ISO8859-1 .. he_IL.UTF-8 .. hi_IN.ISCII-DEV .. hr_HR.ISO8859-2 .. hr_HR.UTF-8 .. hu_HU.ISO8859-2 .. hu_HU.UTF-8 .. hy_AM.ARMSCII-8 .. hy_AM.UTF-8 .. is_IS.ISO8859-1 .. is_IS.ISO8859-15 .. is_IS.UTF-8 .. it_CH.ISO8859-1 .. it_CH.ISO8859-15 .. it_CH.UTF-8 .. it_IT.ISO8859-1 .. it_IT.ISO8859-15 .. it_IT.UTF-8 .. ja_JP.SJIS .. ja_JP.UTF-8 .. ja_JP.eucJP .. kk_KZ.PT154 .. kk_KZ.UTF-8 .. ko_KR.CP949 .. ko_KR.UTF-8 .. ko_KR.eucKR .. lt_LT.ISO8859-13 .. lt_LT.UTF-8 .. lv_LV.ISO8859-13 .. lv_LV.UTF-8 .. mn_MN.UTF-8 .. nl_BE.ISO8859-1 .. nl_BE.ISO8859-15 .. nl_BE.UTF-8 .. nl_NL.ISO8859-1 .. nl_NL.ISO8859-15 .. nl_NL.UTF-8 .. no_NO.ISO8859-1 .. no_NO.ISO8859-15 .. no_NO.UTF-8 .. pl_PL.ISO8859-2 .. pl_PL.UTF-8 .. pt_BR.ISO8859-1 .. pt_BR.UTF-8 .. pt_PT.ISO8859-1 .. pt_PT.ISO8859-15 .. pt_PT.UTF-8 .. ro_RO.ISO8859-2 .. ro_RO.UTF-8 .. ru_RU.CP1251 .. ru_RU.CP866 .. ru_RU.ISO8859-5 .. ru_RU.KOI8-R .. ru_RU.UTF-8 .. sk_SK.ISO8859-2 .. sk_SK.UTF-8 .. sl_SI.ISO8859-2 .. sl_SI.UTF-8 .. sr_YU.ISO8859-2 .. sr_YU.ISO8859-5 .. sr_YU.UTF-8 .. sv_SE.ISO8859-1 .. sv_SE.ISO8859-15 .. sv_SE.UTF-8 .. tr_TR.ISO8859-9 .. tr_TR.UTF-8 .. uk_UA.ISO8859-5 .. uk_UA.KOI8-U .. uk_UA.UTF-8 .. zh_CN.GB18030 .. zh_CN.GB2312 .. zh_CN.GBK .. zh_CN.UTF-8 .. zh_CN.eucCN .. zh_HK.UTF-8 .. zh_TW.UTF-8 .. .. openssl man man1 .. man3 .. man5 .. man7 .. .. .. security .. sendmail .. skel .. snmp defs .. mibs .. .. syscons fonts .. keymaps .. scrnmaps .. .. tabset .. vi catalog .. .. vt fonts .. keymaps .. .. zfs compatibility.d .. .. zoneinfo Africa .. America Argentina .. Indiana .. Kentucky .. North_Dakota .. .. Antarctica .. Arctic .. Asia .. Atlantic .. Australia .. Brazil .. Canada .. Chile .. Etc .. Europe .. Indian .. Mexico .. Pacific .. US .. .. .. src nochange .. .. diff --git a/libexec/Makefile b/libexec/Makefile index 795250dddfdb..bd1571edcfe4 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -1,125 +1,126 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 .include .include SUBDIR= ${_atf} \ ${_atrun} \ ${_blacklistd-helper} \ ${_comsat} \ ${_dma} \ flua \ getty \ ${_hyperv} \ + kgdb \ ${_mail.local} \ ${_makewhatis.local} \ ${_mknetid} \ ${_phttpget} \ ${_pppoed} \ rc \ revnetgroup \ ${_rlogind} \ rpc.rquotad \ rpc.rstatd \ rpc.rusersd \ rpc.rwalld \ rpc.sprayd \ ${_rshd} \ ${_rtld-elf} \ save-entropy \ ${_smrsh} \ ${_tests} \ ${_tftp-proxy} \ ulog-helper \ ${_ypxfr} .if ${MK_AT} != "no" _atrun= atrun .endif .if ${MK_BLACKLIST} != "no" _blacklistd-helper+= blacklistd-helper .endif .if ${MK_BOOTPD} != "no" SUBDIR+= bootpd .endif .if ${MK_FINGER} != "no" SUBDIR+= fingerd .endif .if ${MK_FREEBSD_UPDATE} != "no" _phttpget= phttpget .endif .if ${MK_FTP} != "no" SUBDIR+= ftpd .endif .if ${MK_MAIL} != "no" _comsat= comsat .endif .if ${MK_DMAGENT} != "no" _dma= dma .endif .if ${MK_HYPERV} != "no" _hyperv+= hyperv .endif .if ${MK_NIS} != "no" _mknetid= mknetid _ypxfr= ypxfr .endif .if ${MK_NETGRAPH} != "no" _pppoed= pppoed .endif .if ${MK_PF} != "no" _tftp-proxy= tftp-proxy .endif .if !defined(NO_PIC) && !defined(NO_RTLD) _rtld-elf= rtld-elf .for LIBCOMPAT libcompat in ${_ALL_LIBCOMPATS_libcompats} SUBDIR.${MK_LIB${LIBCOMPAT}}+= rtld-elf${libcompat} .endfor .endif .if ${MK_RBOOTD} != "no" SUBDIR+= rbootd .endif .if ${MK_SENDMAIL} != "no" _mail.local= mail.local _smrsh= smrsh .endif .if ${MK_MAN_UTILS} != "no" _makewhatis.local= makewhatis.local .endif .if ${MK_TALK} != "no" SUBDIR+= talkd .endif .if ${MK_TCP_WRAPPERS} != "no" SUBDIR+= tcpd .endif .if ${MK_TFTP} != "no" SUBDIR+= tftpd .endif .if ${MK_TESTS} != "no" _atf= atf _tests= tests .endif .include .include diff --git a/libexec/kgdb/Makefile b/libexec/kgdb/Makefile new file mode 100644 index 000000000000..f6b255ab4f60 --- /dev/null +++ b/libexec/kgdb/Makefile @@ -0,0 +1,5 @@ +FILESDIR?= /usr/libexec/kgdb + +FILES= acttrace.py + +.include diff --git a/libexec/kgdb/acttrace.py b/libexec/kgdb/acttrace.py new file mode 100644 index 000000000000..3229ff708de1 --- /dev/null +++ b/libexec/kgdb/acttrace.py @@ -0,0 +1,63 @@ +#- +# Copyright (c) 2022 The FreeBSD Foundation +# +# This software was developed by Mark Johnston under sponsorship from the +# FreeBSD Foundation. +# + +import gdb + + +def symval(name): + return gdb.lookup_global_symbol(name).value() + + +def tid_to_gdb_thread(tid): + for thread in gdb.inferiors()[0].threads(): + if thread.ptid[2] == tid: + return thread + else: + return None + + +def all_pcpus(): + mp_maxid = symval("mp_maxid") + cpuid_to_pcpu = symval("cpuid_to_pcpu") + + cpu = 0 + while cpu <= mp_maxid: + pcpu = cpuid_to_pcpu[cpu] + if pcpu: + yield pcpu + cpu = cpu + 1 + + +class acttrace(gdb.Command): + def __init__(self): + super(acttrace, self).__init__("acttrace", gdb.COMMAND_USER) + + def invoke(self, arg, from_tty): + # Save the current thread so that we can switch back after. + curthread = gdb.selected_thread() + + for pcpu in all_pcpus(): + td = pcpu['pc_curthread'] + tid = td['td_tid'] + + gdb_thread = tid_to_gdb_thread(tid) + if gdb_thread is None: + print("failed to find GDB thread with TID {}".format(tid)) + else: + gdb_thread.switch() + + p = td['td_proc'] + print("Tracing command {} pid {} tid {} (CPU {})".format( + p['p_comm'], p['p_pid'], td['td_tid'], pcpu['pc_cpuid'])) + gdb.execute("bt") + print() + + curthread.switch() + + +# Registers the command with gdb, doesn't do anything. +acttrace() diff --git a/usr.sbin/crashinfo/crashinfo.sh b/usr.sbin/crashinfo/crashinfo.sh index 9a3d26020654..3bb1e1456462 100755 --- a/usr.sbin/crashinfo/crashinfo.sh +++ b/usr.sbin/crashinfo/crashinfo.sh @@ -1,345 +1,347 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-3-Clause # # Copyright (c) 2008 Yahoo!, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the author nor the names of any co-contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # usage() { echo "usage: crashinfo [-b] [-d crashdir] [-n dumpnr]" \ "[-k kernel] [core]" exit 1 } # Remove an uncompressed copy of a dump cleanup() { [ -e $VMCORE ] && rm -f $VMCORE } # 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. gdb_command() { local k k=$1 ; shift ${GDB} -batch -ex "$@" $k } find_kernel() { local ivers k kvers ivers=$(awk ' /Version String/ { print nextline=1 next } nextline==1 { if ($0 ~ "^ [A-Za-z ]+: ") { nextline=0 } else { print } }' $INFO) # Look for a matching kernel version, handling possible truncation # of the version string recovered from the dump. for k in `sysctl -n kern.bootfile` $(ls -t /boot/*/kernel); do kvers=$(gdb_command $k 'printf " Version String: %s", version' | \ awk "{line=line\$0\"\n\"} END{print substr(line,1,${#ivers})}" \ 2>/dev/null) if [ "$ivers" = "$kvers" ]; then KERNEL=$k break fi done } BATCH=false CRASHDIR=/var/crash DUMPNR= KERNEL= while getopts "bd:n:k:" opt; do case "$opt" in b) BATCH=true ;; d) CRASHDIR=$OPTARG ;; n) DUMPNR=$OPTARG ;; k) KERNEL=$OPTARG ;; \?) usage ;; esac done shift $((OPTIND - 1)) if [ $# -eq 1 ]; then if [ -n "$DUMPNR" ]; then echo "-n and an explicit vmcore are mutually exclusive" usage fi # Figure out the crash directory and number from the vmcore name. CRASHDIR=`dirname $1` DUMPNR=$(expr $(basename $1) : 'vmcore\.\([0-9]*\)') if [ -z "$DUMPNR" ]; then echo "Unable to determine dump number from vmcore file $1." exit 1 fi elif [ $# -gt 1 ]; then usage else # If we don't have an explicit dump number, operate on the most # recent dump. if [ -z "$DUMPNR" ]; then if ! [ -r $CRASHDIR/bounds ]; then echo "No crash dumps in $CRASHDIR." exit 1 fi next=`cat $CRASHDIR/bounds` if [ -z "$next" ] || [ "$next" -eq 0 ]; then echo "No crash dumps in $CRASHDIR." exit 1 fi DUMPNR=$(($next - 1)) fi fi VMCORE=$CRASHDIR/vmcore.$DUMPNR INFO=$CRASHDIR/info.$DUMPNR FILE=$CRASHDIR/core.txt.$DUMPNR HOSTNAME=`hostname` if $BATCH; then echo "Writing crash summary to $FILE." exec > $FILE 2>&1 fi GDB=/usr/local/bin/gdb if [ ! -x "$GDB" ]; then echo "Unable to find a kernel debugger." echo "Please install the devel/gdb port or gdb package." exit 1 fi if [ ! -e $VMCORE ]; then if [ -e $VMCORE.gz ]; then trap cleanup EXIT HUP INT QUIT TERM gzcat $VMCORE.gz > $VMCORE elif [ -e $VMCORE.zst ]; then trap cleanup EXIT HUP INT QUIT TERM zstdcat $VMCORE.zst > $VMCORE else echo "$VMCORE not found" exit 1 fi fi if [ ! -e $INFO ]; then echo "$INFO not found" exit 1 fi # If the user didn't specify a kernel, then try to find one. if [ -z "$KERNEL" ]; then find_kernel if [ -z "$KERNEL" ]; then echo "Unable to find matching kernel for $VMCORE" exit 1 fi elif [ ! -e $KERNEL ]; then echo "$KERNEL not found" exit 1 fi umask 077 # Simulate uname ostype=$(gdb_command $KERNEL 'printf "%s", ostype') osrelease=$(gdb_command $KERNEL 'printf "%s", osrelease') version=$(gdb_command $KERNEL 'printf "%s", version' | tr '\t\n' ' ') machine=$(gdb_command $KERNEL 'printf "%s", machine') if ! $BATCH; then echo "Writing crash summary to $FILE." exec > $FILE 2>&1 fi echo "$HOSTNAME dumped core - see $VMCORE" echo date echo echo "$ostype $HOSTNAME $osrelease $version $machine" echo sed -ne '/^ Panic String: /{s//panic: /;p;}' $INFO echo -# XXX: /bin/sh on 7.0+ is broken so we can't simply pipe the commands to -# kgdb via stdin and have to use a temporary file instead. file=`mktemp /tmp/crashinfo.XXXXXX` if [ $? -eq 0 ]; then + scriptdir=/usr/libexec/kgdb + echo "bt -full" >> $file + echo "source ${scriptdir}/acttrace.py" >> $file + echo "acttrace" >> $file echo "quit" >> $file - ${GDB%gdb}kgdb $KERNEL $VMCORE < $file + ${GDB%gdb}kgdb -q $KERNEL $VMCORE < $file rm -f $file echo fi echo echo "------------------------------------------------------------------------" echo "ps -axlww" echo ps -M $VMCORE -N $KERNEL -axlww echo echo "------------------------------------------------------------------------" echo "vmstat -s" echo vmstat -M $VMCORE -N $KERNEL -s echo echo "------------------------------------------------------------------------" echo "vmstat -m" echo vmstat -M $VMCORE -N $KERNEL -m echo echo "------------------------------------------------------------------------" echo "vmstat -z" echo vmstat -M $VMCORE -N $KERNEL -z echo echo "------------------------------------------------------------------------" echo "vmstat -i" echo vmstat -M $VMCORE -N $KERNEL -i echo echo "------------------------------------------------------------------------" echo "pstat -T" echo pstat -M $VMCORE -N $KERNEL -T echo echo "------------------------------------------------------------------------" echo "pstat -s" echo pstat -M $VMCORE -N $KERNEL -s echo echo "------------------------------------------------------------------------" echo "iostat" echo iostat -M $VMCORE -N $KERNEL echo echo "------------------------------------------------------------------------" echo "ipcs -a" echo ipcs -C $VMCORE -N $KERNEL -a echo echo "------------------------------------------------------------------------" echo "ipcs -T" echo ipcs -C $VMCORE -N $KERNEL -T echo # XXX: This doesn't actually work in 5.x+ if false; then echo "------------------------------------------------------------------------" echo "w -dn" echo w -M $VMCORE -N $KERNEL -dn echo fi echo "------------------------------------------------------------------------" echo "netstat -s" echo netstat -M $VMCORE -N $KERNEL -s echo echo "------------------------------------------------------------------------" echo "netstat -m" echo netstat -M $VMCORE -N $KERNEL -m echo echo "------------------------------------------------------------------------" echo "netstat -anA" echo netstat -M $VMCORE -N $KERNEL -anA echo echo "------------------------------------------------------------------------" echo "netstat -aL" echo netstat -M $VMCORE -N $KERNEL -aL echo echo "------------------------------------------------------------------------" echo "fstat" echo fstat -M $VMCORE -N $KERNEL echo echo "------------------------------------------------------------------------" echo "dmesg" echo dmesg -a -M $VMCORE -N $KERNEL echo echo "------------------------------------------------------------------------" echo "kernel config" echo config -x $KERNEL echo echo "------------------------------------------------------------------------" echo "ddb capture buffer" echo ddb capture -M $VMCORE -N $KERNEL print