Home | History | Annotate | only in /src/usr.bin/kdump
History log of /src/usr.bin/kdump
RevisionDateAuthorComments
 1.37 20-Apr-2024  rillig {usr.,}{s,}bin: replace LINT_SUPPORTED with the standard NOLINT

While here, re-enable lint in those cases where lint was skipped due to
a bug in interpreting abstract types, which was fixed in cgram.y 1.469
from 2023-08-02.
 1.36 03-Jun-2023  lukem bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER

Provide a single variable
CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
CLANG_NO_ADDR_OF_PACKED_MEMBER
CC_NO_ADDR_OF_PACKED_MEMBER
GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.35 22-Aug-2021  rillig usr.bin: enable lint checks for most programs in /usr/bin

Previously, lint was only activated for the libraries, but not for the
kernel or userland programs. Activate lint for the programs in /usr/bin
for now, more will follow later.

This only affects builds that set MKLINT=yes.
 1.34 07-Sep-2020  mrg apply GCC_NO_ADDR_OF_PACKED_MEMBER
 1.33 02-Apr-2020  kamil Add ioctlprint - descriptive ioctl value printer

ioctlprint(1) is embedded in the kdump(1) program.
 1.32 23-Jan-2016  christos branches: 1.32.16;
Define _KERNTYPES for things that need it.
 1.31 26-Sep-2015  christos Add dtrace ioctls
 1.30 21-Sep-2011  christos Symbolic printing of some known MISC records.
 1.29 14-Apr-2009  lukem Enable WARNS=4 by default for usr.bin, except for:
awk bdes checknr compile_et error gss hxtool kgetcred kinit
klist ldd less lex locale login m4 man menuc mk_cmds
mklocale msgc openssl rpcgen rpcinfo sdiff spell ssh
string2key telnet tn3270 verify_krb5_conf xlint
 1.28 28-May-2007  tls branches: 1.28.22;
Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
FORTIFY_SOURCE feature of libssp, thus checking the size of arguments to
various string and memory copy and set functions (as well as a few system
calls and other miscellany) where known at function entry. RedHat has
evidently built all "core system packages" with this option for some time.

This option should be used at the top of Makefiles (or Makefile.inc where
this is used for subdirectories) but after any setting of LIB.

This is only useful for userland code, and cannot be used in libc or in
any code which includes the libc internals, because it overrides certain
libc functions with macros. Some effort has been made to make USE_FORT=yes
work correctly for a full-system build by having the bsd.sys.mk logic
disable the feature where it should not be used (libc, libssp iteself,
the kernel) but no attempt has been made to build the entire system with
USE_FORT and doing so will doubtless expose numerous bugs and misfeatures.

Adjust the system build so that all programs and libraries that are setuid,
directly handle network data (including serial comm data), perform
authentication, or appear likely to have (or have a history of having)
data-driven bugs (e.g. file(1)) are built with USE_FORT=yes by default,
with the exception of libc, which cannot use USE_FORT and thus uses
only USE_SSP by default. Tested on i386 with no ill results; USE_FORT=no
per-directory or in a system build will disable if desired.
 1.27 08-Oct-2006  peter WFORMAT is no more...
 1.26 16-Jul-2005  christos WARNS=3
 1.25 10-Jul-2004  tron Add prefix "${PROG}-" to filename of automatically created list of
ioctl names. This makes sure that each program is built with its own
copy even if object directories are not used. This avoids build
failures when two or more make jobs are used in parallel.
 1.24 16-Nov-2003  manu Re-add the static root conditionnal that was removed by mistake.
 1.23 19-Sep-2003  christos Print siginfo_t information when available.
 1.22 15-Nov-2002  manu Now properly display Mach traps
 1.21 19-Sep-2002  lukem use NETBSDSRCDIR as appropriate
 1.20 18-Sep-2002  lha remove extra $ from previous commit
 1.19 18-Sep-2002  lukem makefile delint. use NETBSDSRCDIR as appropriate
 1.18 27-Aug-2002  lukem Implement MKDYNAMICROOT, which currently defaults to "no", but will
be changed in the future to "yes".

If MKDYNAMICROOT == "no", there is no change from existing behaviour
of a static /bin and /sbin (and a few programs in elsewhere).

If MKDYNAMICROOT == "yes", the following changes occur:
in <bsd.own.mk>:
SHLIBDIR?= /lib
SHLINKDIR?= /lib
in various Makefiles, the following entry is DISABLED.
LDSTATIC?=-static
This results in all programs (except those "standalone" programs built
in sys/arch/*/stand) are linked dynamically, the shared linker is moved
from /usr/libexec to /lib (with a compat symlink), and the shared
libraries used by /bin and /sbin programs are moved from /usr/lib to
/lib (with compat symlinks).
 1.17 14-Nov-2000  jdolecek back out previous change - this needs to be discussed first at least
 1.16 13-Nov-2000  jdolecek don't link these static; if shared libraries are hosed, these utilities would
surely not save the situation, not help to recover from it
 1.15 11-Oct-2000  is More format string cleanup by sommerfeld.
 1.14 10-Apr-2000  jdolecek branches: 1.14.4;
put setemul(), ectx_* & appropriate structures to separate file, to make it
more easily sharable with ktruss(1)
 1.13 12-Jul-1999  mrg - build with obj dirs.
- use .PATH not broken links
- share the make fragment to build "ioctl.c"
- general clean up, RCSID, etc.

this is all happy now AFAICT.
 1.12 04-Oct-1998  veego branches: 1.12.2;
Fix the include problem of <compat/linux/arch/xxx/linux_syscall.h>.
 1.11 02-Mar-1998  cgd allow LDSTATIC definition to be overridden by bsd.own.mk/mk.conf
 1.10 24-Oct-1997  lukem use CPPFLAGS instead of CFLAGS
 1.9 01-Aug-1997  mikel branches: 1.9.2;
minor cleanup
 1.8 21-Jul-1997  phil Add input files to dependency list for ioctl.c build.
 1.7 08-May-1997  gwr Back out the .PATH.c changes. The .depend problem (and others)
will be fixed using the new .NOPATH make feature instead.
 1.6 06-May-1997  gwr Use .PATH.c: ...
 1.5 09-Jan-1997  tls RCS ID police
 1.4 06-Dec-1994  deraadt Link these statically to make shared library debugging easier
 1.3 06-Oct-1994  mycroft Add RCS ids.
 1.2 18-Jun-1994  mycroft Pass the file names in to mkioctl, to help cross-compilation.
 1.1 11-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 11-May-1994  cgd updated kdump
 1.9.2.1 08-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.12.2.2 19-Oct-2000  he Apply patch (requested by he):
Back out part of previous (the 1.5ism Makefile.ioctl-c).
 1.12.2.1 19-Oct-2000  he Pull up revision 1.15 (via patch, requested by he):
Format string cleanup.
 1.14.4.1 18-Oct-2000  tv Pullup usr.bin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.28.22.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.32.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.40 01-Apr-2024  riastradh elftoolchain: Be consistent about which ELF header files we use.

1. For tools that use elftoolchain: always use elftoolchain's
elfdefinitions.h. Don't even think about looking at the host's
sys/exec_elf.h, which makes no sense and should never happen.

(ELF tools that don't use elftoolchain, like m68k-elf2coff,
continue to use nbincludes/sys/exec_elf.h. But no more nbincludes
hacks in elftoolchain.)

2. For kernel components (solaris, zfs, dtrace): always use
sys/exec_elf.h, even in Solaris components via sys/elf.h.
elfdefinitions.h is not wired up in the kernel build at all.

3. For most userland components that involve libelf: use
elfdefinitions.h via libelf header files (libelf.h, gelf.h).

libdtrace in particular requires _all_ R_* reloc type definitions,
but sys/exec_elf.h brings in only the _current machine's_ R_*
reloc type definitions. (While here: Use uintptr_t instead of
Elf_Addr for pointer-to-integer cast, since Elf_Addr is MD and
provided only by sys/exec_elf.h, not by elfdefinitions.h.)

And most userland components using libelf don't rely on any
properties of the current machine from sys/exec_elf.h, so they can
use libelf's elfdefinition.h.

Exceptions:

- dtrace drti.c relies on link.h -> link_elf.h -> sys/exec_elf.h,
but it also relies on sys/dtrace.h -> sys/elf.h ->
elfdefinitions.h like other userland components using sys/elf.h.

- kdump-ioctl.c uses sys/exec_elf.h directly and sys/dtrace.h ->
sys/elf.h -> elfdefinitions like other userland components using
sys/elf.h.

- t_ptrace_wait.c (via t_ptrace_core_wait.h) uses libelf to parse
core files, but relies on sys/exec_elf.h for struct
netbsd_elfcore_procinfo.

None of these exceptions needs all R_* reloc type definitions, so
as a workaround, we can just suppress libelf's elfdefinitions.h by
defining _SYS_ELFDEFINITIONS_H_ and use sys/exec_elf.h in these
exceptions.

And undo the whole BUILTIN_ELF_HEADERS mistake. This was:

- half bogus workarounds for missing build_install dependencies in
tools/Makefile, which are no longer missing now, and
- half futile attempt to use src/sys/sys/exec_elf.h via nbincludes in
tools involving libelf instead of libelf's elfdefinitions.h, which
collides.

Longer-term, we may wish to unify sys/exec_elf.h and libelf's
elfdefinitions.h, so we don't have to play these games.

But at least now the games are limited to three .c files (one of
which is generated by Makefile.ioctl-c), rather than haphazardly
applied tree-wide by monstrous kludges in widely used .h files with
broken hackarounds to get the tools build lurching to completion.
 1.39 12-Nov-2022  mrg updates for libdrm 2.4.114.

unfortunately, the i915 ioctls are no longer handled by kdump/ktruss
as the new one conflicts with base. this needs a clean build in these
dirs (and rescue). the radeon ioctls have been enabled instead.
 1.38 29-Sep-2018  rmind NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.
 1.37 12-Jun-2018  christos branches: 1.37.2;
remove extra quotes.
 1.36 12-Jun-2018  christos - instead of hard-coding the include paths in mkioctls, pass them in
from the Makefile so that they are consistent.
- do more sed so that destination paths are not hard-coded inside #include
statements.
 1.35 28-May-2018  chs merge a new version of the CDDL dtrace and ZFS code.
this changes the upstream vendor from OpenSolaris to FreeBSD,
and this version is based on FreeBSD svn r315983.

in addition to the 10 years of improvements from upstream,
this version also has these NetBSD-specific enhancements:
- dtrace FBT probes can now be placed in kernel modules.
- ZFS now supports mmap().
 1.34 05-Nov-2017  christos branches: 1.34.2;
- fix "obsolete" skipping to handle obsolete entries that contain other
variables
- skip files particular to other xserver versions than ours.

XXX: How does this build in the build farm?
 1.33 18-Aug-2016  mrg don't hide _DEV_IC_BT8XX_H_ inside DTRACE.
 1.32 01-Apr-2016  knakahara ' != " so make the condition actually work. (same as r1.30)
 1.31 06-Feb-2016  joerg METEORGSIGNAL and METEORSFMT overlap with dtrace, prefer the latter.
 1.30 02-Nov-2015  joerg ' != " so make the condition actually work.
 1.29 26-Sep-2015  christos Add dtrace ioctls
 1.28 07-Feb-2015  christos Add QXL, re-enable I915
 1.27 07-Feb-2015  martin Drop i915, it still causes duplicate case statements
(DRM_IOCTL_QXL_UPDATE_AREA == DRM_IOCTL_I915_BATCHBUFFER)
 1.26 06-Feb-2015  christos Extend the list of the headers processed to generate symbolic ioctls to
the X sets, and include the DRM ioctls. Unfortunately the DRM ioctls for
different cards overlap, so until I write some code to merge them, only
enable one (currently the i915).
 1.25 06-Apr-2013  uebayasi * Don't re-generate kdump-ioctl.c during install.
* Don't expand hundreds of *.h paths into a variable and command-line in !=.
Lazily handle it the glob instead.
 1.24 04-Apr-2013  dsl Extract a base list of .h files from the set lists instead of looking
at the current contents of ${DESTDIR}.
Ignore missing files and also depend on the set lists themselves.
Should stop the build breaking here if there are extra files in DESTDIR (etc).
NB: The order of the .h files matters somewhat. Probably works by luck.
 1.23 25-Oct-2008  apb branches: 1.23.4; 1.23.20; 1.23.26;
Pass SED=${TOOL_SED:Q} in the environment to scripts run during the build.
 1.22 19-Oct-2008  apb Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
 1.21 23-Mar-2008  christos little cleanups.
 1.20 17-Feb-2008  bouyer Install xenio.h and xenio3.h in /usr/include/xen, for the benefit
of xentools3.

XXX ignore those in Makefile.ioctl-c, they don't compile properly outside
of the Xen context and the ioctls from xenio.h conflicts with
soundcard.h
 1.19 16-Feb-2008  matt Add ${PROG}-ioctl.c to DPSRCS
 1.18 27-Aug-2006  christos branches: 1.18.2; 1.18.4; 1.18.8;
pick up ioctls from other devices too.
 1.17 02-Jun-2006  christos PR/33627: Keiichi Shima: typo in Makefile.ioctl-c in kdump directory
s/RW/WR/
 1.16 10-Jul-2004  tron branches: 1.16.6;
Add prefix "${PROG}-" to filename of automatically created list of
ioctl names. This makes sure that each program is built with its own
copy even if object directories are not used. This avoids build
failures when two or more make jobs are used in parallel.
 1.15 07-Jul-2004  tron Don't scan include files in "includes" target because they might not be
in the destination directory yet.
 1.14 23-Apr-2004  hannken Don't invoke the egrep for cleandir and obj targets. Needed for build.sh.
Use ".if !make()" instead of ".if !target()".
 1.13 23-Apr-2004  hannken Undo last commit -- doesn't work.
 1.12 23-Apr-2004  hannken Don't invoke the egrep for cleandir and obj targets. Needed for build.sh.
 1.11 22-Apr-2004  christos Instead of pussy-footing around and grabbing a few of the ioctl's here and
there randomly, grab all the ioctls from the include files.
Read the XXX's in mkioctls about problems with our header files.
 1.10 21-Oct-2003  lukem Rework how MAKEVERBOSE operates:

* Don't bother prefixing commands with a line of ${_MKCMD}\
and instead rely upon "make -s". This is less intrusive on
all the Makefiles than the former. Idea from David Laight.

* Rename the variables use to print messages. The scheme now is:
_MKMSG_FOO Run _MKMSG 'foo'
_MKTARGET_FOO Run _MKMSG_FOO ${.TARGET}
From discussion with Alistair Crooks.
 1.9 19-Oct-2003  lukem support MAKEVERBOSE and use ${HOST_SH}
 1.8 27-Aug-2003  thorpej * Make it a little easier to add new "ioctl defns are in these files".
* Add the ability to decode the cryptodev ioctls.
 1.7 18-Apr-2003  christos Don't invoke the grep for cleandir and obj targets. Suggested by
Juergen Hannken-Illjes
 1.6 13-Apr-2003  christos PR/21117: Robert Elz: Makefile-ioctl.c mishandles dependencies
 1.5 19-Sep-2002  lukem use NETBSDSRCDIR as appropriate
 1.4 25-Sep-2001  mycroft Quotes around ${CC}...
 1.3 23-Sep-2001  jdolecek set CC and DESTDIR for mkioctls accordingly
patch by Chris Jepeway via tech-userlevel.
 1.2 27-Jul-2000  mrg mark the installed ioctl.h & ioctl_compat.h PRECIOUS; if mkioctls fails, don't delete them!
 1.1 12-Jul-1999  mrg - build with obj dirs.
- use .PATH not broken links
- share the make fragment to build "ioctl.c"
- general clean up, RCSID, etc.

this is all happy now AFAICT.
 1.16.6.1 19-Jun-2006  chap Sync with head.
 1.18.8.1 23-Mar-2008  matt sync with HEAD
 1.18.4.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.18.2.1 23-Mar-2008  jdc Pull up revisions (requested by bouyer in ticket #1087):
src/distrib/sets/lists/comp/md.i386 1.104
src/sys/arch/i386/Makefile 1.33
src/sys/arch/xen/include/Makefile 1.3
src/usr.bin/kdump/Makefile.ioctl-c 1.20

Install xenio.h and xenio3.h in /usr/include/xen, for the benefit
of xentools3.

XXX ignore those in Makefile.ioctl-c, they don't compile properly outside
of the Xen context and the ioctls from xenio.h conflicts with
soundcard.h
 1.23.26.1 23-Jun-2013  tls resync from head
 1.23.20.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.4.2 25-Oct-2008  apb Pass SED=${TOOL_SED:Q} in the environment to scripts run during the build.
 1.23.4.1 25-Oct-2008  apb file Makefile.ioctl-c was added on branch christos-time_t on 2008-10-25 22:23:56 +0000
 1.34.2.2 30-Sep-2018  pgoyette Ssync with HEAD
 1.34.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.37.2.1 10-Jun-2019  christos Sync with HEAD
 1.6 19-Oct-2008  apb branches: 1.6.4;
Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
 1.5 16-Feb-2008  matt Add siginfo.c to DPSRCS
 1.4 13-Nov-2003  dsl branches: 1.4.24;
Look for siginfo in the correct place - otherwise kdump is rebuilt all the time.
 1.3 21-Oct-2003  lukem Rework how MAKEVERBOSE operates:

* Don't bother prefixing commands with a line of ${_MKCMD}\
and instead rely upon "make -s". This is less intrusive on
all the Makefiles than the former. Idea from David Laight.

* Rename the variables use to print messages. The scheme now is:
_MKMSG_FOO Run _MKMSG 'foo'
_MKTARGET_FOO Run _MKMSG_FOO ${.TARGET}
From discussion with Alistair Crooks.
 1.2 19-Oct-2003  lukem support MAKEVERBOSE and use ${HOST_SH}
 1.1 19-Sep-2003  christos Print siginfo_t information when available.
 1.4.24.1 23-Mar-2008  matt sync with HEAD
 1.6.4.2 19-Oct-2008  apb Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
 1.6.4.1 19-Oct-2008  apb file Makefile.siginfo-c was added on branch christos-time_t on 2008-10-19 22:05:24 +0000
 1.5 03-Apr-2020  wiz branches: 1.5.2;
Increase column widths. Improve -l description wording to match ioctl(2).
Fix Xr.
 1.4 02-Apr-2020  christos Add the ability to:
1. list all ioctls (-l)
2. print the internal definition symbolically
3. search by name

$ ioctlprint -f "%n %E %e\n" TIOCGETA
TIOCGETA _IOR('t', 19, struct termios) _IOR('t',0x13,0x2c)
 1.3 02-Apr-2020  christos *** empty log message ***
 1.2 02-Apr-2020  wiz Remove superfluous Pp. Add comma in enumeration. Add RCS Id.
 1.1 02-Apr-2020  kamil Add ioctlprint - descriptive ioctl value printer

ioctlprint(1) is embedded in the kdump(1) program.
 1.5.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.2.1 03-Apr-2020  martin file ioctlprint.1 was added on branch phil-wifi on 2020-04-08 14:09:16 +0000
 1.31 02-Sep-2022  gutteridge kdump.1: use past tense for history
 1.30 02-Apr-2020  wiz Add comma in enumeration.
 1.29 02-Apr-2020  kamil Note ioctlprint(1) in SEE ALSO
 1.28 10-Sep-2017  wiz branches: 1.28.4;
Sort flags in SYNOPSIS. Remove unnecessary .Tn. Remove trailing whitespace.
 1.27 08-Sep-2017  uwe Option -E to display elapsed timestamps (time since beginning of trace).

Option name from FreeBSD. While here, make it possible to use a
combination of -T -E and -R to display timestamps in several formats.
Idea also from FreeBSD.
 1.26 16-Nov-2003  wiz New sentence, new line; add comma in enumeration.
 1.25 16-Nov-2003  manu Following mycroft's comment, restore -x to its original behavior: without
an argument. Introduce -Xsize to do the job. -x is equivalent to -X1
Of course -x and -Xsize are mutually exclusive.
 1.24 16-Nov-2003  wiz Bump date for previous. New sentence, new line.
 1.23 16-Nov-2003  manu Add an argument to the -x flag to choose between byte per byte display
and word per word display in hex dumps.
-x1 gives you byte per byte, -x4 word per word, and -x defaults to -x1
 1.22 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.21 17-Jul-2003  dsl Grok KTR_EXEC_ENV and KTR_EXEC_ARG.
Make ktrace -c default to removing all trace points (not just the default ones).
Make kdump default to dumping everything in the trace file.
Add 'A' (all) and '-' (remove following) to valid -t arguments.
Dump data block of UNKNOWN trace points in hex + ascii.
Make first time output with -R 0 (instead of time since epoch).
Use svis() instead of vis() to get " escaped (as \") (needs fixed libc)
Correctly pass unsigned values to svis()
Update man pages.
 1.20 11-Jul-2003  wiz Bump date for -x addition.
 1.19 11-Jul-2003  dsl Add a '-x' option to display GIO data blocks in hex and ascii (instead of
vis(3) format).
Maybe there could be a heuristic to decide whether the data is printable...
 1.18 29-Jun-2003  fvdl Back out previous.
 1.17 28-Jun-2003  darrenr add appropriate hack to display ktr_buf as the lwpid if -L is supplied on
the command line.
 1.16 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.15 29-Nov-2002  wiz Bump date for -N; sort options.
 1.14 27-Nov-2002  atatat Add -N which inhibits translation of system calls numbers into names.
 1.13 28-Sep-2002  wiz Bump date for .Op Ar file addition.
 1.12 27-Sep-2002  atatat Allow passing of the ktrace file as the last argument without a -f.
 1.11 20-Jun-2002  atatat It's easy for ktrace can generate trace files that contain data from
multiple processes, so let's add a "-p pid" option to kdump so that it
can pull out the data for one process easily.
 1.10 01-Dec-2001  wiz Whitespace cleanup.
 1.9 04-Feb-2001  jdolecek use 'trstr' for parameter to -t; both 'cenis' (SYNOPSIS) and 'cnis' (DESCRIPTION)
were already out of date and we really don't want keep the info on two
places
 1.8 10-Apr-2000  jdolecek clarify -e usage
 1.7 22-Mar-1999  garbled More and more .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Many more to
come.
 1.6 19-Oct-1997  lukem WARNSify mkioctls output, fix .Nm usage, deprecate register
 1.5 23-Jul-1997  mikel nuke duplicate RCSid
 1.4 09-Jan-1997  tls RCS ID police
 1.3 19-Jul-1995  christos Add support for displaying and switching between
different OS system call emulations
 1.2 06-Oct-1994  mycroft Add RCS ids.
 1.1 11-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 11-May-1994  cgd updated kdump
 1.28.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.147 14-Sep-2025  christos PR/59642: Taylor R Campbell: kdump doesn't show port number for mbsoname
 1.146 06-Mar-2025  rillig kdump: remove extra space in message for SIGCHLD
 1.145 16-Mar-2024  ryoon branches: 1.145.2;
Remove debug print
 1.144 10-Mar-2024  rillig kdump: keep the comment with its corresponding code

No binary change.
 1.143 10-Mar-2024  christos decode some {g,s}etsockopt*.
 1.142 11-Feb-2024  kre PR bin/57918

Redo the previous correctly, the test should be whether or not only the
bottom 32 bits are set, rather than whether any of bits 32..63 are set.
This makes no difference if u_long (or unsigned long long) is 64 bits,
it is the same test in that case, but if u_long were 128 bits there is
a notable difference (though for the particular issue observed in the PR,
it is likely to work either way).
 1.141 10-Feb-2024  christos PR/57918: Taylor R Campbell: Don't try to print symbolically ioctls that
have bits set on the high 32 bits of a 64 bit long.
 1.140 20-Jun-2021  chs branches: 1.140.2;
fix printf format string for xattr names (the length of the xattr name
needs to be a precision rather than a width).
 1.139 30-Apr-2020  martin futexput: cast the mask to u_long (as the op already is)
 1.138 30-Apr-2020  thorpej Decode futex op codes.
 1.137 20-Apr-2020  christos Understand xattr ktruser records
 1.136 03-Apr-2020  wiz Update usage for ioctlprint.
 1.135 02-Apr-2020  christos Add the ability to:
1. list all ioctls (-l)
2. print the internal definition symbolically
3. search by name

$ ioctlprint -f "%n %E %e\n" TIOCGETA
TIOCGETA _IOR('t', 19, struct termios) _IOR('t',0x13,0x2c)
 1.134 02-Apr-2020  christos *** empty log message ***
 1.133 02-Apr-2020  kamil Add ioctlprint - descriptive ioctl value printer

ioctlprint(1) is embedded in the kdump(1) program.
 1.132 23-Jul-2019  nonaka kdump(1): Symbolic printing for MALLOC_OPTIONS="U".
 1.131 06-May-2019  christos You don't have to be _LP64 to run 32 bit binaries. You can be mips (64 bit
kernel/32 bit userland).
 1.130 29-Apr-2018  christos branches: 1.130.2;
print the mprotect perm argument symbolically.
 1.129 10-Sep-2017  wiz branches: 1.129.2;
Sync usage with man page.
 1.128 08-Sep-2017  uwe Print negative time offsets correctly. Provide an exegetical quote
from riastradh@, slightly edited to fit the metre.
 1.127 08-Sep-2017  uwe Option -E to display elapsed timestamps (time since beginning of trace).

Option name from FreeBSD. While here, make it possible to use a
combination of -T -E and -R to display timestamps in several formats.
Idea also from FreeBSD.
 1.126 08-Sep-2017  uwe Drop support for KTRFACv0 (NetBSD 3) and KTRFACv1 (NetBSD 5).
Note that on 32-bit platforms it probably never worked anyway because
header size changed from v1 to v2 when time_t became 64 bit.

ok christos@
CVS: ----------------------------------------------------------------------
CVS: CVSROOT cvs.NetBSD.org:/cvsroot
CVS: please use "PR category/123" to have the commitmsg appended to PR 123
CVS:
CVS: Please evaluate your changes and consider the following.
CVS: Abort checkin if you answer no.
CVS: => For all changes:
CVS: Do the changed files compile?
CVS: Has the change been tested?
CVS: => If you are not completely familiar with the changed components:
CVS: Has the change been posted for review?
CVS: Have you allowed enough time for feedback?
CVS: => If the change is major:
CVS: => If the change adds files to, or removes files from $DESTDIR:
CVS: => If you are changing a library or kernel interface:
CVS: Have you successfully run "./build.sh release"?
 1.125 05-Sep-2016  sevan Drop main() prototype.
 1.124 01-Jun-2016  christos Symbolic printing for mmap
 1.123 27-Mar-2016  alnsn Don't enter infinite loop on big ktr_len values.

Fixes PR 49460.
 1.122 04-Jan-2016  martin Cast register_t to unsigned long before printf'ing it with %lx.
 1.121 03-Jan-2016  christos be a bit smarter about fcntl
 1.120 17-Jun-2015  christos more stray \n
 1.119 16-Jun-2015  christos fix some error handling.
 1.118 30-Apr-2014  njoly Fix compat netbsd32 syscall return values display by calling
output_long() instead of printf().
 1.117 27-Nov-2013  christos branches: 1.117.2;
PR/48413: Inappropriate sign extension in kdump output
 1.116 02-Jan-2013  dsl Only expose the bulk of sys/proc.h and sys/lwp.h if _KERNEL or _KMEMUSER
is defined.
i386 and amd64 build ok.
 1.115 28-Sep-2011  christos branches: 1.115.2; 1.115.8;
don't limit sockets to sizeof(sizeof sockaddr_storage). We can create valid
sockaddr_un sockets that exceed that. Arguably either
sizeof(struct sockaddr_storage) should be amended, or we should disallow
unix domain sockaddrs that exceed that size.
 1.114 21-Sep-2011  christos Symbolic printing of some known MISC records.
 1.113 02-Sep-2011  christos - use PT_STRINGS
- use __arraycount()
 1.112 01-Jun-2011  alnsn kern/42030 - tracking of file descriptors by ktrace/kdump
 1.111 27-Apr-2011  joerg branches: 1.111.2;
Remove Mach specific trace points.
 1.110 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.109 10-Apr-2011  pgoyette Fix string constant so it compiles again.
 1.108 10-Apr-2011  christos we don't have access to si_lid anymore.
 1.107 10-Apr-2011  christos print detailed info about other SI_ codes.
 1.106 10-Jan-2011  christos format SI_QUEUE properly.
 1.105 08-Aug-2010  chs fix emul state tracking for exit vs exit_group on linux.
 1.104 13-Apr-2009  christos Allow kdump to be used as an ioctl decoder if invoked as ioctlname.
 1.103 12-Apr-2009  lukem fix sign-compare issues
 1.102 11-Jan-2009  christos branches: 1.102.2;
resolve conflict.
 1.101 11-Jan-2009  christos merge christos-time_t
 1.100 02-Jan-2009  njoly Add minimal SI_LWP support.
 1.99 12-Sep-2008  christos branches: 1.99.6;
handle SI_NOINFO
 1.98 21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.97 18-Jun-2008  njoly Output linux ptrace request name for processes under compat linux32
emulation too.
 1.96 29-Feb-2008  njoly branches: 1.96.4;
Add a few NULL entries to linux_ptrace_ops[], to make PTRACE_SYSCALL
string appear at the expected indice 24.
 1.95 15-Dec-2007  perry branches: 1.95.2;
convert __attribute__s to applicable cdefs.h macros
 1.94 07-Nov-2007  dsl Apply the -N (show syscalls by number) to the system return trace.
Change 'USER' to 'MISC' since they get used for misc kernel traces as well.
 1.93 08-Aug-2007  agc branches: 1.93.2;
Apply fix from PR 35283 from David Holland:

ensure that kdump properly escapes newlines in argv
 1.92 01-Jun-2007  dsl When displaying 'KTR_USER' data, exclude the header from the length, don't
enclose in ", and output using the hexdump function if -x (or -X) given.
 1.91 21-May-2007  dogcow fallout from si_sigval -> si_value
 1.90 19-Mar-2007  njoly When decoding ioctl commands type; do not output non printable
characters, but the corresponding hexadecimal values.

ok by christos
 1.89 09-Feb-2007  ad Sync with kernel changes introduced by merging the newlock2 branch.
 1.88 28-Jan-2007  chs skip over the "self" sa when printing upcalls.
 1.87 23-Oct-2006  mrg branches: 1.87.2;
since register_t is sometimes unsigned, cast to (long) to check >= 0.
 1.86 23-Sep-2006  manu Add a -t+S flag to ktrace for tracing activity related to sysctl. MIB
names will be displayed, with data readen and written as well.
 1.85 05-Apr-2006  christos Use the standard macros to compute the ioctl length instead of rolling our
own. Thanks to Chuck for noticing.
 1.84 05-Mar-2006  christos Add PT_SYSCALL
 1.83 11-Dec-2005  christos Learn about v1 records and sa upcalls.
 1.82 18-Oct-2005  christos Print symbolic signal names for killpg *sigaction* and *sigvec*.
 1.81 16-Jul-2005  christos WARNS=3
 1.80 02-Jun-2005  lukem appease gcc -Wuninitialized
 1.79 23-Aug-2004  dsl Ensure a non-zero 'word_size' is passed to hexdump_buf for unknown
trace types.
Also fix an incorrect use of the global word_size variable
 1.78 06-May-2004  matt Allow kdump to print the names for machine dependent ptrace ops.
(This requires <machine/ptrace.h> to define PT_MACHDEP_STRINGS
which corresponds to the machdep ops).
 1.77 07-Mar-2004  dsl branches: 1.77.2;
Suppress duplicate lines when hexdumping data
 1.76 27-Feb-2004  enami Fix whitespace usage and remove unnecessary semi-colon.
 1.75 27-Feb-2004  enami We can't access array[sizeof(array) / sizeof(array[0])].
 1.74 27-Feb-2004  enami Calculate the width again if we start newline at tab character, since
start column changes.
 1.73 02-Feb-2004  christos Fix reversed logic (decimal argument passed in output_long, where it expects
hex). Change tests to <= 9 to a small(v) macro, so that negative numbers fail
too consistently.
 1.72 15-Jan-2004  mrg redo the former in light of making the kernel output normal 64 bit
records for 32 bit & 64 bit processes. we still make some adjustments
when dealing with 32-bit processes, but largely things are handled the
same now. make the code to match "netbsd32_<syscall>" in place of
plain "<syscall>" more general.
 1.71 12-Jan-2004  mrg - add a new flags field to the emulation vector, with one user so far
EMUL_FLAG_NETBSD32. set EMUL_FLAG_NETBSD32 in any 32 bit on 64 bit
kernel emulation layers.
- if EMUL_FLAG_NETBSD32 is set, calculate the proper argument count.
(XXX: this should use register32_t, but that's not visible to all
builders of kdump...)

now netbsd32_ioctl(2) actually reports sane values, and other arguments
are mostly correctly printed (there are still some signed extension
issues with 32 bit numbers being displayed as "0xffffffff8xxxxxxx".)
 1.70 24-Nov-2003  manu Fix cross-build problem on sparc caused by a cast size_t -> int
 1.69 24-Nov-2003  manu Enable tracing of out of line data sent with Mach messages
 1.68 18-Nov-2003  manu For Mach messages, always display the message Id in decimal. The information
is indeed in the message, but in hex. It's a bit inconvenient.
 1.67 18-Nov-2003  dsl Stop core dump if an ioctl trace has fewer than expected arguments.
- Check names of system calls (for special treatment) because emulations
might use different numbers.
- Report an error if arguments to -p or -m non-numeric.
- Just take last of -x and -Xvalue, stop -X0x80000000 being valid (core dumps).
- Keep 'last used' emulation_ctx at top of list, create on lookup (usually
EMUL anyway), delete when exit called (doesn't return).
- Slightly improve hack to get correct system call name in execve return
when emulation has changed.
- Rename global variables 'current'/'previous' to 'cur_emul'/'prev_emul'.
(TODO: save system call type (and maybe an argument) per pid so GIO trace
format can depend on the actual system call.)
Fixes part of PR sparc64/23473 - but system call arguments will still not be
displayed correctly.
 1.66 16-Nov-2003  manu Following mycroft's comment, restore -x to its original behavior: without
an argument. Introduce -Xsize to do the job. -x is equivalent to -X1
Of course -x and -Xsize are mutually exclusive.
 1.65 16-Nov-2003  dsl Validate the numeric argument to -x, support -x1|2|4|8|16.
Produce sensible output on little-endian systems.
 1.64 16-Nov-2003  manu Add an argument to the -x flag to choose between byte per byte display
and word per word display in hex dumps.
-x1 gives you byte per byte, -x4 word per word, and -x defaults to -x1
 1.63 15-Nov-2003  manu kdump now displays Mach services names itself, including a table of
id/names in sys/compat/mach/mach_services_names.c

Remove ports and flags displays, the information is already in the message.
 1.62 20-Sep-2003  matt Fix printf botch
 1.61 20-Sep-2003  christos improve formatting in the non-siginfo case, by printing the code. This is
for compatibility with the old ktrace files.
 1.60 19-Sep-2003  christos Print siginfo_t information when available.
 1.59 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.58 17-Jul-2003  dsl Grok KTR_EXEC_ENV and KTR_EXEC_ARG.
Make ktrace -c default to removing all trace points (not just the default ones).
Make kdump default to dumping everything in the trace file.
Add 'A' (all) and '-' (remove following) to valid -t arguments.
Dump data block of UNKNOWN trace points in hex + ascii.
Make first time output with -R 0 (instead of time since epoch).
Use svis() instead of vis() to get " escaped (as \") (needs fixed libc)
Correctly pass unsigned values to svis()
Update man pages.
 1.57 13-Jul-2003  dsl Change back to print hex bytes. The 'word' print was completely broken
on little endian systems. It is also much easier to read misaligned
words in a straight byte hexdump.
Cut offset to 3 hex digits so that it fixs in 80 columns and still
leaves a tab at the start of 'continuation' lines.
The ktrace buffer is limited to 4k, so 3 digits is ample.
 1.56 13-Jul-2003  he On some ports, pointer differences are not ints, so do a cast
before using such a result as a field width.
 1.55 12-Jul-2003  manu Make hexdump output fix in 80 char-wide terminal
 1.54 12-Jul-2003  manu Use the same code to display hexdump of GIO and MMSG (Mach Messages).
While we are there, display offsets in the hexdump, it can be useful.
Remove size display in Mach Messages as user processes don't always
fill it correctly.
 1.53 11-Jul-2003  wiz Add -x to usage output.
 1.52 11-Jul-2003  dsl Add a '-x' option to display GIO data blocks in hex and ascii (instead of
vis(3) format).
Maybe there could be a heuristic to decide whether the data is printable...
 1.51 29-Jun-2003  fvdl Back out previous.
 1.50 29-Jun-2003  martin Since a caddr_t is (mis-)used as the lwp-id, cast it to intptr_t and use
apropriate format string.
 1.49 28-Jun-2003  darrenr add appropriate hack to display ktr_buf as the lwpid if -L is supplied on
the command line.
 1.48 15-May-2003  dsl Print rval[1] if non-zero and present in the trace entry.
To get both fd numbers for pipe().
 1.47 30-Jan-2003  atatat Make "-m0" print no data, so that we agree better with the man page.
 1.46 09-Dec-2002  manu Added support for dumping mach messages in ktrace/kdump. While we are
there, KNFify a few functions.
 1.45 29-Nov-2002  wiz Sync usage with man page (and actual options).
 1.44 28-Nov-2002  jdolecek signame(): if sig == 0, return name " 0", so that the result would be
printed as:
CALL kill(0x1e4, SIG 0)
rathern than previous
CALL kill(0x1e4, SIG*unknown 0*)
 1.43 27-Nov-2002  atatat Add -N which inhibits translation of system calls numbers into names.
 1.42 15-Nov-2002  manu Now properly display Mach traps
 1.41 27-Sep-2002  atatat Allow passing of the ktrace file as the last argument without a -f.
 1.40 04-Aug-2002  jdolecek Fix formatting of ktr_user entries so that values of individual bytes
of ktrace record are treated as unsigned char, and printed using "%02x".
Change suggested in bin/17832 by Paul Goyette.
 1.39 20-Jun-2002  atatat It's easy for ktrace can generate trace files that contain data from
multiple processes, so let's add a "-p pid" option to kdump so that it
can pull out the data for one process easily.
 1.38 08-Apr-2002  christos Fix translation in the native emulation. Noted by veego.
 1.37 31-Mar-2002  christos Provide hooks for signal number to name translation, and use them for kill
and PSIG.

XXX[1]: This shows that signal emulation ktrace is slightly busted: posted
signals should really be translated to the emulated ones instead of
producing ktrace records with the signal numbers of the native
emulation.
XXX[2]: There are other places where signal names can be displayed, but this
is not done yet.
 1.36 12-Feb-2002  christos reverse the notion of fancy, use plain, and increment it so that we can
have multiple levels of plainness. I want to be able to display syscalls
numerically, for that use -nn. This is not documented as it is an wip.
 1.35 16-Feb-2001  manu Cosmetic fix so that RET record after CALL execve get the appropriate syscall
even if the emulation changed
 1.34 28-Dec-2000  jdolecek adapt to KTR_USER structure changes
 1.33 20-Dec-2000  itojun avoid using "errno" as struct member name, to avoid conflict with errno.h.
ok by jdolecek
 1.32 17-Dec-2000  jdolecek add support for KTR_USER records
 1.31 13-Nov-2000  jdolecek map linux ptrace op (number) to it's appropriate name - this is kind of hack,
but turned out to be pretty usable for me
 1.30 12-Oct-2000  is Format string cleanups
 1.29 26-Apr-2000  tron branches: 1.29.4;
Prevent "kdump" from causing a segmentation fault if the io buffer that
it's printing to stdout ends on a page boundary. Patch supplied by
Andrew Brown in PR bin/9983.
 1.28 10-Apr-2000  jdolecek put setemul(), ectx_* & appropriate structures to separate file, to make it
more easily sharable with ktruss(1)
 1.27 10-Apr-2000  jdolecek Keep track of what pid uses which emulation and ensure proper
structures are used when decoding the ktrace records. This makes
kdump of ktrace -i output of a process executing binaries of various
emulations actually useful - before, the code used emulation structures
appropriate for last recently executed process, which is bogus.
 1.26 27-Mar-2000  kleink Cast timeval members to types we know the printf conversions of.
 1.25 31-Dec-1999  eeh Add COMPAT_NETBSD32 support.
 1.24 06-Aug-1999  thorpej Don't truncate syscall return values on LP64 platforms.
 1.23 24-Oct-1998  christos branches: 1.23.2;
Adjust to Eric's recent errno renaming.
 1.22 18-Oct-1998  christos Fix emulation errno translation.
 1.21 11-Sep-1998  mycroft Update for signal handling changes.
 1.20 30-Mar-1998  mrg use static int instead of static
 1.19 20-Oct-1997  lukem add support for freebsd emulation. from Dave Huang <khym@bga.com> [bin/4293]
 1.18 19-Oct-1997  lukem WARNSify mkioctls output, fix .Nm usage, deprecate register
 1.17 23-Jul-1997  mikel add explicit return types and prototypes for local functions
use __COPYRIGHT and __RCSID macros, fix other gcc -Wall warnings
 1.16 17-May-1997  pk * NULL => 0 (Arne Juul; PR#3629)
* Nuke spacoids
 1.15 27-Jan-1997  cgd fix decode of _IOR/_IOW/_IOWR: 'R' and 'W' were switched (i.e. _IOW ioctls
would print out as '_IOR'), and _IOWR ioctls were being printed as
_IORW (which doesn't exist).
 1.14 21-Nov-1996  mikel eliminate multiple inclusion of <sys/errno.h>.
 1.13 13-May-1996  christos Decode unknown ioctl commands to _IO{R,W,}('c',x[,y]), instead of 0xabcdef00
 1.12 31-Aug-1995  jtc Sync with 4.4lite2
 1.11 19-Jul-1995  christos Add support for displaying and switching between
different OS system call emulations
 1.10 07-Jun-1995  cgd only print MAXCOMLEN chars of the process command name. fixes pr 1080.
 1.9 11-May-1995  cgd don't get syscalls.c with an absolute path
 1.8 28-Mar-1995  jtc KERNEL -> _KERNEL
 1.7 26-Mar-1995  cgd update for the new data stored in ktrace files:
(1) use argsize rather than nargs
(2) print long-sized (assumed == register_t-sized; XXX) items
rather than int-sized ones.
 1.6 21-Mar-1995  mycroft Make two variables non-static.
 1.5 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.4 15-Jan-1995  mycroft Some KNF, POSIX, and err*(3)/warn*(3) cleanup. Also, use sys_signame[]
rather than a private, home-grown list.
 1.3 06-Oct-1994  mycroft Add RCS ids.
 1.2 18-May-1994  deraadt netbsd does not define PT_STEP for architectures that lack
in-kernel single stepping capabilities.
 1.1 11-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 31-Aug-1995  jtc imported from 44lite2
 1.1.1.1 11-May-1994  cgd updated kdump
 1.23.2.1 19-Oct-2000  he Apply patch (requested by he):
Fix format / arg mismatch.
 1.29.4.1 18-Oct-2000  tv Pullup usr.bin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.77.2.2 30-Aug-2004  tron Pull up revision 1.79 (requested by skrll in ticket #789):
Ensure a non-zero 'word_size' is passed to hexdump_buf for unknown
trace types.
Also fix an incorrect use of the global word_size variable
 1.77.2.1 10-May-2004  tron Pull up revision 1.78 (requested by matt in ticket #278):
Allow kdump to print the names for machine dependent ptrace ops.
(This requires <machine/ptrace.h> to define PT_MACHDEP_STRINGS
which corresponds to the machdep ops).
 1.87.2.1 16-Feb-2007  riz Pull up following revision(s) (requested by chs in ticket #420):
usr.bin/kdump/kdump.c: revision 1.88
skip over the "self" sa when printing upcalls.
 1.93.2.2 23-Mar-2008  matt sync with HEAD
 1.93.2.1 09-Jan-2008  matt sync with HEAD
 1.95.2.1 24-Mar-2008  keiichi sync with head.
 1.96.4.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.96.4.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.96.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.99.6.2 29-Dec-2008  christos update for version 2
 1.99.6.1 12-Sep-2008  christos file kdump.c was added on branch christos-time_t on 2008-12-29 01:23:13 +0000
 1.102.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.111.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.115.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.115.8.1 25-Feb-2013  tls resync with head
 1.115.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.115.2.1 23-Jan-2013  yamt sync with head
 1.117.2.1 10-Aug-2014  tls Rebase.
 1.129.2.1 02-May-2018  pgoyette Synch with HEAD
 1.130.2.4 21-Apr-2020  martin Sync with HEAD
 1.130.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.130.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.130.2.1 10-Jun-2019  christos Sync with HEAD
 1.140.2.2 25-Mar-2024  martin Pull up following revision(s) (requested by kre in ticket #641):

usr.bin/kdump/kdump.c: revision 1.145

Remove debug print
 1.140.2.1 12-Mar-2024  martin Pull up following revision(s) (requested by kre in ticket #635):

usr.bin/kdump/kdump.c: revision 1.141
usr.bin/kdump/kdump.c: revision 1.142
usr.bin/kdump/kdump.c: revision 1.143
usr.bin/kdump/kdump.c: revision 1.144

PR/57918: Taylor R Campbell: Don't try to print symbolically ioctls that
have bits set on the high 32 bits of a 64 bit long.

PR bin/57918

Redo the previous correctly, the test should be whether or not only the
bottom 32 bits are set, rather than whether any of bits 32..63 are set.

This makes no difference if u_long (or unsigned long long) is 64 bits,
it is the same test in that case, but if u_long were 128 bits there is
a notable difference (though for the particular issue observed in the PR,
it is likely to work either way).
decode some {g,s}etsockopt*.

kdump: keep the comment with its corresponding code
No binary change.
 1.145.2.1 02-Aug-2025  perseant Sync with HEAD
 1.57 12-Sep-2020  roy kdump: include netinet/in_var.h to access in_nbrinfo
 1.56 02-Apr-2020  christos remove debugging
 1.55 02-Apr-2020  christos Add the ability to:
1. list all ioctls (-l)
2. print the internal definition symbolically
3. search by name

$ ioctlprint -f "%n %E %e\n" TIOCGETA
TIOCGETA _IOR('t', 19, struct termios) _IOR('t',0x13,0x2c)
 1.54 02-Apr-2020  christos *** empty log message ***
 1.53 29-Sep-2018  rmind NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.
 1.52 12-Jun-2018  christos branches: 1.52.2;
- instead of hard-coding the include paths in mkioctls, pass them in
from the Makefile so that they are consistent.
- do more sed so that destination paths are not hard-coded inside #include
statements.
 1.51 02-Jun-2018  mrg just include <sys/mutex.h> for mkioctls. this works fine for me
for several platforms and fixes the clang build.
 1.50 29-May-2018  martin Use proper forward declaration for kmutex_t. This makes MKDTRACE=no builds
work again.
 1.49 29-May-2018  martin Ooops, backout previous - it was an update build artifact (or something)
 1.48 29-May-2018  martin Backout previous: "typedef void *kmutex_t;
is incompatible with our kmutex_t and breaks the build. ZFS will need
to find a better way to work around this.
 1.47 28-May-2018  chs merge a new version of the CDDL dtrace and ZFS code.
this changes the upstream vendor from OpenSolaris to FreeBSD,
and this version is based on FreeBSD svn r315983.

in addition to the 10 years of improvements from upstream,
this version also has these NetBSD-specific enhancements:
- dtrace FBT probes can now be placed in kernel modules.
- ZFS now supports mmap().
 1.46 05-Nov-2017  christos branches: 1.46.2;
deal with the stdbool.h mess defining bool in <net/if.h> and <net/route.h>
and then xf86Opt.h wanting to define a struct field called bool.
 1.45 22-Oct-2015  christos simplify
 1.44 27-Sep-2015  christos Kill sys/modctl.h which we don't need.
 1.43 20-May-2015  matt #include <sys/exec_elf.h> for ksyms
 1.42 06-Feb-2015  christos Extend the scripts to handle the X drm ioctls.
 1.41 04-Apr-2013  dsl Output a blank line between the fixed and variable #include lines.
Just a little hint that they come from different places.
 1.40 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.39 22-Mar-2010  mrg branches: 1.39.6; 1.39.12;
convert -idirafter to -isystem, as recommended by cgd in PR 11843.
most of the list in that PR were already done.
 1.38 25-Oct-2008  apb branches: 1.38.4;
In shell scripts run during the build, add a SED variable, defaulting
to "sed". SED=${TOOL_SED:Q} should be passed in the environment to
override this.
 1.37 19-Oct-2008  apb In shell scripts invoked during a build, and in crunchgen, use ${AWK}
instead of plain "awk". The Makefiles that invoke these scripts
or programs will pass AWK=${HOST_AWK:Q}.
 1.36 23-Mar-2008  christos little cleanups.
 1.35 11-Mar-2008  joerg Don't skip ioctls with a digit in the name.
Add a number of conflicting entries.
Add some entries from the IPv6 stack where the used structure is not
exported to userland.
 1.34 11-Feb-2008  dyoung branches: 1.34.2;
Do not #include <sys/device.h> from userland.
 1.33 29-Jun-2007  dmcmahill branches: 1.33.4;
Replace "awk" with "${AWK:-awk}".

Needed to be able to cross-build on systems with a feeble awk (SunOS-5.9
for example). Example error message is:
awk: record `#define CTL_IPPROTO_...' has too many fields
record number 404
 1.32 05-Mar-2007  he Add two more ioctl values which are the same.
 1.31 30-Nov-2006  elad branches: 1.31.2;
Conflict was resolved, so revert previous.

Okay dogcow@.
 1.30 29-Nov-2006  dogcow deal with VERIEXEC_LOAD/SPKRTONE conflict
 1.29 31-Aug-2006  he Provide a dummy default for NBPG after including <sys/param.h> to deal
with a build problem for sparc. The reason is that <dev/tc/sticio.h>
(yes, irrelevant for sparc...) wants NBPG declared, but for sparc user-land
that symbol is not available since sun4/sun4c/sun4m do not all share the
same page size.
 1.28 31-Aug-2006  he Add one more conflicting ioctl set: CLOCKCTL_ADJTIME / TCTRL_MODEM_PWR,
(partially) fixes build problem for sparc.
 1.27 30-Aug-2006  he Add handling of two more pairs of duplicate ioctl values: amiga's
and x68k's PARIOC[SG]PARAM reuse the ioctl values from sbus/mbppio.h's
MBPPIOC[SG]PARAM.

Suggested by Christos.
 1.26 29-Aug-2006  christos Fix sparc64 build; thanks to Martin S. Weber
 1.25 27-Aug-2006  christos Include <sys/device.h> needed by iopio.h
 1.24 27-Aug-2006  christos pick up ioctls from other devices too.
 1.23 03-Jun-2006  christos We don't need to define struct ap_control anymore
 1.22 03-Jun-2006  christos SIOCLOOKUPSTAT is the same as SIOCPROXY.
 1.21 16-Jul-2005  christos branches: 1.21.2;
WARNS=3
 1.20 08-Jul-2004  christos deal with another dup ioctl; fortunately this is from pcvt and it will die.
 1.19 22-Jun-2004  christos Include ioctl's that don't have IO in their names [lkm ones eg.]
 1.18 10-May-2004  drochner remove creation of the intermediate "sourcefile" which was for debugging
 1.17 10-May-2004  hannken Add "sys/dkbad.h" for DIOCSBAD from sys/dkio.h.
Use # to start comment in awk program.
 1.16 10-May-2004  christos Change code to use a switch statement, and add exceptions to fix the
conflicts.

XXX: Fix the conflicts.

1. chio: change to 'x' from 'c' so that it does not conflict with cdio.
keep the 'c' ioctls in the driver for compat.
2. ppp/slip: change SLCGUNIT to some other number and accept the old number
in the driver.
3. ipf: [3 instances] Have darren fix them.
 1.15 08-May-2004  jmc Add another exception for broken includes (showed up on acorn32 build)
 1.14 22-Apr-2004  christos Instead of pussy-footing around and grabbing a few of the ioctl's here and
there randomly, grab all the ioctls from the include files.
Read the XXX's in mkioctls about problems with our header files.
 1.13 27-Aug-2003  thorpej * Make it a little easier to add new "ioctl defns are in these files".
* Add the ability to decode the cryptodev ioctls.
 1.12 24-Jun-2003  mjl Add sys/sockio.h to needed includes for SIOCGIFASYNCMAP.
 1.11 27-Jul-2000  cgd '${CC:-cc} -E' rather than 'cpp': want to use a cross-compiler if
appropriate, but worse: 'cpp' (real-UNIX or stock gnu) takes args
[infile [outfile]]. I.e., the second arg (ioctl_compat.h) would
end up being nuked by this script if using a vendor or stock gnu cpp!
Our /usr/bin/cpp works Differently.
 1.10 19-Oct-1997  lukem WARNSify mkioctls output, fix .Nm usage, deprecate register
 1.9 23-Jul-1997  mikel RCSid police
 1.8 14-Apr-1997  leo Make it obey the DESTDIR environment.
 1.7 31-Aug-1995  jtc Sync with 4.4lite2
 1.6 06-Jun-1995  thorpej Bring in all includes necessary since the multicast changes. Fixes
PR #1114.
 1.5 15-Jan-1995  mycroft Gather a more complete ioctl list. From Matt Green (somewhat edited).
 1.4 24-Dec-1994  cgd val is a long, now.
 1.3 06-Oct-1994  mycroft Add RCS ids.
 1.2 18-Jun-1994  mycroft Pass the file names in to mkioctl, to help cross-compilation.
 1.1 11-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 31-Aug-1995  jtc imported from 44lite2
 1.1.1.1 11-May-1994  cgd updated kdump
 1.21.2.1 19-Jun-2006  chap Sync with head.
 1.31.2.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by garbled in ticket #536):
usr.bin/kdump/mkioctls: revision 1.32
Add two more ioctl values which are the same.
 1.33.4.1 23-Mar-2008  matt sync with HEAD
 1.34.2.1 24-Mar-2008  keiichi sync with head.
 1.38.4.2 25-Oct-2008  apb In shell scripts run during the build, add a SED variable, defaulting
to "sed". SED=${TOOL_SED:Q} should be passed in the environment to
override this.
 1.38.4.1 25-Oct-2008  apb file mkioctls was added on branch christos-time_t on 2008-10-25 22:18:16 +0000
 1.39.12.1 23-Jun-2013  tls resync from head
 1.39.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.2.2 30-Sep-2018  pgoyette Ssync with HEAD
 1.46.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.52.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.52.2.1 10-Jun-2019  christos Sync with HEAD
 1.6 11-Sep-2021  andvar Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.5 19-Oct-2008  apb branches: 1.5.4;
In shell scripts invoked during a build, and in crunchgen, use ${AWK}
instead of plain "awk". The Makefiles that invoke these scripts
or programs will pass AWK=${HOST_AWK:Q}.
 1.4 12-Sep-2008  christos When returning an unknown code, return the code number not NULL
 1.3 30-Apr-2008  martin branches: 1.3.2;
Convert TNF licenses to new 2 clause variant
 1.2 13-Nov-2003  matt branches: 1.2.32;
Use envariable AWK
 1.1 19-Sep-2003  christos Print siginfo_t information when available.
 1.2.32.1 18-May-2008  yamt sync with head.
 1.3.2.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.5.4.2 19-Oct-2008  apb In shell scripts invoked during a build, and in crunchgen, use ${AWK}
instead of plain "awk". The Makefiles that invoke these scripts
or programs will pass AWK=${HOST_AWK:Q}.
 1.5.4.1 19-Oct-2008  apb file mksiginfos was added on branch christos-time_t on 2008-10-19 22:10:06 +0000
 1.32 25-Mar-2019  maxv Remove compat_osf1, discussed on tech-kern@.
 1.31 29-Dec-2018  martin ibcs2 is gone
 1.30 19-Dec-2018  martin compat/svr4* is gone - adapt
 1.29 26-Apr-2011  joerg branches: 1.29.42; 1.29.44;
Remove PECOFF/Win32 emulation.
 1.28 26-Apr-2011  joerg Remove IRIX emulation
 1.27 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.26 28-Apr-2008  martin branches: 1.26.8;
Remove clause 3 and 4 from TNF licenses
 1.25 31-Dec-2007  ad branches: 1.25.4;
COMPAT_HPUX is gone
 1.24 07-Nov-2007  dsl Verify that the system call is within the negative range before
deciding that it is a 'mach' system call.
XXX - shouldn't this translation only happen for certain emulations?
 1.23 07-Feb-2007  njoly branches: 1.23.4;
compat linux32 depends on compat netbsd32, and thus needs
EMUL_FLAG_NETBSD32.

ok by manu
 1.22 04-May-2006  christos Handle aout m68k; from Izumi Tsutsui.
 1.21 09-Feb-2006  manu Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.20 15-Jan-2005  jdolecek ectx_find() failed to lookup the emulation context unless it happened
to be the first entry, effectively resetting context of all processes to
default emulation on every EMUL trace record

rewrite ectx_find() to fix this, using <sys/queue.h> LIST for readability

this fix should once and for all remove need to ever use -e option,
and makes kdump work properly for traces with processes under different
emulations
 1.19 12-Jan-2004  mrg - add a new flags field to the emulation vector, with one user so far
EMUL_FLAG_NETBSD32. set EMUL_FLAG_NETBSD32 in any 32 bit on 64 bit
kernel emulation layers.
- if EMUL_FLAG_NETBSD32 is set, calculate the proper argument count.
(XXX: this should use register32_t, but that's not visible to all
builders of kdump...)

now netbsd32_ioctl(2) actually reports sane values, and other arguments
are mostly correctly printed (there are still some signed extension
issues with 32 bit numbers being displayed as "0xffffffff8xxxxxxx".)
 1.18 18-Nov-2003  dsl Stop core dump if an ioctl trace has fewer than expected arguments.
- Check names of system calls (for special treatment) because emulations
might use different numbers.
- Report an error if arguments to -p or -m non-numeric.
- Just take last of -x and -Xvalue, stop -X0x80000000 being valid (core dumps).
- Keep 'last used' emulation_ctx at top of list, create on lookup (usually
EMUL anyway), delete when exit called (doesn't return).
- Slightly improve hack to get correct system call name in execve return
when emulation has changed.
- Rename global variables 'current'/'previous' to 'cur_emul'/'prev_emul'.
(TODO: save system call type (and maybe an argument) per pid so GIO trace
format can depend on the actual system call.)
Fixes part of PR sparc64/23473 - but system call arguments will still not be
displayed correctly.
 1.17 15-Nov-2003  manu kdump now displays Mach services names itself, including a table of
id/names in sys/compat/mach/mach_services_names.c

Remove ports and flags displays, the information is already in the message.
 1.16 19-Oct-2003  christos KNF:
- ansify
- no breaks after returns
- statics where needed
- no exit after errx
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.14 15-Nov-2002  manu Now properly display Mach traps
 1.13 29-Oct-2002  manu Added support for COMPAT_MACH
 1.12 31-Mar-2002  christos Provide hooks for signal number to name translation, and use them for kill
and PSIG.

XXX[1]: This shows that signal emulation ktrace is slightly busted: posted
signals should really be translated to the emulated ones instead of
producing ktrace records with the signal numbers of the native
emulation.
XXX[2]: There are other places where signal names can be displayed, but this
is not done yet.
 1.11 07-Jan-2002  manu reflect iric o32/n32 emulations
 1.10 02-Dec-2001  manu Now use IRIX errno translation instead of SVR4 errno translation
 1.9 28-Nov-2001  manu Added support for IRIX emulation
 1.8 11-Mar-2001  eeh Add svr4_32 info.
 1.7 16-Feb-2001  manu Cosmetic fix so that RET record after CALL execve get the appropriate syscall
even if the emulation changed
 1.6 02-Feb-2001  mrg teach kdump about compat/sunos32
 1.5 13-Nov-2000  jdolecek adapt to *syscallnames[] change (it's now const char * const foo[]),
constify
 1.4 20-Jul-2000  jdolecek ectx_sanify(): ditch utterly broken 'optimization', which caused incorrect
emulation structures to be used in every even case if default emulation
and emulation of process differed.

Bug found by Bill Studenmund.
 1.3 13-Jun-2000  itohy branches: 1.3.2;
Add "pecoff" emulation.
 1.2 10-Apr-2000  jdolecek branches: 1.2.2;
ectx_sanify(): if default_emul is not set, use netbsd emulation (may happen when user passes invalid
emulation name via -e argument)
 1.1 10-Apr-2000  jdolecek put setemul(), ectx_* & appropriate structures to separate file, to make it
more easily sharable with ktruss(1)
 1.2.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.1 20-Jul-2000  jdolecek update from trunk, rev 1.4 (approved by thorpej):
ectx_sanify(): ditch utterly broken 'optimization', which caused incorrect
emulation structures to be used in every even case if default emulation
and emulation of process differed.

Bug found by Bill Studenmund.
 1.23.4.1 09-Jan-2008  matt sync with HEAD
 1.25.4.1 18-May-2008  yamt sync with head.
 1.26.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.26.8.1 28-Apr-2008  martin file setemul.c was added on branch christos-time_t on 2008-04-28 20:24:14 +0000
 1.29.44.1 10-Jun-2019  christos Sync with HEAD
 1.29.42.2 18-Jan-2019  pgoyette Synch with HEAD
 1.29.42.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.15 26-Apr-2011  joerg Remove Darwin, MACH and Mach-O support.
 1.14 28-Apr-2008  martin branches: 1.14.8;
Remove clause 3 and 4 from TNF licenses
 1.13 16-Jul-2005  christos branches: 1.13.20;
WARNS=3
 1.12 12-Jan-2004  mrg - add a new flags field to the emulation vector, with one user so far
EMUL_FLAG_NETBSD32. set EMUL_FLAG_NETBSD32 in any 32 bit on 64 bit
kernel emulation layers.
- if EMUL_FLAG_NETBSD32 is set, calculate the proper argument count.
(XXX: this should use register32_t, but that's not visible to all
builders of kdump...)

now netbsd32_ioctl(2) actually reports sane values, and other arguments
are mostly correctly printed (there are still some signed extension
issues with 32 bit numbers being displayed as "0xffffffff8xxxxxxx".)
 1.11 18-Nov-2003  dsl Stop core dump if an ioctl trace has fewer than expected arguments.
- Check names of system calls (for special treatment) because emulations
might use different numbers.
- Report an error if arguments to -p or -m non-numeric.
- Just take last of -x and -Xvalue, stop -X0x80000000 being valid (core dumps).
- Keep 'last used' emulation_ctx at top of list, create on lookup (usually
EMUL anyway), delete when exit called (doesn't return).
- Slightly improve hack to get correct system call name in execve return
when emulation has changed.
- Rename global variables 'current'/'previous' to 'cur_emul'/'prev_emul'.
(TODO: save system call type (and maybe an argument) per pid so GIO trace
format can depend on the actual system call.)
Fixes part of PR sparc64/23473 - but system call arguments will still not be
displayed correctly.
 1.10 15-Nov-2003  manu kdump now displays Mach services names itself, including a table of
id/names in sys/compat/mach/mach_services_names.c

Remove ports and flags displays, the information is already in the message.
 1.9 19-Oct-2003  christos KNF:
- ansify
- no breaks after returns
- statics where needed
- no exit after errx
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.7 15-Nov-2002  manu Now properly display Mach traps
 1.6 31-Mar-2002  christos Provide hooks for signal number to name translation, and use them for kill
and PSIG.

XXX[1]: This shows that signal emulation ktrace is slightly busted: posted
signals should really be translated to the emulated ones instead of
producing ktrace records with the signal numbers of the native
emulation.
XXX[2]: There are other places where signal names can be displayed, but this
is not done yet.
 1.5 16-Feb-2001  manu Cosmetic fix so that RET record after CALL execve get the appropriate syscall
even if the emulation changed
 1.4 19-Jan-2001  enami Make files here compile again.
 1.3 20-Dec-2000  itojun avoid using "errno" as struct member name, to avoid conflict with errno.h.
ok by jdolecek
 1.2 13-Nov-2000  jdolecek adapt to *syscallnames[] change (it's now const char * const foo[]),
constify
 1.1 10-Apr-2000  jdolecek put setemul(), ectx_* & appropriate structures to separate file, to make it
more easily sharable with ktruss(1)
 1.13.20.1 18-May-2008  yamt sync with head.
 1.14.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.14.8.1 28-Apr-2008  martin file setemul.h was added on branch christos-time_t on 2008-04-28 20:24:14 +0000

RSS XML Feed