Home | History | Annotate | only in /src/sys/ddb
History log of /src/sys/ddb
RevisionDateAuthorComments
 1.19 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.18 19-Dec-2020  mrg update several items that are done or dead.
 1.17 11-Dec-2005  christos branches: 1.17.176;
merge ktrace-lwp.
 1.16 30-May-2005  jhawk minor updates: vax port kludge is in trace, not kill. spelling.
no 0t output in ps.
 1.15 29-Sep-2004  reinoud Implement ddb setting that allows all ddb output to be teed into the
kernel message buffer/log. Its off by default and can be switched on in the
kernel configuration on build time, be set as a variable in ddb and be set
using sysctl.

This adds the sysctl value
ddb.tee_msgbuf = 0
by default.

The functionality is especially added and aimed for developers who are not
blessed with a serial console and wish to keep all their ddb output in the
log. Specifying /l as a modifier to some selected commands will also put
the output in the log but not all commands provide one nor has the same
meaning for all commands.

This feature could in the future also be implemented as an ddb command but
that could lead to more bloat allthough maybe easier for non developpers to
use when mailing their backtraces from kernel crashes.
 1.14 28-Sep-2004  reinoud Note that point 32 (ddb output to msgbuf) is Work In Progress and is about
to be committed after more testing and cleanup/review.
 1.13 28-Sep-2004  reinoud Add an item to help developers without serial consoles.
 1.12 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.11 26-Aug-2002  scw branches: 1.11.6;
Another item on the TODO list:

Add support for cpus where sizeof(register_t) is not necessarily
the same as sizeof(void *). This is the case on SH5 using the
ILP32 ABI. On this cpu db_expr_t is, necessarily, 64-bits.
Unfortunately, in ILP32 mode, ddb will only display the low 32-bits
of any expression, including registers...
 1.10 15-Feb-2002  simonb branches: 1.10.8;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.9 05-Jan-2002  jhawk ddb(9)
 1.8 31-Dec-2001  jhawk Convenience variables (workXX) don't work, so don't document them.
 1.7 28-Dec-2000  jmc branches: 1.7.2; 1.7.4;
Add x/m option functionality
 1.6 10-Jul-2000  eeh branches: 1.6.2;
Update TODO list item #7.
 1.5 07-Jul-2000  jhawk Observe deficiency in printfs reporting symbol table problems
before we have a message buffer.
 1.4 05-Jul-2000  jhawk "set" now displays the name of the variable, old value, and new value,
just as "write" does.
 1.3 17-Jun-2000  jhawk branches: 1.3.4;
In db_command(), fix indentation and add a missing db_skip_to_eol() which
previously caused the next command following a ","-style repitition
to not be properly executed.
 1.2 07-Jun-2000  jhawk Fix long-standing inconsistency between manapage and code.
The "ditto" character is " (double-quote); not , (comma) as
indicated in the manpage; and not ' (single-quote) as indicated
in the man.old -style manpage from which the mdoc manpage was derived.

Some other versions of ddb use single-quote for this feature, and this
part of the code may change again in the near future, but the documentation
now affects reality now.
they
 1.1 06-Jun-2000  jhawk First cut at an outline of stuff to do.
 1.3.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 17-Jun-2000  minoura file TODO was added on branch minoura-xpg4dl on 2000-06-22 17:06:10 +0000
 1.6.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.6.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.2.1 10-Jul-2000  bouyer file TODO was added on branch thorpej_scsipi on 2000-11-20 18:08:46 +0000
 1.7.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.7.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.7.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.7.2.2 11-Jan-2002  nathanw More catchup.
 1.7.2.1 08-Jan-2002  nathanw Catch up to -current.
 1.10.8.1 29-Aug-2002  gehenna catch up with -current.
 1.11.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.6.4 19-Oct-2004  skrll Sync with HEAD
 1.11.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.6.1 03-Aug-2004  skrll Sync with HEAD
 1.17.176.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.27 01-Sep-2023  andvar s/unnsupported/unsupported/ in message.
 1.26 12-Sep-2019  ryo db_get_qvalue() with size=8 on 64bit arch returns incorrect value. fixed.
 1.25 12-Sep-2019  ryo changes of r1.39 was incomplete. only "examin/m" could handle 'q'.
added support 'r','x','z','d','u', and 'o' with 'q' modifier on 32bit arch.
 1.24 23-Aug-2019  kamil Avoids signedness bit shift in db_get_value()

Appease UBSan.
 1.23 04-Feb-2018  mrg branches: 1.23.4;
avoid leftshift of an unsigned value
 1.22 06-Jun-2015  matt Add support for 'q' qualifier for 64-bit values on examine and write.
Align data to long so that the MD parts can use aligned load/stores.
Don't use db_extend but use db_expr_t based expressions.
 1.21 28-Sep-2009  bsh branches: 1.21.22; 1.21.40;
quick fix for crash(8) build failure caused by my previous commit (rev
1.20).

The problem was reported Ty Sarna and Geoff Wing. Thanks.

XXX: I made #if too messy. split db_access.c into two files for
db_{get,put}_values and db_read_{int,ptr}?
 1.20 27-Sep-2009  bsh kgdb still needs db_{get,put}_value in ddb/db_access.c when SOFTWARE_SSTEP is defined in db_machdep.h.
 1.19 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.18 21-Feb-2007  thorpej branches: 1.18.42; 1.18.52; 1.18.58;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.17 15-Feb-2002  simonb branches: 1.17.32; 1.17.70;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.16 12-Nov-2001  lukem add RCSIDs
 1.15 17-Jan-2001  jdolecek branches: 1.15.2; 1.15.4;
constify a little
 1.14 30-Mar-2000  augustss Die, register, die!
 1.13 12-Apr-1999  pk branches: 1.13.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.12 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.11 13-Sep-1997  pk branches: 1.11.10;
Last loop variable type change causes undesirable non-terminating loops.
Change for-loop expressions to get the intended effect again.
 1.10 09-Sep-1997  mycroft Eliminate signed-unsigned comparisons.
 1.9 26-Jun-1997  thorpej branches: 1.9.4;
Use db_expr_t rather than int in a few strategic places to avoid
type-size problems.
 1.8 09-Oct-1994  mycroft Use BYTE_ORDER, not BYTE_[LM]SF.
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 31-Jan-1994  mycroft #if --> #ifdef
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.9.4.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.10.2 12-Apr-1999  pk branches: 1.11.10.2.2;
Pullup copyright text corrections.
 1.11.10.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.11.10.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.13.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.15.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.15.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.17.70.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.17.32.1 26-Feb-2007  yamt sync with head.
 1.18.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.42.2 11-Mar-2010  yamt sync with head
 1.18.42.1 04-May-2009  yamt sync with head.
 1.21.40.1 22-Sep-2015  skrll Sync with HEAD
 1.21.22.1 03-Dec-2017  jdolecek update from HEAD
 1.23.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14 12-Sep-2019  ryo changes of r1.39 was incomplete. only "examin/m" could handle 'q'.
added support 'r','x','z','d','u', and 'o' with 'q' modifier on 32bit arch.
 1.13 07-Mar-2009  ad branches: 1.13.64;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.12 21-Feb-2007  thorpej branches: 1.12.42; 1.12.52; 1.12.58;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.11 11-Dec-2005  christos branches: 1.11.26;
merge ktrace-lwp.
 1.10 01-Jun-2005  drochner branches: 1.10.2;
make the argument of db_write_bytes const (sorry for the signature change)
 1.9 15-Feb-2002  simonb branches: 1.9.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.8 12-Apr-1999  pk branches: 1.8.14; 1.8.16;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.7 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.6 09-Oct-1994  mycroft branches: 1.6.26;
Clean up #includes.
 1.5 09-Oct-1994  mycroft Add prototypes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 15-Feb-1994  mycroft Remove RCS logs.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.26.2 12-Apr-1999  pk branches: 1.6.26.2.2;
Pullup copyright text corrections.
 1.6.26.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.6.26.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.14.1 28-Feb-2002  nathanw Catch up to -current.
 1.9.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.1 26-Feb-2007  yamt sync with head.
 1.11.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.12.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.42.1 04-May-2009  yamt sync with head.
 1.13.64.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 27-Oct-2022  riastradh ddb(4): Declare extern db_active if _KMEMUSER too, not just DDB.

crash(8) is built with _KMEMUSER defined but DDB not defined except
for a few specific files or on MIPS.

Seems to me crash(8) should really be built with DDB defined in all
.c files but that leads to other fallout I'm not really inclined to
diagnose right now.
 1.1 26-Oct-2022  riastradh ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.
 1.2 31-May-2020  rin Revert introduction of db_alloc.h.

db_alloc() and friends are already provided in crash.c.
Sorry for confusing you...
 1.1 31-May-2020  rin Introduce db_alloc.h.

Provide db_alloc() and friends to userland, i.e., crash(8).
 1.42 11-Apr-2011  mrg obsolete DB_AOUT_SYMBOLS. however, we need to leave most of the code
in db_sym.[ch] as it is used by the elf version of crash(8).

i will be cleaning up the db_sym.c code in a follow up commit to avoid
having dead code compiled.
 1.41 22-Feb-2007  thorpej branches: 1.41.66; 1.41.72;
TRUE -> true, FALSE -> false
 1.40 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.39 16-Nov-2006  christos branches: 1.39.4;
__unused removal on arguments; approved by core.
 1.38 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.37 11-Dec-2005  christos branches: 1.37.20; 1.37.22;
merge ktrace-lwp.
 1.36 29-May-2005  christos branches: 1.36.2;
Add lots of const.
 1.35 17-May-2003  kristerw branches: 1.35.2;
Add a cast to make this build with -D__AUDIT__.
 1.34 24-Apr-2003  ragge Teach DDB to use ksyms instead of it's own symbol table management.
Note: For a.out kernels (beware!) DDB will still use the old stuff.
 1.33 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.32 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.31 12-Nov-2001  lukem add RCSIDs
 1.30 17-Jan-2001  jdolecek branches: 1.30.2; 1.30.4;
constify a little
 1.29 07-Jul-2000  jhawk s/preserving ... bytes of symbol table/using ... bytes of symbol table/

"preserving" implies that the data may be copied and might otherwise
be freed, and that other data in the symbol table or sections of
the kernel might be freed, however there is no mechanism for these
things to take place, so "using" is clearer.
 1.28 22-May-2000  jhawk Add a "sifting" command to ddb (named from the Sun OpenPROM command of
the same name); it searches the symbol table(s) for all symbols matching
a given substring, and prints.

Extremely useful for when you forget that critical symbol name.

Also, with /F support (cf. "ls -F") to print a char indicating the
symbol type.
 1.27 30-Mar-2000  augustss Die, register, die!
 1.26 15-Jun-1999  thorpej branches: 1.26.2;
Don't load the symbol table if it's corrupted.
 1.25 05-Jun-1999  pk Cast ptrdiff_t to long for printf purposes.
 1.24 29-Apr-1999  christos Don't go dereferencing pointers before verifying they are aligned.
 1.23 12-Apr-1999  pk Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.22 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.21 04-Dec-1998  thorpej branches: 1.21.4;
- Make the ddb_init() interface consistent for a.out and ELF.
- Allow DDB to run-time switch for a.out or ELF symbol table support.
 1.20 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.19 09-Jun-1998  tv branches: 1.19.2;
Change ddb_init() for a.out to provision for kernels which are not booted by
the current 'bootblock' method, like the Shark, which preloads and preformats
the symbol table right in the boot code.
 1.18 30-Nov-1997  drochner Clean up usage of printf() vs db_printf(): The diagnostic messages
when symbol tables are loaded don't belong to the user interaction,
their output lines should not be counted by ddb's builtin pager.
 1.17 26-Jun-1997  thorpej A few small changes to make it easier to support non-a.out symbol table
formats in DDB:
- Reverse the sense of the symbol format #ifdef... i.e. instead of
"#ifndef DB_NO_AOUT", use "#ifdef DB_AOUT_SYMBOLS". This is pulled
in from <machine/db_machdep.h>.
- Change the signature of X_db_sym_init(). Instead of int * and char *,
it now takes void *'s for the start and end of the symbol table.
- In X_db_sym_init(), check that the pointer to the beginning of
the symbol table is aligned.
- X_db_symbol_values() now takes a "db_symtab_t *symtab" argument.
 1.16 13-Oct-1996  christos backout previous kprintf changes
 1.15 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.14 27-Feb-1996  gwr Eliminate dependency on /usr/include/*
 1.13 05-Feb-1996  christos DDB prototype changes.
 1.12 09-Oct-1994  mycroft Add prototypes.
 1.11 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.10 03-Jun-1994  gwr Fix test for empty db_symtab on big-endian machines.
 1.9 18-Dec-1993  mycroft Canonicalize all #includes.
 1.8 18-Dec-1993  mycroft Canonicalize all #includes.
 1.7 29-Aug-1993  brezak branches: 1.7.2;
Changes for boot loading of symbols.
 1.6 02-Aug-1993  mycroft Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
 1.5 22-Jul-1993  brezak Remove read from file. Merge changes from mach DDB.
 1.4 10-Jul-1993  brezak Print symbolic args and line no's in stack traces.
 1.3 20-May-1993  cgd add explicit rcs id
 1.2 07-May-1993  cgd make SYMTAB_SPACE user-definable, as an "option"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.19.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.21.4.3 18-Jun-1999  perry pullup 1.25->1.26 (thorpej): Don't load the symbol table if it's corrupted
 1.21.4.2 12-Apr-1999  pk branches: 1.21.4.2.2; 1.21.4.2.4;
Pullup copyright text corrections.
 1.21.4.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.21.4.2.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.21.4.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.26.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.26.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.30.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.30.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.30.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.30.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.30.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.35.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.36.2.2 26-Feb-2007  yamt sync with head.
 1.36.2.1 30-Dec-2006  yamt sync with head.
 1.37.22.2 10-Dec-2006  yamt sync with head.
 1.37.22.1 22-Oct-2006  yamt sync with head
 1.37.20.1 18-Nov-2006  ad Sync with head.
 1.39.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.41.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.41.66.1 21-Apr-2011  rmind sync with head
 1.4 11-Apr-2011  mrg obsolete DB_AOUT_SYMBOLS. however, we need to leave most of the code
in db_sym.[ch] as it is used by the elf version of crash(8).

i will be cleaning up the db_sym.c code in a follow up commit to avoid
having dead code compiled.
 1.3 11-Dec-2005  christos branches: 1.3.98; 1.3.104;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 27-Feb-1996  gwr branches: 1.1.64;
Eliminate dependency on /usr/include/*
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.104.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.98.1 21-Apr-2011  rmind sync with head
 1.3 28-Mar-2022  riastradh sys: Split struct device into a private device_impl.h.

Include this only inside autoconf itself, and a few files that abuse
autoconf in ways I can't confidently make easy fixes for.

XXX kernel ABI change requires bump -- no more use of struct device
internals allowed, previously done by some drivers
 1.2 05-Mar-2018  mlelstv enums might be unsigned.
 1.1 04-Mar-2018  mlelstv Add command to print device list.
 1.1 04-Mar-2018  mlelstv Add command to print device list.
 1.26 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.25 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.24 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.23 16-Nov-2006  christos branches: 1.23.4;
__unused removal on arguments; approved by core.
 1.22 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21 02-Apr-2006  he branches: 1.21.8; 1.21.10;
Now that BKPT_SET takes two arguments, supply the second argument.
 1.20 11-Dec-2005  christos branches: 1.20.4; 1.20.6; 1.20.8; 1.20.10; 1.20.12;
merge ktrace-lwp.
 1.19 01-Jun-2005  drochner branches: 1.19.2;
more constification fallout
 1.18 29-Apr-2003  scw branches: 1.18.2;
Add a BKPT_ADDR() macro which gives MD code a chance to munge a
breakpoint address before it's used. Currently a no-op on all but sh5.

This is useful on sh5, for example, to mask off the instruction
type encoding in the bottom two address bits, and makes it possible
to do "db> break $rXX" instead of manually munging the address.
 1.17 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.16 12-Nov-2001  lukem add RCSIDs
 1.15 02-Jun-2001  chs branches: 1.15.2;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.14 26-Jun-2000  mrg branches: 1.14.2;
remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.13 25-May-2000  jhawk Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.12 30-Mar-2000  augustss Die, register, die!
 1.11 12-Apr-1999  pk branches: 1.11.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.10 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.9 13-Aug-1998  eeh branches: 1.9.6;
Merge paddr_t changes into the main branch.
 1.8 03-Apr-1998  pk branches: 1.8.2;
If `SOFTWARE_SSTEP' is defined then kgdb_stub.c needs the single-step
emulation in db_run.c:

- re-arrange `db_*_single_step()' and `db_*_temp_breakpoint()' -
which are only used in the `SOFTWARE_SSTEP' case - so these
are available to the KGDB code.
- make other code in db_run.c conditional on `DDB'.
 1.7 30-Mar-1996  christos Fix db_printf format specifications.
 1.6 05-Feb-1996  christos DDB prototype changes.
 1.5 09-Oct-1994  mycroft Add prototypes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.8.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.9.6.2 12-Apr-1999  pk branches: 1.9.6.2.2;
Pullup copyright text corrections.
 1.9.6.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.9.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.14.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.15.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.15.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.3 26-Feb-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.20.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.20.10.1 19-Apr-2006  elad sync with head.
 1.20.8.1 11-Apr-2006  yamt sync with head
 1.20.6.1 22-Apr-2006  simonb Sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.21.10.2 10-Dec-2006  yamt sync with head.
 1.21.10.1 22-Oct-2006  yamt sync with head
 1.21.8.1 18-Nov-2006  ad Sync with head.
 1.23.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.20 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.19 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.18 11-Dec-2005  christos branches: 1.18.26;
merge ktrace-lwp.
 1.17 01-Jun-2005  drochner branches: 1.17.2;
more constification fallout
 1.16 15-Feb-2002  simonb branches: 1.16.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.15 02-Jun-2001  chs branches: 1.15.2;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.14 27-Jun-2000  mrg branches: 1.14.2;
remove include of <vm/vm.h>
 1.13 12-Apr-1999  pk branches: 1.13.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.12 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.11 13-Aug-1998  eeh branches: 1.11.6;
Merge paddr_t changes into the main branch.
 1.10 03-Apr-1998  pk branches: 1.10.2;
If `SOFTWARE_SSTEP' is defined then kgdb_stub.c needs the single-step
emulation in db_run.c:

- re-arrange `db_*_single_step()' and `db_*_temp_breakpoint()' -
which are only used in the `SOFTWARE_SSTEP' case - so these
are available to the KGDB code.
- make other code in db_run.c conditional on `DDB'.
 1.9 26-Jun-1997  thorpej In the db_breakpoint_t, use a db_expr_t to store the original instruction,
not an int.
 1.8 05-Feb-1996  christos DDB prototype changes.
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 15-Feb-1994  mycroft Remove RCS logs.
 1.3 08-Jan-1994  mycroft Rearrange some #includes.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.11.6.2 12-Apr-1999  pk branches: 1.11.6.2.2;
Pullup copyright text corrections.
 1.11.6.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.11.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.15.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.16.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.1 26-Feb-2007  yamt sync with head.
 1.18.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.190 02-Nov-2023  martin Back out the following revisions on behalf of core:

sys/sys/lwp.h: revision 1.228
sys/sys/pipe.h: revision 1.40
sys/kern/uipc_socket.c: revision 1.306
sys/kern/kern_sleepq.c: revision 1.84
sys/rump/librump/rumpkern/locks_up.c: revision 1.13
sys/kern/sys_pipe.c: revision 1.165
usr.bin/fstat/fstat.c: revision 1.119
sys/rump/librump/rumpkern/locks.c: revision 1.87
sys/ddb/db_xxx.c: revision 1.78
sys/ddb/db_command.c: revision 1.187
sys/sys/condvar.h: revision 1.18
sys/ddb/db_interface.h: revision 1.42
sys/sys/socketvar.h: revision 1.166
sys/kern/uipc_syscalls.c: revision 1.209
sys/kern/kern_condvar.c: revision 1.60

Add cv_fdrestart() [...]
Use cv_fdrestart() to implement fo_restart.
Simplify/streamline pipes a little bit [...]

This changes have caused regressions and need to be debugged.
The cv_fdrestart() addition needs more discussion.
 1.189 15-Oct-2023  riastradh ddb: Don't restrict `show all tstiles' to wmesg `tstile'.

This is no longer the wmesg, as of last week -- now it's the name of
the underlying syncobj, like `mutex' or `rwlock'.
 1.188 15-Oct-2023  riastradh ddb: Constify db_syncobj_owner argument.

No need for it to be writable, and the actual type of the struct lwp
member is const.
 1.187 13-Oct-2023  ad Simplify/streamline pipes a little bit:

- Allocate only one struct pipe not two (no need to be bidirectional here).
- Then use f_flag (FREAD/FWRITE) to figure out what to do in the fileops.
- Never wake the other side or acquire long-term (I/O) lock unless needed.
- Whenever possible, defer wakeups until after locks have been released.
- Do some things locklessly in pipe_ioctl() and pipe_poll().

Some notable results:

- -30% latency on a 486DX2/66 doing 1 byte ping-pong within a single process.
- 2.5x less lock contention during "make cleandir" of src on a 48 CPU machine.
- 1.5x bandwith with 1kB messages on the same 48 CPU machine (8kB: same b/w).
 1.186 07-Oct-2023  ad Add some simple DDB show commands: condvar, selinfo, sleepq
 1.185 17-Jul-2023  riastradh ddb: Teach `show all tstiles' to show the type of each lock.
 1.184 11-Jul-2023  riastradh ddb: Cast pointer to uintptr_t first before db_expr_t.
 1.183 09-Jul-2023  riastradh ddb: New `show all tstiles' command.

Shows who's waiting for which locks and what the owner is up to.

XXX pullup-10
 1.182 25-May-2023  uwe ddb: PR kern/57435 - fix duplicate "show mount"

Bolivar cannot carry double. One of these commands should have been
"show mounts", cf. page/pages and a few others. While here fix the
function name to be db_show_all_mounts to conform to the pattern.
 1.181 28-Apr-2022  msaitoh branches: 1.181.4;
Remove 'a' modifier from "show vmem". It was removed in sbur_vmem.c rev. 1.55.
 1.180 20-Apr-2022  uwe ddb: guard invocation of db_cmd_on_enter properly.

db_command_loop - do not ignore the return value from setjmp used to
guard db_cmd_on_enter. We do not want to re-execute the enter command
if it fails. Note that "fails" includes e.g. aborting long output
from the enter command with "q" at the --db more-- prompt, which is
quite likely as the default enter command is "bt".

While here, don't even bother with the whole song and dance if the
enter command is not set.
 1.179 10-Oct-2021  thorpej Add a "show kqueue <addr>" command.
 1.178 21-Aug-2021  andvar fix mainly same typos as in my previous commit but outside sys/dev/dm.
 1.177 13-Aug-2021  andvar fix typos in words "pointer" and s/fram /frame/
 1.176 23-Feb-2021  mrg introduce DDB_END_CMD and replace more than 20 copies of the same
list of NULLs and 0. idea from rillig@.

all touched ports built, several booted.
 1.175 30-Oct-2020  skrll branches: 1.175.2;
Remove "also;"
 1.174 30-Oct-2020  skrll Add a "show fdt" ddb command
 1.173 30-Oct-2020  skrll Sort the db_show_cmd entries
 1.172 30-Oct-2020  skrll Put the 'added from all sub cmds' comment above the four commands that
were added as part of the work in r1.98
 1.171 30-Oct-2020  skrll Trailing whitespace
 1.170 13-Apr-2020  skrll Handle "no count" properly in db_kernhist_print_cmd
 1.169 10-Mar-2020  christos branches: 1.169.2;
Make the db_kernelonly() macro visible to all files and re-use it.
Register access is kernel only.
 1.168 09-Mar-2020  christos print a message for the commands crash does not support.
Allow "show lock"
 1.167 01-Jan-2020  thorpej - Introduce a new global kernel variable "shutting_down" to indicate that
the system is shutting down or rebooting.
- Set this global in a new function called kern_reboot(), which is currently
just a basic wrapper around cpu_reboot().
- Call kern_reboot() instead of cpu_reboot() almost everywhere; a few
places remain where it's still called directly, but those are in early
pre-main() machdep locations.

Eventually, all of the various cpu_reboot() functions should be re-factored
and common functionality moved to kern_reboot(), but that's for another day.
 1.166 27-Dec-2019  ad Redo the page allocator to perform better, especially on multi-core and
multi-socket systems. Proposed on tech-kern. While here:

- add rudimentary NUMA support - needs more work.
- remove now unused "listq" from vm_page.
 1.165 15-Dec-2019  joerg Teach ddb(4) about printing the full mount list.
 1.164 29-Sep-2019  uwe db_command - don't hide local static variable in the middle of other
local variable definitions. While here, get rid of the alignment of
variable names.
 1.163 29-Sep-2019  uwe db_command - make setting have_addr more clear.
Don't set it to false that it's already initialized to.
 1.162 29-Sep-2019  uwe db_command - make sure count is always initialized.
 1.161 22-Sep-2019  mrg fix "show kernhist".

set addr = 0 if we don't have_addr and avoid using random garbage in addr.
 1.160 17-Sep-2018  kre branches: 1.160.4;

When this file is used when not building the kernel (eg: /usr/sbin/crash)
make cnpollc() go away.
 1.159 16-Sep-2018  mrg call cnpollc(1) and cnpollc(0) around cngetc().

(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still). not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)
 1.158 15-Sep-2018  mrg call spl0() before cpu_reboot(), so that there's a chance that:
- interrupts can work afterwards
- this also means if IO stalls, serial break might work again.

this mimics how reboot(2) ends up calling cpu_reboot().
 1.157 13-Sep-2018  mrg always call lockdebug_dismiss() from DDB -- there are always some
minimal lockdebug checks in place, even without LOCKDEBUG.

adjust lockdebug_abort() to ignore problems after ld_panic is set
so that there's a chance of this working.

this fixes ddb 'reboot' on softiron od1000.
 1.156 13-Aug-2018  mrg extend the ddb "show kernhist" command. the synopsis is now:

show kernhist[/i] [addr[,count]]

the i modifier means display info instead of entries, and the count
restricts to the last count entries.

the count option is only supported for specified histories. it
could be extended but requires more logic than the single history,
as multiple histories are merged during display.
 1.155 12-Aug-2018  mrg add a lockdebug_dismiss() function for DDB to use that tells
lockdebug to avoid asserts. use it for the ddb "reboot"
command, so that it doesn't matter how ddb was entered, the
reboot not trigger mutex checks and not work.
 1.154 20-Jul-2018  msaitoh Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.
 1.153 19-Mar-2018  ozaki-r branches: 1.153.2;
ddb: rename "show lockstat" to "show lockstats" to avoid conflicting with lockstat(8)

Requested by mrg@
 1.152 16-Mar-2018  ozaki-r Don't pass a unset address to lockdebug_lock_print
 1.151 16-Mar-2018  ozaki-r Add a new command, show all locks, which shows information of active locks

The command shows information of all active (i.e., being held) locks that are
tracked through either of LWPs or CPUs by the LOCKDEBUG facility. The /t
modifier additionally shows a backtrace for each LWP additionally. This
feature is useful for debugging especially to analyze deadlocks.

The command is useful only if LOCKDEBUG is enabled.
 1.150 16-Mar-2018  ozaki-r Add a new command, show lockstat, which shows statistics of locks

Currently the command shows the number of allocated locks.

The command is useful only if LOCKDEBUG is enabled.
 1.149 04-Mar-2018  mlelstv branches: 1.149.2;
Add command to print device list.
 1.148 11-Jan-2017  joerg branches: 1.148.8;
Add ddb command to find a vnode by the address of its lock.
This makes it much easier to convert lockstat traces into understandable
data.
 1.147 13-Apr-2016  ozaki-r branches: 1.147.2;
ddb: rename show arptab to show routes

show arptab command of ddb is now inappropriate because it actually dumps
routes but arp entries aren't routes anymore. So rename it to show routes
and move the code from if_arp.c to route.c.

ok christos@
 1.146 06-Apr-2016  skrll Improve ddb(4) show kernhist

1) really prints all the histories merged together (rather than just the
"first" when no argument specified
2) dumps a single history when an argument is given, e.g.
"show kernhist usbhist"
3) uses db_printf correctly
 1.145 21-May-2015  mrg only call the on-enter commands if we're not recursing.
avoids having a fault in the on-enter commands repeating.
 1.144 08-Feb-2015  christos we can use show callout now from crash
 1.143 19-Oct-2013  christos branches: 1.143.6;
fix userland build, by moving all the unused stuff inside ifdef _KERNEL
 1.142 06-Jan-2013  christos branches: 1.142.2;
remove the new command not the old one.
 1.141 06-Jan-2013  christos remove previous, dmesg just works.
 1.140 06-Jan-2013  christos Add "show dmesg" that prints the contents of the message buffer.
 1.139 05-Jan-2013  christos Add "show panic" that shows the current panic string. two ports had it, and
it could be easily made MI.
 1.138 28-Apr-2012  rmind branches: 1.138.2;
Remove MALLOC_DEBUG and MALLOCLOG, which is dead code after malloc(9) move
to kmem(9). Note: kmem(9) has debugging facilities under DEBUG/DIAGNOSTIC.
However, expensive kmguard and debug_freecheck have to be enabled manually.
 1.137 13-Nov-2011  mrg branches: 1.137.4;
set panicstr to "reboot forced via kernel debugger" when rebooting
from ddb, similar to how sync from ddb works.

this avoids various asserts and other issues during ddb reboot.
 1.136 17-May-2011  mrg branches: 1.136.4;
move and rename the uvm history code out of uvm_stat to "kernhist".

rename "UVMHIST" option to enable the uvm histories.

TODO:
- make UVMHIST properly depend upon KERNHIST
- enable dynamic registration of histories. this is mostly just
allocating something in a bitmap, and is only for viewing multiple
histories in a merged form.


tested on amd64 and sparc64.
 1.135 10-Apr-2011  christos Add:
usage: show proc [/a] [/p] address|pid
/a == argument is an address of any lwp
/p == argument is a pid [default]
From: Vladimir Kirillov proger at wilab dot org dot ua
 1.134 13-Sep-2010  drochner branches: 1.134.2;
fix extern/static inconsistency
 1.133 19-Jul-2009  rmind branches: 1.133.2; 1.133.4;
Add #ifdef MQUEUE for db_show_mqueue_cmd().

XXX: Wrong. DDB should be dynamic, modular, etc.
 1.132 05-Jun-2009  mrg extend 'show event' to take /i /t and /m modifiers, to select interrupt,
trap or misc event types. you can mix them with /f as well, to show all
including zero events for traps and misc, "show event/ftm"
 1.131 21-Mar-2009  ad Make 'show event', 'dmesg' work with crash(8).
XXX dmesg fails exactly the same way as /sbin/dmesg.
 1.130 11-Mar-2009  nakayama Avoid "warning: cast from pointer to integer of different size"
on 32-bit sparc64 kernels.
 1.129 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.128 01-Mar-2009  haad Do not set last_count to zero after every db_command function call it is
static variable. This should fix PR 40712.
 1.127 18-Feb-2009  yamt - fix vmem unittest. rename VMEM_DEBUG so that it won't be abused again.
- reimplement vmem sanity checks with less code duplication.
- reimplement ddb vmem-related commands in a more consistent ways.
remove automatic whatis.
 1.126 05-Jan-2009  haad branches: 1.126.2;
Fix my bug introduced in rev 1.98 of db_command.c where command prefix
not ambiguous in one table was choosed even if it was ambiguous in another
table in same list. Also apply more KNF rules.

Patch was supplied by uwe@.
 1.125 07-Dec-2008  cegger ddb: new 'show vmem' and 'show all vmems' commands.
Useful to inspect vmem(9) structures.
 1.124 25-Nov-2008  nakayama Make DDB shows right register values on 32-bit sparc64 kernels.
- define db_expr_t as int64_t.
- %gsr is 32-bit, so use db_sparc_intop.
- sync arguments with function prototype.
- ansify.
 1.123 25-Nov-2008  ad Add some basic DDB stuff for modules.
 1.122 16-Nov-2008  pooka more <sys/buf.h> police
 1.121 14-Nov-2008  ad +ifdef AIO

XXX ddb needs a way to register commands at runtime!
 1.120 03-Oct-2008  rmind branches: 1.120.2; 1.120.4;
Replace more intptr_t to uintptr_t when casting VA.
 1.119 29-Sep-2008  rmind - Fix message queue permissions problems.
- Rake into account umask when creating mqueue.
- Restore DDB command, which was accidentally lost (hi martin).
- Misc.
 1.118 08-Aug-2008  skrll Make "show uvmhist" available to all arches (not just sparc*) in ddb.
 1.117 10-Jul-2008  blymn Add a show files command that prints the vnodes associated with a
given struct proc and, if LOCKDEBUG is built in, the lock status of
the uvmobject.
 1.116 10-Jul-2008  blymn Whitespace clean up.
 1.115 28-Apr-2008  martin branches: 1.115.2; 1.115.4; 1.115.6;
Remove clause 3 and 4 from TNF licenses
 1.114 21-Feb-2008  uwe branches: 1.114.6; 1.114.8; 1.114.10;
Fix help string for "w" - it is "write" not "watch".
 1.113 02-Feb-2008  martin When doing a reboot from ddb, set panicstr, so that later LOCKDEBUG checks
show the same mercy as with a real panic.
 1.112 13-Dec-2007  yamt add ddb "whatis" command. inspired from solaris ::whatis dcmd.
 1.111 14-Nov-2007  martin branches: 1.111.2; 1.111.4; 1.111.6;
Add a missing "else". Should finally fix PR kern/37110.
 1.110 22-Oct-2007  martin branches: 1.110.2;
Pacify some gcc uninitialized warnings at -O3
 1.109 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.108 14-Oct-2007  uwe branches: 1.108.2;
db_cmd_search: When we compare names we'd better stop at the nul byte.
Don't flip-flop between found and ambiguous. (hi, martin!)
 1.107 12-Oct-2007  martin Fix command name matching, avoid jumps to null function pointers and
some minor cosmetics.
 1.106 08-Oct-2007  martin Do another setjmp right before entering the command loop, we do not want
to execute the on-enter commands again on errors.
 1.105 02-Oct-2007  martin Some cleanup:
- When registering command tables, make sure the builtin commands are
already registered
- Make the command table entry structure private
- Do not bother to store the number of commands in a table, we can quickly
calc that if needed.
 1.104 01-Oct-2007  martin No need to db_init_commands() early any more - it will happen on first
entry to ddb.
 1.103 01-Oct-2007  martin Special case the initialization of builtin command tables to avoid using
malloc. Fixes PR kern/37042.
Allow "mach" commands registered by LKMs even if there is no builtin
mach command for the arch.
 1.102 23-Sep-2007  martin Minor clenaup - db_cmd_loop_done is a bool nowadays, so use true/false
instead of 0/1.
Also make db_init_commands() non-static.
 1.101 23-Sep-2007  martin Simplify the "tables are already setup" test.
Print a message on unknown commands (as we used to do before) and get rid
of the now unused macro previously used for that.
 1.100 23-Sep-2007  martin Fix build for archs w/o DB_MACHINE_COMMANDS.
Patch from KIYOHARA Takashi.
 1.99 23-Sep-2007  martin branches: 1.99.2;
Add missing argument - fixes compilation if KGDB is defined.
 1.98 22-Sep-2007  martin Add a new option DDB_VERBOSE_HELP that adds online help to ddb.
From Adam Hamsik.
Minor modifications by me, all bugs are probably mine.
 1.97 07-Sep-2007  rmind Implementation of POSIX message queues.

Reviewed by: <ad>, <tech-kern>
 1.96 30-Apr-2007  rmind branches: 1.96.2; 1.96.6; 1.96.8;
Import of POSIX Asynchronous I/O.
Seems to be quite stable. Some work still left to do.

Please note, that syscalls are not yet MP-safe, because
of the file and vnode subsystems.

Reviewed by: <tech-kern>, <ad>
 1.95 22-Feb-2007  thorpej branches: 1.95.4; 1.95.6;
TRUE -> true, FALSE -> false
 1.94 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.93 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.92 09-Feb-2007  ad branches: 1.92.2;
Merge newlock2 to head.
 1.91 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.90 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.89 05-Sep-2006  uwe branches: 1.89.2; 1.89.4;
ANSIfy db_error.
 1.88 14-May-2006  elad integrate kauth.
 1.87 14-May-2006  he Move declaration up ahead of active code in the function, so that
this can be built again with gcc 2.95.3, as used by vax.
 1.86 10-May-2006  mrg quell GCC 4.1 uninitialised variable warnings.

XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
 1.85 14-Apr-2006  christos Coverity CID 1094: Protect against NULL deref.
 1.84 19-Feb-2006  bjh21 branches: 1.84.2; 1.84.4; 1.84.6;
Add a "show all pages" command to DDB which prints one line per physical
page in the system. Useful for getting some idea where all your memory's
gone, at least on a sufficiently small system.
 1.83 24-Jan-2006  yamt branches: 1.83.2; 1.83.4;
add ddb "sh mbuf" command.
 1.82 01-Dec-2005  yamt branches: 1.82.2;
add "show all pools" command for ddb.
 1.81 27-Nov-2005  yamt make DDB_COMMANDONENTER sysctl. (ddb.commandonenter)
suggested by Christos Zoulas.
 1.80 26-Nov-2005  yamt add a new option DDB_COMMANDONENTER.
which can be useful for eg. broken console input.
 1.79 01-Jun-2005  drochner branches: 1.79.2; 1.79.8;
more constification fallout
 1.78 29-May-2005  christos Add lots of const.
 1.77 29-Apr-2005  yamt move decl of db_machine_command_table from db_interface.h to db_command.c
to avoid an array of incomplete type. found by gcc4.
 1.76 27-Apr-2004  atatat branches: 1.76.4;
That's not supposed to be there. Sorry.
 1.75 24-Mar-2004  atatat branches: 1.75.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.74 18-Nov-2003  dbj add "show mount" ddb command
 1.73 10-Oct-2003  chs add "b" as a synonym for "break", since someone added "bt"
and made "b" an ambiguous prefix.
 1.72 20-Sep-2003  thorpej Add a "show sched_qs" command to dump the run queues. Format is:
1 pid.lid (p_comm)
pid.lid (p_comm)
...

If a queue has procs, but no sched_whichqs bit, it shows:
!1 pid.lid (p_comm)
 1.71 16-May-2003  itojun branches: 1.71.2;
switch to use strlcpy() from libkern.
 1.70 15-May-2003  atatat (1) Don't print the message buffer (via ddb's dmesg command) if the
message buffer has not yet been set up, mimicking code from the top of
the sysctl routine for retrieving the message buffer.

(2) Add a /l modifier to the trace command. This makes it print the
backtrace using printf() instead of db_printf(), which has the nice
side-effect of also putting it into the message buffer. A kernel with
ddb in it but disabled (ie, ddb.onpanic set to zero) will print a
backtrace (which ends up in the message buffer) before dumping (or
not, depending on the value of kern.dump_on_panic) and rebooting, but
if ddb is not disabled, the backtrace is not printed, and there's no
way to get it to display a backtrace such that you can retrieve it
after the dump. The backtrace printed by gdb is sometimes a little
different.

(3) Documentation for the above.
 1.69 28-Apr-2003  briggs Add a rudimentary 'trap to kgdb' command if KGDB is defined. This allows
systems with only one serial port for console, etc., to have at least some
basic access to remote-kgdb-over-serial, even if it is a bit awkward.
 1.68 13-Feb-2003  jmc Add a synonym for trace - 'bt' and document it
 1.67 20-Jan-2003  simonb Remove variable that is only assigned too but not referenced.
 1.66 26-Aug-2002  scw Casting from a pointer, to a db_expr_t, has to go via an intptr_t.
(db_expr_t == int64_t on sh5, for example).
 1.65 15-Feb-2002  simonb branches: 1.65.8;
Add a "show event" ddb command to show the event counters.
 1.64 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.63 12-Nov-2001  lukem add RCSIDs
 1.62 17-Aug-2001  thorpej Add `show malloc' to dump the internal state of the MALLOC_DEBUG code.
 1.61 31-Jul-2001  atatat Add an easy way to dump the message buffer from ddb.
 1.60 03-Jun-2001  matt branches: 1.60.2;
Default to kernel_map if no addr is available.
 1.59 02-Jun-2001  chs replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.58 30-May-2001  mrg use _KERNEL_OPT
 1.57 11-Feb-2001  jhawk branches: 1.57.2;
alphabetize db_command tables
 1.56 24-Jan-2001  jdolecek make db_command_table[] const; since there is no way to dynamically extend
or modify the table at the moment, there is no functionality lost.
See also the discussion on tech-kern (Subject: 'machine' DDB command).
 1.55 22-Jan-2001  jdolecek Require the machine-dependant DDB commands to be in db_machine_command_table[]
and link it directly to db_command_table[] so that it's not necessary
to do this at runtime. Make db_machine_command_table[] const on all ports.
g/c now unneded stuff, like db_machine_commands_install(), db_machine_init()

Patch written by enami.
 1.54 18-Jan-2001  enami db_command_table needs to be writable at least when DB_MACHINE_COMMANDS
is defined.
 1.53 17-Jan-2001  jdolecek constify a little
 1.52 28-Nov-2000  eeh Restore the top level `callout' command.
 1.51 24-Nov-2000  chs add ddb commands "show uvmexp" and "show ncache".
the former used to be "call uvm_dump", the latter is new.
 1.50 08-Jul-2000  sommerfeld printf format safety
 1.49 27-Jun-2000  mrg remove include of <vm/vm.h>
 1.48 17-Jun-2000  jhawk In db_command(), fix indentation and add a missing db_skip_to_eol() which
previously caused the next command following a ","-style repitition
to not be properly executed.
 1.47 10-Jun-2000  sommerfeld In the "reboot" and (badly misnamed) "sync" commands, clear db_recover
before calling cpu_reboot() (which never returns) so we can debug
faults occurring in cpu_reboot().
 1.46 08-Jun-2000  jhawk Only define db_show_arptab if NARP>1;
pointed out by cgd in kern/10314
 1.45 06-Jun-2000  jhawk Stop using DDB-specific "%n" kprintf() format specifier. This was
important as db_sym() can be called through printf() rather than
db_printf(), causing a trap as the standard %n usage is invoked.

The DDB-specific %n code should disappear from subr_prf.c soon...
 1.44 28-May-2000  sommerfeld Change printing of cpu number in the prompt in the MULTIPROCESSOR case
 1.43 26-May-2000  jhawk branches: 1.43.2;
Rename the machine-specific stack trace printing functions
from db_stack_trace_cmd() to db_stack_trace_print(),
and add an additional argument, a function pointer for an
output routine (i.e. printf() or db_printf()).

Add db_stack_trace_cmd() in db_command.[ch], calling
db_stack_trace_print() with db_printf() as the printer.

Move count==-1 special handling from db_stack_trace_print() [nee
db_stack_trace_cmd()] to db_stack_trace_cmd() [nascent here].

Again, I'm unable to test compilation on all affected platforms,
so advance apologies for potential brokenness.
 1.42 23-May-2000  thorpej Fix a printf format.
 1.41 22-May-2000  jhawk Add a "sifting" command to ddb (named from the Sun OpenPROM command of
the same name); it searches the symbol table(s) for all symbols matching
a given substring, and prints.

Extremely useful for when you forget that critical symbol name.

Also, with /F support (cf. "ls -F") to print a char indicating the
symbol type.
 1.40 20-May-2000  jhawk Install "show arptab" (db_show_arptab) in the ddb command tree.
Move prototype from netinet/if_inarp.h to ddb/db_interface.h.
Change function to have standard ddb parameters (though they're
ignored).
 1.39 15-May-2000  jhawk "p" should be an alias for "print", and was until "ps" was added.
Now it is, again.
 1.38 13-Apr-2000  jhawk From kern/9569.
Preserve ddb's idea of "count" from one command to the next if
repeating a command via hitting newline.
 1.37 11-Apr-2000  chs actually add buf- and vnode-printing commands to the table.
 1.36 10-Apr-2000  chs add ddb commands for printing vnodes and bufs.
 1.35 30-Mar-2000  augustss Die, register, die!
 1.34 21-Feb-2000  sommerfeld On MP, print cpu number prior to prompt
 1.33 02-Nov-1999  jdolecek db_cmd_list(): variable ``width'' might have be used uninitialized, initialize
it to 0
 1.32 28-Oct-1999  lukem - change db_cmd_list() to list commands vertically rather than horizontally
- sort entries in the various command tables, so that the `help' lists
are easier to use. this included hacking db_machine_commands_install()
to search for the "machine" entry to change the `more cmds' pointer,
rather than assuming it was the first entry
- add a `sync' command, which is effectively `reboot 0x100'.
- remove db_help_cmd(); it was unused (and was almost a duplicate of
db_cmd_list()).
- move some extern decls to db_output.h, since they're used in more than one
place now
- rename NEXT_TAB to DB_NEXT_TAB and move to db_output.h
 1.31 10-May-1999  thorpej branches: 1.31.2; 1.31.4; 1.31.6;
Improve the pool allocator's diagnostic helpers, adding the ability to
log on a per-pool basis, reentrancy checking, and dumping various pool
information from DDB.
 1.30 12-Apr-1999  pk Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.29 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.28 24-Mar-1999  mrg branches: 1.28.2;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.27 05-Jul-1998  tron branches: 1.27.4;
Include required "opt_ddb.h" header file.
 1.26 04-Jul-1998  jonathan defopt DDB.
 1.25 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.24 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly. :-)
 1.23 11-Sep-1997  scottr Add a 'reboot' command with a single parameter specifying the boot flags.
 1.22 07-May-1997  gwr branches: 1.22.4;
Add a "kill" command that calls db_kill_proc().
 1.21 03-Feb-1997  mycroft db_expr_t became a long.
 1.20 30-Mar-1996  christos Fix db_printf format specifications.
 1.19 13-Mar-1996  christos Kernel version of longjmp() does not take the return value of setjmp() as
an argument. setjmp() always returns 1.
 1.18 07-Mar-1996  christos Bring setjmp/longjmp prototypes into scope.
 1.17 13-Feb-1996  gwr eliminate setjmp.h
 1.16 05-Feb-1996  christos DDB prototype changes.
 1.15 26-Oct-1995  gwr Need to include <vm/vm.h>
 1.14 16-Oct-1995  mycroft Fix nits pointed out by GCC 2.7.
 1.13 09-Oct-1994  mycroft Clean up #includes.
 1.12 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.11 27-Apr-1994  pk Add "show callout".
 1.10 23-Mar-1994  pk struct command => struct db_command, and define it in db_command.h
 1.9 09-Jan-1994  mycroft Pointers to arrays behave oddly in C...
 1.8 09-Jan-1994  mycroft Push and pop db_recover for error handling, so we can set up temporary catch
points easily. (Alluded to by m68k code, but not implemented yet for some
reason.)
 1.7 18-Dec-1993  mycroft Canonicalize all #includes.
 1.6 13-Sep-1993  brezak Call vm_map_print and vm_object_print with func ptr to db_printf. Add DDB_MACHINE_COMMANDS from Mach 3.0 version.
 1.5 02-Aug-1993  mycroft branches: 1.5.2;
Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
 1.4 15-Jul-1993  brezak Add 'ps' command. Add -more- pager to output from Mach ddb.
 1.3 20-May-1993  cgd add explicit rcs id
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.2 14-Nov-1993  mycroft Canonicalize all #includes.
 1.5.2.1 14-Sep-1993  mycroft Incorporate changes from main branch.
 1.22.4.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.27.4.1 09-Nov-1998  chs initial snapshot. lots left to do.
 1.28.2.2 12-Apr-1999  pk branches: 1.28.2.2.2;
Pullup copyright text corrections.
 1.28.2.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.28.2.2.2.2 21-Jun-1999  thorpej Sync w/ -current.
 1.28.2.2.2.1 07-Jun-1999  chs merge everything from chs-ubc branch.
 1.31.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.31.4.1 15-Nov-1999  fvdl Sync with -current
 1.31.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.31.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.31.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.31.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.43.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.57.2.5 27-Aug-2002  nathanw Catch up to -current.
 1.57.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.57.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.57.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.57.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.60.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.60.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.60.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.60.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.60.2.1 03-Aug-2001  lukem update to -current
 1.65.8.1 29-Aug-2002  gehenna catch up with -current.
 1.71.2.5 11-Dec-2005  christos Sync with head.
 1.71.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.71.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.71.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.71.2.1 03-Aug-2004  skrll Sync with HEAD
 1.75.2.1 29-Apr-2004  jmc Pullup rev 1.76 (requested by atatat in ticket #207)

Not supposed to be there
 1.76.4.1 29-Apr-2005  kent sync with -current
 1.79.8.1 29-Nov-2005  yamt sync with head.
 1.79.2.9 27-Feb-2008  yamt sync with head.
 1.79.2.8 04-Feb-2008  yamt sync with head.
 1.79.2.7 21-Jan-2008  yamt sync with head
 1.79.2.6 15-Nov-2007  yamt sync with head.
 1.79.2.5 27-Oct-2007  yamt sync with head.
 1.79.2.4 03-Sep-2007  yamt sync with head.
 1.79.2.3 26-Feb-2007  yamt sync with head.
 1.79.2.2 30-Dec-2006  yamt sync with head.
 1.79.2.1 21-Jun-2006  yamt sync with head.
 1.82.2.2 01-Mar-2006  yamt sync with head.
 1.82.2.1 01-Feb-2006  yamt sync with head.
 1.83.4.2 01-Jun-2006  kardel Sync with head.
 1.83.4.1 22-Apr-2006  simonb Sync with head.
 1.83.2.1 09-Sep-2006  rpaulo sync with head
 1.84.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.84.4.2 11-May-2006  elad sync with head
 1.84.4.1 19-Apr-2006  elad sync with head.
 1.84.2.2 14-Sep-2006  yamt sync with head.
 1.84.2.1 24-May-2006  yamt sync with head.
 1.89.4.2 10-Dec-2006  yamt sync with head.
 1.89.4.1 22-Oct-2006  yamt sync with head
 1.89.2.2 05-Feb-2007  ad - Dump the contents of a lock's turnstile when an error is detected.
- Add a 'show lock' command to DDB.
 1.89.2.1 18-Nov-2006  ad Sync with head.
 1.92.2.2 07-May-2007  yamt sync with head.
 1.92.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.95.6.1 11-Jul-2007  mjf Sync with head.
 1.95.4.5 23-Oct-2007  ad Sync with head.
 1.95.4.4 17-Oct-2007  ad Sync with head (fix ddb).
 1.95.4.3 12-Oct-2007  ad Sync with head.
 1.95.4.2 09-Oct-2007  ad Sync with head.
 1.95.4.1 08-Jun-2007  ad Sync with head.
 1.96.8.3 23-Mar-2008  matt sync with HEAD
 1.96.8.2 09-Jan-2008  matt sync with HEAD
 1.96.8.1 06-Nov-2007  matt sync with HEAD
 1.96.6.3 14-Nov-2007  joerg Sync with HEAD.
 1.96.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.96.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.96.2.1 10-Sep-2007  skrll Sync with HEAD.
 1.99.2.2 14-Oct-2007  yamt sync with head.
 1.99.2.1 06-Oct-2007  yamt sync with head.
 1.108.2.2 18-Nov-2007  bouyer Sync with HEAD
 1.108.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.110.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.110.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.110.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.111.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.111.4.1 13-Dec-2007  yamt sync with head.
 1.111.2.1 26-Dec-2007  ad Sync with head.
 1.114.10.5 09-Oct-2010  yamt sync with head
 1.114.10.4 19-Aug-2009  yamt sync with head.
 1.114.10.3 20-Jun-2009  yamt sync with head
 1.114.10.2 04-May-2009  yamt sync with head.
 1.114.10.1 16-May-2008  yamt sync with head.
 1.114.8.1 18-May-2008  yamt sync with head.
 1.114.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.114.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.114.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.114.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.114.6.1 21-Feb-2008  mjf file db_command.c was added on branch mjf-devfs2 on 2008-06-02 13:23:10 +0000
 1.115.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.115.6.1 19-Oct-2008  haad Sync with HEAD.
 1.115.4.1 18-Jul-2008  simonb Sync with head.
 1.115.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.115.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.120.4.2 09-Jan-2009  snj Pull up following revision(s) (requested by haad in ticket #241):
sys/ddb/db_command.c: revision 1.126
sys/ddb/db_command.h: revision 1.34
Fix my bug introduced in rev 1.98 of db_command.c where command prefix
not ambiguous in one table was choosed even if it was ambiguous in
another table in same list. Also apply more KNF rules.
Patch was supplied by uwe@.
 1.120.4.1 27-Nov-2008  snj Pull up following revision(s) (requested by nakayama in ticket #131):
sys/arch/sparc64/sparc64/db_disasm.c: revision 1.15
sys/arch/sparc64/sparc64/db_trace.c: revision 1.41
sys/arch/sparc64/sparc64/db_interface.c: revision 1.113
sys/ddb/db_command.c: revision 1.124
sys/arch/sparc64/include/db_machdep.h: revision 1.26
Make DDB shows right register values on 32-bit sparc64 kernels.
- define db_expr_t as int64_t.
- %gsr is 32-bit, so use db_sparc_intop.
- sync arguments with function prototype.
- ansify.
 1.120.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.120.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.120.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.126.2.2 23-Jul-2009  jym Sync with HEAD.
 1.126.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.133.4.3 31-May-2011  rmind sync with head
 1.133.4.2 21-Apr-2011  rmind sync with head
 1.133.4.1 05-Mar-2011  rmind sync with head
 1.133.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.134.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.136.4.4 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.136.4.3 23-Jan-2013  yamt sync with head
 1.136.4.2 23-May-2012  yamt sync with head.
 1.136.4.1 17-Apr-2012  yamt sync with head
 1.137.4.1 29-Apr-2012  mrg sync to latest -current.
 1.138.2.3 03-Dec-2017  jdolecek update from HEAD
 1.138.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.138.2.1 25-Feb-2013  tls resync with head
 1.142.2.1 18-May-2014  rmind sync with head
 1.143.6.5 05-Feb-2017  skrll Sync with HEAD
 1.143.6.4 22-Apr-2016  skrll Sync with HEAD
 1.143.6.3 06-Apr-2016  skrll Pull across ddb(4) show kernhist updates from HEAD
 1.143.6.2 06-Jun-2015  skrll Sync with HEAD
 1.143.6.1 06-Apr-2015  skrll Sync with HEAD
 1.147.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.148.8.5 27-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1037):

sys/dev/usb/uhub.c: revision 1.139
sys/external/bsd/dwc2/dwc2.c: revision 1.55
sys/ddb/db_output.c: revision 1.34
sys/ddb/db_command.c: revision 1.160
sys/dev/usb/ehci.c: revision 1.264
sys/dev/usb/xhci.c: revision 1.99
sys/dev/usb/ehci.c: revision 1.265
sys/kern/subr_userconf.c: revision 1.27
sys/dev/usb/ehcivar.h: revision 1.46
sys/dev/usb/ohci.c: revision 1.287
sys/dev/usb/uhci.c: revision 1.284
sys/dev/usb/usbdi.c: revision 1.178
sys/dev/usb/usb.c: revision 1.172
sys/dev/pci/xhci_pci.c: revision 1.14
sys/dev/usb/usb.c: revision 1.173
sys/dev/usb/usb.c: revision 1.174
share/man/man4/usb.4: revision 1.110
sys/ddb/db_command.c: revision 1.159
sys/dev/usb/usb_subr.c: revision 1.227
sys/dev/usb/uhcivar.h: revision 1.56
(all via patch)

consolidate the handling of polling across HC drivers, and generic USB:
- don't take mutexes if polling
- normalise the code across all drivers
- add some not yet code to block discovery to/from polling
- minor CSE
- adjust comment for usbd_set_polling() to reality now i properly
understand what it is used for and why.

this, with a hack to make RB_ASKNAME to wait 5 seconds allows boot -a
work with USB keyboards. there are still multiple issues remaining:
- discovery and polling need to be mutually exclusive
- attachment of ukbd and wskbd is not handled by config_pending, and
the 5 second delay isn't going to always be enough.

call cnpollc(1) and cnpollc(0) around cngetc().
(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still). not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)


When this file is used when not building the kernel (eg: /usr/sbin/crash)
make cnpollc() go away.


reorder some struct members to remove holes.


add config_pending usage to uhub and general USB device attachment.
- call config_pending_incr() and config_pending_decr() around attaching
devices against "usbdevif" attribute.

uhub:
- convert sc_explorepending and sc_running to bool. add new sc_first_explore.
- call config_pending_incr() at the start of uhub_attach(). dropped in
uhub_explore(), if this is the first explore.


implement a gross hack to fix "boot -a" on systems with usb keyboards on
systems with ehci handover to uhci (and maybe ohci), and fix a similar
problem for "boot -s".

there is effort to ensure that all devices attached via USB are probed
before RB_ASKNAME or RB_SINGLE attempts to ask any questions on the console,
and largely this works, often by chance, today, for USB disks and root.
i've recently pushed this more into uhub and general USB device attachment
as well, and kept a config_pending reference across the first explore of
a bus. these fix many issues with directly attached hubs.

however, on systems where devices connected to ehci ports are handed over
to a companion uhci or ohci port, it may not be the first, or even second,
bus explore that finds the device finally before attachment, and at this
point all config_pending references are dropped.

there is no direct communication between drivers, the potentials are
looked up but their device_t is only used for generic things like the name,
so informing the correct companion to expect a device and deal with the
config_pending references is not possible without some fairly ugly layer
violations or multi-level callbacks (eg, we have "ehci0", and usually an
the relevant companion, eg, "uhci2", but it is the uhub that uhci2 has
attached that will deal with the device attachment.)

with the above fixes to generic USB code, the disown happens during the
first explore. the hack works by, at this point, checking if (a) root
is not mounted, (b) single user or ask name are set, and (c) if the hack
as not been triggered already. if all 3 conditions are true, then a
config_pending_incr() is called and a callback is triggered for (default)
5 seconds to call config_pending_decr(). ehci detach pauses waiting for
this callback if scheduled.

this allows enough time for the uhub and the ukbd/wskbd to attach before
the RK_ASKROOT prompts appear. testing shows it takes between 1.5 and
2 seconds for the keyboard to appear after the disown occurs.

Index: dev/usb/ehcivar.c
- new sc_compcallout, sc_compcallout, sc_complock, and a state for th
handover hack.

Index: dev/usb/ehci.c
ehci_init():
- use aprint_normal_dev() instead of manual device_xname().
- initialise sc_compcallout, sc_compcallout, sc_complock, and sc_comp_state.
ehci_detach():
- if there are companion controllers, tear own the above, including waiting
if there is a callback scheduled.
ehci_disown_callback():
- new callout to call config_pending_decr() in the the future.
schedule this ca
ehci_disown_sched_callback():
- if booting to single user or asking names, call config_pending_incr() and
schedule the callout above, default 5 second delay.
ehci_disown():
- if disowning a port call ehci_disown_sched_callback().
deal with partial attach failures in usb_attach vs usb_detach aka PR 53598.
- make sure xhci's sc->sc_ios is NULL if failure happens.
- rearrange usb_attach() / usb_doattach() to make it simpler to clean up.
- move usb_async_intr softint into usb_once_init(). previously, each USB
controller would start a new one, and leave the old one leaked.
- handle controller interrupts without a bus attached


remove usb(4)'s "flags 1" code. it has been dead for a while,
as it runs during the interrupts part of configuration now,
and all the devices try attach as early as possible, including
any root or boot required disk or keyboard device, which is
what this flag was for.
 1.148.8.4 23-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1024):

sys/ddb/db_command.c: revision 1.157
sys/ddb/db_command.c: revision 1.158
sys/kern/subr_lockdebug.c: revision 1.67

always call lockdebug_dismiss() from DDB -- there are always some
minimal lockdebug checks in place, even without LOCKDEBUG.

adjust lockdebug_abort() to ignore problems after ld_panic is set

so that there's a chance of this working.
this fixes ddb 'reboot' on softiron od1000.

call spl0() before cpu_reboot(), so that there's a chance that:
- interrupts can work afterwards
- this also means if IO stalls, serial break might work again.

this mimics how reboot(2) ends up calling cpu_reboot().
 1.148.8.3 07-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1013):

sys/sys/lockdebug.h: revision 1.20
sys/ddb/db_command.c: revision 1.155
sys/kern/subr_lockdebug.c: revision 1.65

add a lockdebug_dismiss() function for DDB to use that tells
lockdebug to avoid asserts. use it for the ddb "reboot"
command, so that it doesn't matter how ddb was entered, the
reboot not trigger mutex checks and not work.
 1.148.8.2 31-Jul-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #954):

sys/sys/socketvar.h: revision 1.157
share/man/man4/ddb.4: revision 1.180
share/man/man4/ddb.4: revision 1.181
sys/kern/uipc_socket2.c: revision 1.131
sys/ddb/db_command.c: revision 1.154

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.
Improve wording.
 1.148.8.1 02-Apr-2018  martin Pull up following revision(s) (requested by ozaki-r in ticket #687):
sys/kern/kern_rwlock_obj.c: revision 1.4
sys/rump/librump/rumpkern/locks.c: revision 1.80
sys/kern/kern_rwlock.c: revision 1.50
sys/arch/x86/x86/db_memrw.c: revision 1.5,1.6
sys/ddb/db_command.c: revision 1.150-1.153
share/man/man4/ddb.4: revision 1.175 (via patch),1.176-1.178
sys/kern/kern_mutex_obj.c: revision 1.6
sys/kern/subr_lockdebug.c: revision 1.61-1.64
sys/sys/lockdebug.h: revision 1.17
sys/kern/kern_mutex.c: revision 1.71
sys/sys/lockdebug.h: revision 1.18,1.19
sys/kern/subr_xcall.c: revision 1.26

Obtain proper initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc

Initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc
were not useful because the addresses were mutex_obj_alloc or rw_obj_alloc
itself. What we want to know are callers of them.

Spinkle ASSERT_SLEEPABLE to xcall functions

Use db_printf instead of printf in ddb

Add a new command, show lockstat, which shows statistics of locks
Currently the command shows the number of allocated locks.
The command is useful only if LOCKDEBUG is enabled.

Add a new command, show all locks, which shows information of active locks

The command shows information of all active (i.e., being held) locks that are
tracked through either of LWPs or CPUs by the LOCKDEBUG facility. The /t
modifier additionally shows a backtrace for each LWP additionally. This
feature is useful for debugging especially to analyze deadlocks.
The command is useful only if LOCKDEBUG is enabled.

Don't pass a unset address to lockdebug_lock_print

x86: avoid accessing invalid addresses in ddb like arm32
This avoids that a command stops in the middle of an execution if
a fault occurs due to an access to an invalid address.

Get rid of a redundant output

Improve wording. Fix a Cm argument.

ddb: rename "show lockstat" to "show lockstats" to avoid conflicting with lockstat(8)
Requested by mrg@
 1.149.2.4 30-Sep-2018  pgoyette Ssync with HEAD
 1.149.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.149.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.149.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.153.2.4 21-Apr-2020  martin Sync with HEAD
 1.153.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.153.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.153.2.1 10-Jun-2019  christos Sync with HEAD
 1.160.4.1 26-Jan-2020  martin Pull up following revision(s) (requested by uwe in ticket #656):

sys/ddb/db_command.c: revision 1.162
sys/ddb/db_command.c: revision 1.163
sys/ddb/db_command.c: revision 1.164

db_command - make sure count is always initialized.
db_command - make setting have_addr more clear.
Don't set it to false that it's already initialized to.
db_command - don't hide local static variable in the middle of other
local variable definitions. While here, get rid of the alignment of
variable names.
 1.169.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.175.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.181.4.2 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

sys/arch/m68k/include/mutex.h: revision 1.13
sys/arch/arm/include/cpu.h: revision 1.125
sys/arch/sun68k/include/intr.h: revision 1.21
sys/arch/arm/include/mutex.h: revision 1.28
sys/sys/rwlock.h: revision 1.18
sys/arch/powerpc/include/mutex.h: revision 1.7
sys/arch/arm/include/mutex.h: revision 1.29
sys/arch/powerpc/include/mutex.h: revision 1.8
sys/uvm/uvm_param.h: revision 1.42
sys/sys/ksem.h: revision 1.16
sys/arch/x86/include/mutex.h: revision 1.10
sys/sys/proc.h: revision 1.372
sys/sys/ksem.h: revision 1.17
sys/arch/ia64/include/mutex.h: revision 1.8
sys/arch/evbarm/include/intr.h: revision 1.29
sys/sys/lua.h: revision 1.9
sys/arch/next68k/include/intr.h: revision 1.23
sys/arch/ia64/include/mutex.h: revision 1.9
sys/arch/hp300/include/intr.h: revision 1.35
sys/arch/hp300/include/intr.h: revision 1.36
sys/arch/sparc/include/cpu.h: revision 1.111
sys/arch/hppa/include/mutex.h: revision 1.16
sys/arch/vax/include/intr.h: revision 1.31
sys/arch/hppa/include/mutex.h: revision 1.17
sys/arch/news68k/include/intr.h: revision 1.28
sys/arch/hppa/include/mutex.h: revision 1.18
sys/arch/hppa/include/intr.h: revision 1.3
sys/arch/hppa/include/mutex.h: revision 1.19
sys/arch/hppa/include/intr.h: revision 1.4
sys/sys/sched.h: revision 1.92
sys/opencrypto/cryptodev.h: revision 1.51
sys/arch/vax/include/mutex.h: revision 1.20
sys/arch/sparc64/include/mutex.h: revision 1.10
sys/arch/ia64/include/sapicvar.h: revision 1.2
sys/arch/riscv/include/mutex.h: revision 1.5
sys/arch/amiga/dev/grfabs_cc.c: revision 1.39
sys/external/bsd/drm2/include/linux/idr.h: revision 1.11
sys/arch/riscv/include/mutex.h: revision 1.6
sys/ddb/files.ddb: revision 1.16
sys/arch/mac68k/include/intr.h: revision 1.32
share/man/man4/ddb.4: revision 1.203
sys/ddb/db_command.c: revision 1.183
sys/arch/mips/include/mutex.h: revision 1.10
sys/ddb/db_command.c: revision 1.184
sys/arch/x68k/include/intr.h: revision 1.22
sys/arch/sparc/include/psl.h: revision 1.51
sys/arch/or1k/include/mutex.h: revision 1.4
sys/arch/mips/include/mutex.h: revision 1.11
sys/arch/arm/xscale/pxa2x0_intr.h: revision 1.16
sys/arch/sparc64/include/cpu.h: revision 1.134
sys/arch/sparc/include/psl.h: revision 1.52
sys/arch/or1k/include/mutex.h: revision 1.5
sys/arch/mvme68k/include/intr.h: revision 1.22
sys/arch/luna68k/include/intr.h: revision 1.16
external/cddl/osnet/sys/sys/kcondvar.h: revision 1.6
sys/arch/sparc/include/mutex.h: revision 1.12
sys/arch/sparc/include/mutex.h: revision 1.13
sys/arch/usermode/include/mutex.h: revision 1.5
sys/arch/usermode/include/mutex.h: revision 1.6
sys/kern/kern_core.c: revision 1.38
usr.sbin/crash/Makefile: revision 1.49
sys/arch/amiga/include/intr.h: revision 1.23
sys/arch/alpha/include/mutex.h: revision 1.12
sys/arch/alpha/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.16
sys/ddb/ddb.h: revision 1.6
sys/arch/sparc64/include/mutex.h: revision 1.8
sys/arch/sh3/include/mutex.h: revision 1.12
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.17
sys/ddb/db_syncobj.c: revision 1.1
sys/arch/vax/include/mutex.h: revision 1.18
sys/arch/sparc64/include/psl.h: revision 1.63
sys/arch/sparc64/include/mutex.h: revision 1.9
sys/arch/sh3/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/obio.c: revision 1.13
sys/arch/atari/include/intr.h: revision 1.23
sys/ddb/db_syncobj.c: revision 1.2
sys/arch/vax/include/mutex.h: revision 1.19
sys/arch/evbarm/g42xxeb/obio.c: revision 1.14
sys/arch/evbarm/g42xxeb/obio.c: revision 1.15
sys/arch/cesfic/include/intr.h: revision 1.14
sys/ddb/db_syncobj.h: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.134
sys/arch/evbarm/g42xxeb/obio.c: revision 1.16
sys/arch/cesfic/include/intr.h: revision 1.15
sys/arch/arm/xscale/pxa2x0_intr.c: revision 1.26
sys/sys/cpu_data.h: revision 1.54
sys/arch/m68k/include/mutex.h: revision 1.12
sys/arch/ia64/acpi/madt.c: revision 1.6

sys/rwlock.h: Make this more self-contained for bool.

machine/mutex.h: Sprinkle includes so this can be used by crash(8).

ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

sys: Rip <sys/resourcevar.h> out of <uvm/uvm_param.h>.

And thus out of <sys/param.h>, which is exceedingly overused and
fragile and delenda est.

Should fix (some) issues with the recent inclusion of machine/lock.h
in various machine/mutex.h files.

arm/mutex.h: Need machine/intr.h, machine/lock.h.

For ipl_cookie_t and __cpu_simple_lock_t.
evbarm/intr.h: Define ipl_cookie_t before including ARM_INTR_IMPL.

Otherwise arm/mutex.h doesn't work, due to a cyclic dependency which
should really be fixed.
opencrypto/cryptodev.h: Fix includes.
- Move sys/condvar.h under #ifdef _KERNEL.
- Add some other necessary includes and forward declarations.
- Sort.

hp300/intr.h: Fix missing includes.
linux/idr.h: Need <sys/mutex.h> for kmutex_t.
amiga/intr.h: Don't define spl*() functions if !_KERNEL.

This is used by crash(8) now, and what's important is ipl_cookie_t.
cesfic/intr.h: Expose ipl_cookie_t to userland for crash(8).
cesfic/intr.h: Expose ipl_cookie_t to userland only with _KMEMUSER.

Probably not necessary but let's be a little more cautious about
this.

atari/intr.h: Expose ipl_cookie_t with _KMEMUSER for crash(8).

arm/cpu.h: Need sys/param.h for COHERENCY_UNIT.

Nix machine/param.h -- not meant to be used directly, pulled in by
sys/param.h.

Move the definition of ipl_cookie_t out of the kernel-only sections,
some _KMEMUSER applications need it.

ddb: Cast pointer to uintptr_t first before db_expr_t.

hppa/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

luna68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

mvme68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

news68k/intr.h: Fix includes. Put some definitions under _KERNEL.

next68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

sys/ksem.h: Hack around fstat(8) abuse of _KERNEL.

sun68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

vax/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

x68k/intr.h: Put functions under _KERNEL so crash(8) can use this.

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

Explicitly include <sys/mutex.h> for kmutex_t.

Replace kmutex_t * (which may be undefined here) with struct kmutex *,
suggested by Taylor.

hp300/intr.h: Put most of this under #ifdef _KERNEL.
Only ipl_cookie_t really needs to be exposed now, for crash(8).

mac68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).
Make inclusion of sys/intr.h explicit for spl*.

fix hppa and vax builds.

machine/lock.h isn't necessary for __cpu_simple_lock_t, it's in
sys/types.h. avoids cpu_data.h vs sched.h include order issues.

move the hppa ipl_t typedef with the moved usage of it.
machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.

ddb: Cast pointer to uintptr_t, then to db_expr_t.
Avoids warnings about conversion between pointer and integer of
different size on some architectures.

re-fix hppa builds.

this file uses __cpu_simple_lock(), not just the underlying type,
so it does need machine/lock.h.

Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex. Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT. Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.

ia64: Need sys/types.h for u_int, vaddr_t; sys/mutex.h for kmutex_t.

explicitly include no longer implicitly included sys/mutex.h.

arm/xscale: Use sys/bitops.h fls32 - 1 instead of 31 - __builtin_clz.
Sidesteps namespace collision with `#define bits ...' in net/zlib.c.

complete the previous - there were two calls to find_first_bit() to fix.

arm/xscale: Missed a spot with previous find_first_bit commit.

evbarm/g42xxeb: Fix off-by-one in previous.

The original find_first_bit(x) was 31 - __builtin_clz((uint32_t)x),
which is equivalent to fls32(x) - 1, not to fls32(x).

Note that fls32 is 1-based and returns 0 for x=0.
 1.181.4.1 03-Jun-2023  martin Pull up following revision(s) (requested by uwe in ticket #188):

sys/ddb/db_command.c: revision 1.182

ddb: PR kern/57435 - fix duplicate "show mount"

Bolivar cannot carry double. One of these commands should have been
"show mounts", cf. page/pages and a few others. While here fix the
function name to be db_show_all_mounts to conform to the pattern.
 1.42 09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.41 23-Feb-2021  mrg introduce DDB_END_CMD and replace more than 20 copies of the same
list of NULLs and 0. idea from rillig@.

all touched ports built, several booted.
 1.40 30-Oct-2020  skrll branches: 1.40.2;
Whitespace
 1.39 30-Oct-2020  skrll Trailing whitespace
 1.38 31-May-2020  rin Revert introduction of db_alloc.h.

db_alloc() and friends are already provided in crash.c.
Sorry for confusing you...
 1.37 31-May-2020  rin Introduce db_alloc.h.

Provide db_alloc() and friends to userland, i.e., crash(8).
 1.36 10-Mar-2020  christos Make the db_kernelonly() macro visible to all files and re-use it.
Register access is kernel only.
 1.35 07-Mar-2009  ad branches: 1.35.64;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.34 05-Jan-2009  haad branches: 1.34.2;
Fix my bug introduced in rev 1.98 of db_command.c where command prefix
not ambiguous in one table was choosed even if it was ambiguous in another
table in same list. Also apply more KNF rules.

Patch was supplied by uwe@.
 1.33 28-Apr-2008  martin branches: 1.33.8; 1.33.10;
Remove clause 3 and 4 from TNF licenses
 1.32 27-Mar-2008  uwe branches: 1.32.2; 1.32.4;
Fix CS_MACH definition. 0x10 is spelled 0x10, not 0x16.
 1.31 25-Dec-2007  perry branches: 1.31.6;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.30 01-Oct-2007  martin branches: 1.30.4; 1.30.6; 1.30.10;
No need to db_init_commands() early any more - it will happen on first
entry to ddb.
 1.29 23-Sep-2007  martin Minor clenaup - db_cmd_loop_done is a bool nowadays, so use true/false
instead of 0/1.
Also make db_init_commands() non-static.
 1.28 22-Sep-2007  martin Add a new option DDB_VERBOSE_HELP that adds online help to ddb.
From Adam Hamsik.
Minor modifications by me, all bugs are probably mine.
 1.27 22-Feb-2007  matt branches: 1.27.4; 1.27.16; 1.27.18;
Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.26 05-Sep-2006  uwe branches: 1.26.8;
Mark db_error __attribute__((__noreturn__)).
 1.25 27-Nov-2005  yamt branches: 1.25.4; 1.25.8;
make DDB_COMMANDONENTER sysctl. (ddb.commandonenter)
suggested by Christos Zoulas.
 1.24 01-Jun-2005  drochner branches: 1.24.2; 1.24.8;
more constification fallout
 1.23 29-May-2005  christos Add lots of const.
 1.22 15-Feb-2002  simonb branches: 1.22.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.21 17-Aug-2001  thorpej Add `show malloc' to dump the internal state of the MALLOC_DEBUG code.
 1.20 22-Jan-2001  jdolecek branches: 1.20.2; 1.20.4;
Require the machine-dependant DDB commands to be in db_machine_command_table[]
and link it directly to db_command_table[] so that it's not necessary
to do this at runtime. Make db_machine_command_table[] const on all ports.
g/c now unneded stuff, like db_machine_commands_install(), db_machine_init()

Patch written by enami.
 1.19 17-Jan-2001  jdolecek constify a little
 1.18 24-Nov-2000  chs add ddb commands "show uvmexp" and "show ncache".
the former used to be "call uvm_dump", the latter is new.
 1.17 26-May-2000  jhawk Rename the machine-specific stack trace printing functions
from db_stack_trace_cmd() to db_stack_trace_print(),
and add an additional argument, a function pointer for an
output routine (i.e. printf() or db_printf()).

Add db_stack_trace_cmd() in db_command.[ch], calling
db_stack_trace_print() with db_printf() as the printer.

Move count==-1 special handling from db_stack_trace_print() [nee
db_stack_trace_cmd()] to db_stack_trace_cmd() [nascent here].

Again, I'm unable to test compilation on all affected platforms,
so advance apologies for potential brokenness.
 1.16 22-May-2000  jhawk Add a "sifting" command to ddb (named from the Sun OpenPROM command of
the same name); it searches the symbol table(s) for all symbols matching
a given substring, and prints.

Extremely useful for when you forget that critical symbol name.

Also, with /F support (cf. "ls -F") to print a char indicating the
symbol type.
 1.15 10-Apr-2000  chs add ddb commands for printing vnodes and bufs.
 1.14 28-Oct-1999  lukem - change db_cmd_list() to list commands vertically rather than horizontally
- sort entries in the various command tables, so that the `help' lists
are easier to use. this included hacking db_machine_commands_install()
to search for the "machine" entry to change the `more cmds' pointer,
rather than assuming it was the first entry
- add a `sync' command, which is effectively `reboot 0x100'.
- remove db_help_cmd(); it was unused (and was almost a duplicate of
db_cmd_list()).
- move some extern decls to db_output.h, since they're used in more than one
place now
- rename NEXT_TAB to DB_NEXT_TAB and move to db_output.h
 1.13 10-May-1999  thorpej branches: 1.13.2; 1.13.4; 1.13.6;
Improve the pool allocator's diagnostic helpers, adding the ability to
log on a per-pool basis, reentrancy checking, and dumping various pool
information from DDB.
 1.12 12-Apr-1999  pk Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.11 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.10 05-Feb-1998  mrg branches: 1.10.4; 1.10.8;
initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly. :-)
 1.9 11-Sep-1997  scottr Add a 'reboot' command with a single parameter specifying the boot flags.
 1.8 05-Feb-1996  christos branches: 1.8.12;
DDB prototype changes.
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 23-Mar-1994  pk struct command => struct db_command, and define it in db_command.h
 1.3 15-Feb-1994  mycroft Remove RCS logs.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.8.12.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.10.8.2 12-Apr-1999  pk branches: 1.10.8.2.2;
Pullup copyright text corrections.
 1.10.8.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.10.8.2.2.2 21-Jun-1999  thorpej Sync w/ -current.
 1.10.8.2.2.1 07-Jun-1999  chs merge everything from chs-ubc branch.
 1.10.4.1 09-Nov-1998  chs initial snapshot. lots left to do.
 1.13.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.13.4.1 15-Nov-1999  fvdl Sync with -current
 1.13.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.13.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.13.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.20.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.20.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.20.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.20.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.22.16.2 11-Dec-2005  christos Sync with head.
 1.22.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.8.1 29-Nov-2005  yamt sync with head.
 1.24.2.5 21-Jan-2008  yamt sync with head
 1.24.2.4 27-Oct-2007  yamt sync with head.
 1.24.2.3 26-Feb-2007  yamt sync with head.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.25.8.1 14-Sep-2006  yamt sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.8.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.27.18.2 09-Jan-2008  matt sync with HEAD
 1.27.18.1 06-Nov-2007  matt sync with HEAD
 1.27.16.1 02-Oct-2007  joerg Sync with HEAD.
 1.27.4.1 09-Oct-2007  ad Sync with head.
 1.30.10.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.6.1 26-Dec-2007  ad Sync with head.
 1.30.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.31.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.31.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.31.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.4.2 04-May-2009  yamt sync with head.
 1.32.4.1 16-May-2008  yamt sync with head.
 1.32.2.1 18-May-2008  yamt sync with head.
 1.33.10.1 09-Jan-2009  snj Pull up following revision(s) (requested by haad in ticket #241):
sys/ddb/db_command.c: revision 1.126
sys/ddb/db_command.h: revision 1.34
Fix my bug introduced in rev 1.98 of db_command.c where command prefix
not ambiguous in one table was choosed even if it was ambiguous in
another table in same list. Also apply more KNF rules.
Patch was supplied by uwe@.
 1.33.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.33.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.35.64.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.40.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 02-Oct-2007  martin Some cleanup:
- When registering command tables, make sure the builtin commands are
already registered
- Make the command table entry structure private
- Do not bother to store the number of commands in a table, we can quickly
calc that if needed.
 1.1 22-Sep-2007  martin branches: 1.1.2;
Add a new option DDB_VERBOSE_HELP that adds online help to ddb.
From Adam Hamsik.
Minor modifications by me, all bugs are probably mine.
 1.1.2.1 06-Oct-2007  yamt sync with head.
 1.7 12-Apr-2014  jakllsch Make this build.

Hi jakllsch@.
 1.6 12-Apr-2014  jakllsch Unbreak db_cpu_*. Allows backtraces on i386 to progress beyond the
first function by not doing a NULL-deref in the debugger.

Bug located by me. Patch implementation by riastradh@. Hi rmind@.
 1.5 24-Nov-2013  rmind branches: 1.5.2;
Remove cpu_queue (and thus eleminate another use of CIRCLEQ) by replacing
its uses with cpu_infos array. Extra testing by christos@.
 1.4 20-Feb-2011  hannken branches: 1.4.4; 1.4.14; 1.4.18;
When looking for the next element of cpu_queue compare the pointer to the
address of the head, not to the head itself. Not sure if the cast of the
arg to db_value_name() is right, but works on i386 and compiles on sparc64.

Stack traces from ddb work again on i386.
 1.3 09-Mar-2009  mrg branches: 1.3.2; 1.3.4; 1.3.6; 1.3.10; 1.3.12; 1.3.14;
include <stdbool.h> if not _KERNEL, and don't include kauth.h if _KERNEL.

now crash builds on i386.
 1.2 08-Mar-2009  mrg include ddb headers *after* sys/types.h or sys/param.h.
 1.1 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.3.14.1 05-Mar-2011  bouyer Sync with HEAD
 1.3.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.10.1 05-Mar-2011  rmind sync with head
 1.3.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.6.1 09-Mar-2009  jym file db_cpu.c was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.3.4.2 04-May-2009  yamt sync with head.
 1.3.4.1 09-Mar-2009  yamt file db_cpu.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.3.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.3.2.1 09-Mar-2009  skrll file db_cpu.c was added on branch nick-hppapmap on 2009-04-28 07:35:12 +0000
 1.4.18.1 18-May-2014  rmind sync with head
 1.4.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.4.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.5.2.1 10-Aug-2014  tls Rebase.
 1.1 07-Mar-2009  ad branches: 1.1.2; 1.1.4; 1.1.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 07-Mar-2009  jym file db_cpu.h was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 07-Mar-2009  yamt file db_cpu.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.1.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1 07-Mar-2009  skrll file db_cpu.h was added on branch nick-hppapmap on 2009-04-28 07:35:12 +0000
 1.2 14-Oct-1999  jdolecek remove the MI Debugger() added recently. It doesn't make sense in
it's current form.
make Debugger just an alias for cpu_Debugger
 1.1 12-Oct-1999  jdolecek rename the MD Debugger() to cpu_Debugger()
add MI Debugger() which switches to console if wscons is used prior
to calling cpu_Debugger()
 1.29 06-Nov-2017  christos remove more DB_ELFSIZE
 1.28 04-Nov-2017  christos use Elf_Sym ** instead of casting.
 1.27 14-Mar-2009  dsl branches: 1.27.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.26 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.25 28-Apr-2008  martin branches: 1.25.8; 1.25.14;
Remove clause 3 and 4 from TNF licenses
 1.24 22-Feb-2007  thorpej branches: 1.24.38; 1.24.40; 1.24.42;
TRUE -> true, FALSE -> false
 1.23 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.22 13-Nov-2002  yamt branches: 1.22.22; 1.22.60;
make stack trace on i386 work again.
(signed vs unsigned)
 1.21 10-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.20 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.19 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.18 12-Nov-2001  lukem add RCSIDs
 1.17 08-Nov-2001  christos PR/14498: Wesley Chen: Identify loaded modules vs. kernel, because we don't
load the elf header with them.
 1.16 31-Jul-2001  bjh21 branches: 1.16.4;
Extra sanity checking on ELF headers: Make sure the bootloader actually
loaded (or claims to have loaded) everything we need.
 1.15 31-Jul-2001  bjh21 Don't depend on the bootloader's having loaded the .shstrtab section
in order to load the symbol table. Instead of using the sections
called ".symtab" and ".strtab", use the first SYMTAB section (the
ELF spec says there should currently only be one) and the STRTAB
section that's linked to it. I believe this is more robust, and it
certainly makes life easier for the bootloader.
 1.14 17-Jan-2001  jdolecek branches: 1.14.2; 1.14.4;
constify a little
 1.13 07-Jul-2000  jhawk s/preserving ... bytes of symbol table/using ... bytes of symbol table/

"preserving" implies that the data may be copied and might otherwise
be freed, and that other data in the symbol table or sections of
the kernel might be freed, however there is no mechanism for these
things to take place, so "using" is clearer.
 1.12 07-Jul-2000  jhawk Detect ELF sections (string and symbol tables) by looking them
up by name (in .shstrtab) instead of guessing based on section
type (and throwing away the small one). In addition to being cleaner,
multiple symbol tables are no longer and error condition, so
booting netbsd.gdb no longer results in ddb being unable to use
*any* symbols.
 1.11 22-May-2000  jhawk branches: 1.11.4;
Add a "sifting" command to ddb (named from the Sun OpenPROM command of
the same name); it searches the symbol table(s) for all symbols matching
a given substring, and prints.

Extremely useful for when you forget that critical symbol name.

Also, with /F support (cf. "ls -F") to print a char indicating the
symbol type.
 1.10 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.9 21-Oct-1999  erh Remove ELFNAME macros which are already defines in exec_elf.h
 1.8 08-Jan-1999  augustss branches: 1.8.8; 1.8.10; 1.8.12;
Avoid arithmetic on `void *' since that's not ANSI C.
 1.7 04-Dec-1998  thorpej - Make the ddb_init() interface consistent for a.out and ELF.
- Allow DDB to run-time switch for a.out or ELF symbol table support.
 1.6 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.5 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.4 03-May-1998  thorpej branches: 1.4.2;
Whitespace.
 1.3 30-Nov-1997  drochner Clean up usage of printf() vs db_printf(): The diagnostic messages
when symbol tables are loaded don't belong to the user interaction,
their output lines should not be counted by ddb's builtin pager.
 1.2 05-Sep-1997  thorpej Make sure debugging symbol sections are aligned.
 1.1 01-Jul-1997  thorpej branches: 1.1.2;
Add support for Elf symbol tables to DDB, written from scratch by me.
Known to work in DDB under NetBSD/alpha.
 1.1.2.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.2.1 12-Aug-1998  eeh Give DDB access to all the nice symbols in locore.s
 1.8.12.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.10.1 15-Nov-1999  fvdl Sync with -current
 1.8.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.8.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.11.4.1 12-Jul-2000  jhawk Pullup rev 1.12, approved by thorpej:
Detect ELF sections (string and symbol tables) by looking them
up by name (in .shstrtab) instead of guessing based on section
type (and throwing away the small one). In addition to being cleaner,
multiple symbol tables are no longer and error condition, so
booting netbsd.gdb no longer results in ddb being unable to use
*any* symbols.
 1.14.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.14.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.4.1 03-Aug-2001  lukem update to -current
 1.14.2.6 15-Nov-2002  nathanw Catch up to -current (stack trace sign fix).
 1.14.2.5 11-Nov-2002  nathanw Catch up to -current
 1.14.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.14.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.14.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.16.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.22.60.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.22.1 26-Feb-2007  yamt sync with head.
 1.24.42.2 04-May-2009  yamt sync with head.
 1.24.42.1 16-May-2008  yamt sync with head.
 1.24.40.1 18-May-2008  yamt sync with head.
 1.24.38.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.22.1 03-Dec-2017  jdolecek update from HEAD
 1.40 12-Sep-2019  ryo changes of r1.39 was incomplete. only "examin/m" could handle 'q'.
added support 'r','x','z','d','u', and 'o' with 'q' modifier on 32bit arch.
 1.39 10-Sep-2019  ryo - examin/m displays with splitting by spaces as specified size
- add support 'q' modifier on all arch
- consider endianness
 1.38 10-Sep-2019  ryo Add support for 'p' qualifier for pointer values on examine.
this shows as a pointer with symbol if possible. (e.g. "x/p $sp,10")
 1.37 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.36 06-Jun-2015  matt branches: 1.36.18;
Add support for 'q' qualifier for 64-bit values on examine and write.
Align data to long so that the MD parts can use aligned load/stores.
Don't use db_extend but use db_expr_t based expressions.
 1.35 26-May-2011  joerg branches: 1.35.14; 1.35.32;
Introduce DDB_EXPR_FMT and replace the logic around DB_EXPR_T_IS_QUAD.
 1.34 07-Mar-2009  ad branches: 1.34.4; 1.34.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.33 16-Nov-2008  pooka branches: 1.33.4;
more <sys/buf.h> police
 1.32 22-Feb-2007  thorpej branches: 1.32.38; 1.32.42; 1.32.46; 1.32.48; 1.32.52;
TRUE -> true, FALSE -> false
 1.31 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.30 16-Nov-2006  christos branches: 1.30.4;
__unused removal on arguments; approved by core.
 1.29 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.28 11-Dec-2005  christos branches: 1.28.20; 1.28.22;
merge ktrace-lwp.
 1.27 01-Jun-2005  drochner branches: 1.27.2;
more constification fallout
 1.26 09-Nov-2003  scw Fix format string warnings for platforms where
sizeof(db_addr_t) > sizeof(long). e.g. ILP32 on sh5.
 1.25 17-May-2003  scw branches: 1.25.2;
On some platforms, sizeof(db_expr_t) > sizeof(long), so add a method
to select the right format string (at compile time) when displaying
variables of type db_expr_t.

This fixes a problem where ddb(4) would only display the low 32-bits
of registers for an ILP32 kernel on SH5, even though registers
(and db_expr_t) are always 64-bits wide.
 1.24 16-May-2003  itojun switch to use strlcpy() from libkern.
 1.23 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.22 12-Nov-2001  lukem add RCSIDs
 1.21 24-Feb-2001  cgd branches: 1.21.2; 1.21.4;
#include <systm.h> for string fn prototypes.
 1.20 28-Dec-2000  jmc Add x/m option functionality
 1.19 09-Aug-2000  tv Add two new functions, db_format_radix() and db_format_hex(), which supplant
the former %r and %z nonstandard kprintf strings.
 1.18 25-May-2000  jhawk Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.17 30-Mar-2000  augustss Die, register, die!
 1.16 31-May-1999  ross branches: 1.16.2;
New format modifier: `L' gives true `long' vs `l' or `legacy' long.
 1.15 12-Apr-1999  pk Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.14 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.13 03-Feb-1997  mycroft branches: 1.13.20;
db_expr_t became a long.
 1.12 03-Feb-1997  cgd fix various 64-bitness bugs.
 1.11 30-Mar-1996  christos Fix db_printf format specifications.
 1.10 05-Feb-1996  christos DDB prototype changes.
 1.9 17-Nov-1994  gwr Make x/a print the address; simplify slightly.
 1.8 14-Nov-1994  gwr When use default form when printing location (i.e. after step).
Use less space printing longs (so you can fit four per line).
 1.7 06-Oct-1994  mycroft Fix some weird formatting.
 1.6 26-Sep-1994  gwr Fix data size specifiers and multiple format specifiers, like:
db> x/bxxxx ADDRESS
 1.5 30-Jun-1994  gwr branches: 1.5.2;
Make "examine" (x/i) always print the address.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.5.2.1 06-Oct-1994  mycroft Update from trunk.
 1.13.20.2 12-Apr-1999  pk branches: 1.13.20.2.2;
Pullup copyright text corrections.
 1.13.20.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.13.20.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.16.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.16.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.16.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.21.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.21.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.25.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.1 03-Aug-2004  skrll Sync with HEAD
 1.27.2.2 26-Feb-2007  yamt sync with head.
 1.27.2.1 30-Dec-2006  yamt sync with head.
 1.28.22.2 10-Dec-2006  yamt sync with head.
 1.28.22.1 22-Oct-2006  yamt sync with head
 1.28.20.1 18-Nov-2006  ad Sync with head.
 1.30.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.32.52.2 28-Apr-2009  skrll Sync with HEAD.
 1.32.52.1 19-Jan-2009  skrll Sync with HEAD.
 1.32.48.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.32.46.2 27-Jun-2008  simonb Revert local changes that were not meant to be in previous "sync with
head" commit.
 1.32.46.1 27-Jun-2008  simonb Sync with head.
 1.32.42.1 04-May-2009  yamt sync with head.
 1.32.38.1 17-Jan-2009  mjf Sync with HEAD.
 1.33.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.34.4.1 31-May-2011  rmind sync with head
 1.35.32.1 22-Sep-2015  skrll Sync with HEAD
 1.35.14.1 03-Dec-2017  jdolecek update from HEAD
 1.36.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.36.18.1 10-Jun-2019  christos Sync with HEAD
 1.16 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.15 22-Feb-2007  thorpej branches: 1.15.42; 1.15.52; 1.15.58;
TRUE -> true, FALSE -> false
 1.14 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.13 15-Feb-2002  simonb branches: 1.13.32; 1.13.70;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.12 12-Nov-2001  lukem add RCSIDs
 1.11 09-Jul-2000  mycroft branches: 1.11.2; 1.11.4;
Fix compiler warning.
 1.10 08-Jul-2000  eeh Fix for:

7. Numbers starting with [a-f] should work, but symbols
of the same name should have priority.
 1.9 12-Apr-1999  pk branches: 1.9.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.8 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.7 26-Jun-1997  thorpej branches: 1.7.16;
Use db_expr_t rather than int when reading a value from the kernel
address space, to avoid type-size problems.
 1.6 03-Feb-1997  cgd fix various 64-bitness bugs.
 1.5 05-Feb-1996  christos DDB prototype changes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.7.16.2 12-Apr-1999  pk branches: 1.7.16.2.2;
Pullup copyright text corrections.
 1.7.16.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.7.16.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.11.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.11.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.11.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.13.70.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.13.32.1 26-Feb-2007  yamt sync with head.
 1.15.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.15.42.1 04-May-2009  yamt sync with head.
 1.16 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.15 22-Feb-2007  matt branches: 1.15.38; 1.15.40; 1.15.42;
Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.14 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.13 11-Dec-2005  christos branches: 1.13.26;
merge ktrace-lwp.
 1.12 01-Jun-2005  drochner branches: 1.12.2;
more constification fallout
 1.11 16-May-2003  itojun branches: 1.11.2;
switch to use strlcpy() from libkern.
 1.10 28-Apr-2003  briggs Add a rudimentary 'trap to kgdb' command if KGDB is defined. This allows
systems with only one serial port for console, etc., to have at least some
basic access to remote-kgdb-over-serial, even if it is a bit awkward.
 1.9 13-May-2002  matt Add db_recover
 1.8 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.7 17-Jul-2000  jeffs branches: 1.7.2; 1.7.4;
Move platform db_trap callback from arch/mips into ddb as suggested by
jhawk. This callback is used by platform code to manage things like
watchdogs that should be disabled while in ddb. Done as a callback
for processors such as mips that support lots of different systems.
 1.6 04-Dec-1998  thorpej branches: 1.6.10;
- Make the ddb_init() interface consistent for a.out and ELF.
- Allow DDB to run-time switch for a.out or ELF symbol table support.
 1.5 05-Sep-1998  christos Assign copyright to TNF.
 1.4 09-Jun-1998  tv Change ddb_init() for a.out to provision for kernels which are not booted by
the current 'bootblock' method, like the Shark, which preloads and preformats
the symbol table right in the boot code.
 1.3 16-Nov-1997  christos Add declaration for db_delete_line
 1.2 26-Jun-1997  thorpej Update prototypes for new function signatures. Note, the ddb_init()
signature is currently different for the DB_AOUT_SYMBOLS vs. the
DB_ELF_SYMBOLS cases. (XXX)
 1.1 05-Feb-1996  christos DDB prototype changes.
 1.6.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.7.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.7.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.11.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.1 26-Feb-2007  yamt sync with head.
 1.13.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.15.42.1 16-May-2008  yamt sync with head.
 1.15.40.1 18-May-2008  yamt sync with head.
 1.15.38.1 02-Jun-2008  mjf Sync with HEAD.
 1.28 30-Oct-2020  skrll Trailing whitespace
 1.27 29-Sep-2019  uwe Print db> prompt in db_read_line(), not db_readline().

The former is what DDB repl calls. The latter performs the actual
input so let other code use it without the unwanted db> prompt. It's
already used by ACPI (and AcpiOsWaitCommandReady supplies its own
prompt). I also use it for my uncommitted Forth scripting for DDB.
 1.26 31-Aug-2010  enami branches: 1.26.60; 1.26.64;
Define db_hist_put() only when DDB_HISTORY_SIZE != 0 so that
build successes on ports like hpcarm.
 1.25 31-Aug-2010  enami Fix indent in prevous commit.
 1.24 30-Aug-2010  tls Don't overflow DDB command history. Coyote Point changelist description:

DDB is flakey. The command history wanders past the bounds. Way
past. When it hits some boolean that indicates a.out format symbol
tables are to be used, and here is the pointer to the function, the
call thru the NULL function pointer renders the debug session entirely
unsatisfactory, outcome wise.
 1.23 07-Mar-2009  ad branches: 1.23.2; 1.23.4;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.22 22-Feb-2007  thorpej branches: 1.22.42; 1.22.52; 1.22.58;
TRUE -> true, FALSE -> false
 1.21 11-Dec-2005  christos branches: 1.21.26;
merge ktrace-lwp.
 1.20 29-May-2005  christos branches: 1.20.2;
Add lots of const.
 1.19 04-Nov-2002  itohy branches: 1.19.6;
Dump DDB_* and SYMTAB_SPACE options to opt_ddbparam.h rather than opt_ddb.h.
These options are used in limited files but #include "opt_ddb.h" are
everywhere, and changing them caused almost full recompilation.
 1.18 02-Nov-2002  perry /*CONTCOND*/ while (0)'ed macros
 1.17 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.16 20-Nov-2001  lukem - pull in opt_kgdb.h where necessary
- replace opt_kgdb_machdep.h with opt_kgdb.h
- defparam opt_kgdb.h:
KGDB_DEV KGDB_DEVNAME KGDB_DEVADDR KGDB_DEVRATE KGDB_DEVMODE
- move from opt_ddbparam.h to opt_ddb.h:
DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE DDB_BREAK_CHAR SYMTAB_SPACE
- replace KGDBDEV with KGDB_DEV
- replace KGDBADDR with KGDB_DEVADDR
- replace KGDBMODE with KGDB_DEVMODE
- replace KGDBRATE with KGDB_DEVRATE
- use `9600' instead of `0x2580' for 9600 baud rate
- use correct quotes for options KGDB_DEVNAME="\"com\""
- use correct quotes for options KGDB_DEV="17*256+0"
- remove unnecessary dependancy on Makefile for kgdb_stub.o
- minor whitespace cleanup
 1.15 12-Nov-2001  lukem add RCSIDs
 1.14 28-Jul-2000  jhawk branches: 1.14.2; 1.14.4;
Fix CTRL-T to behave properly. It should swaps the current and previous
characters, not the previous and second-to-previous.
 1.13 30-Mar-2000  augustss Die, register, die!
 1.12 12-Apr-1999  pk branches: 1.12.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.11 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.10 04-Jul-1998  jonathan branches: 1.10.8;
defopt DDB.
 1.9 16-Nov-1997  lukem s/DB_HISTORY_SIZE/DDB_HISTORY_SIZE/, for consistency with other DDB #defines
 1.8 16-Nov-1997  christos PR/4504: Tero Kivinen: Add DB_HISTORY_SIZE option to enable history in ddb
 1.7 05-Feb-1996  christos DDB prototype changes.
 1.6 26-Oct-1994  mycroft Remove bogus definition of cnpollc().
 1.5 09-Oct-1994  mycroft db_error() does not return.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.10.8.2 12-Apr-1999  pk branches: 1.10.8.2.2;
Pullup copyright text corrections.
 1.10.8.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.10.8.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.14.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.4 11-Nov-2002  nathanw Catch up to -current
 1.14.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.14.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.19.6.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.1 26-Feb-2007  yamt sync with head.
 1.21.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.22.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.22.42.2 09-Oct-2010  yamt sync with head
 1.22.42.1 04-May-2009  yamt sync with head.
 1.23.4.1 05-Mar-2011  rmind sync with head
 1.23.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.26.64.1 26-Jan-2020  martin Pull up following revision(s) (requested by uwe in ticket #655):

sys/ddb/db_input.c: revision 1.27
sys/ddb/db_lex.c: revision 1.23

Print db> prompt in db_read_line(), not db_readline().
The former is what DDB repl calls. The latter performs the actual
input so let other code use it without the unwanted db> prompt. It's
already used by ACPI (and AcpiOsWaitCommandReady supplies its own
prompt). I also use it for my uncommitted Forth scripting for DDB.
 1.26.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.44 21-Nov-2023  riastradh ddb: New db_stack_trace_print_ra.

Takes an optional extra argument for the return address so that the
stack parser has a chance to use instruction-dependent interpretation
of the frame to find parent frames.

Implemented only on Alpha for now, which needs it. Other
architectures just ignore the extra argument.

PR port-alpha/57716

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.43 02-Nov-2023  martin Back out the following revisions on behalf of core:

sys/sys/lwp.h: revision 1.228
sys/sys/pipe.h: revision 1.40
sys/kern/uipc_socket.c: revision 1.306
sys/kern/kern_sleepq.c: revision 1.84
sys/rump/librump/rumpkern/locks_up.c: revision 1.13
sys/kern/sys_pipe.c: revision 1.165
usr.bin/fstat/fstat.c: revision 1.119
sys/rump/librump/rumpkern/locks.c: revision 1.87
sys/ddb/db_xxx.c: revision 1.78
sys/ddb/db_command.c: revision 1.187
sys/sys/condvar.h: revision 1.18
sys/ddb/db_interface.h: revision 1.42
sys/sys/socketvar.h: revision 1.166
sys/kern/uipc_syscalls.c: revision 1.209
sys/kern/kern_condvar.c: revision 1.60

Add cv_fdrestart() [...]
Use cv_fdrestart() to implement fo_restart.
Simplify/streamline pipes a little bit [...]

This changes have caused regressions and need to be debugged.
The cv_fdrestart() addition needs more discussion.
 1.42 13-Oct-2023  ad Simplify/streamline pipes a little bit:

- Allocate only one struct pipe not two (no need to be bidirectional here).
- Then use f_flag (FREAD/FWRITE) to figure out what to do in the fileops.
- Never wake the other side or acquire long-term (I/O) lock unless needed.
- Whenever possible, defer wakeups until after locks have been released.
- Do some things locklessly in pipe_ioctl() and pipe_poll().

Some notable results:

- -30% latency on a 486DX2/66 doing 1 byte ping-pong within a single process.
- 2.5x less lock contention during "make cleandir" of src on a 48 CPU machine.
- 1.5x bandwith with 1kB messages on the same 48 CPU machine (8kB: same b/w).
 1.41 07-Oct-2023  ad Add some simple DDB show commands: condvar, selinfo, sleepq
 1.40 18-Apr-2021  mrg don't provide db_lstacktrace() for crash (yet?).
 1.39 18-Apr-2021  mrg db_lstacktrace() can't use db_stacktrace_print and log() directly.

log() takes a 'int level' first argument, that must be supplied.
add an inline wrapper that calls vlog() with LOG_INFO, and the
supplied va_list.

(not noticed because this macro is not used anywhere in src but
i have a use in some uncommited code, that now failed to compile.)
 1.38 10-Feb-2021  simonb Allow for MD code to use a different function than db_stack_trace_print()
to be used with db_stacktrace() and friends by pre-defining the
db_stacktrace_print macro.
 1.37 02-Jun-2019  mrg branches: 1.37.10;
add two db_stack_print_trace frontends that emit to the system log
or the user's terminal.

kind of wrong to be called db_*() when they'll typically be used
outside of ddb itself, but db_stacktrace() itself is no different.
fix this by making the stack trace support separate from ddb?
 1.36 04-Mar-2018  mlelstv branches: 1.36.4;
Add command to print device list.
 1.35 27-Oct-2017  joerg Revert printf return value change.
 1.34 27-Oct-2017  utkarsh009 [syzkaller] Cast all the printf's to (void *)
> as a result of new printf(9) declaration.
 1.33 04-Jan-2017  christos add a simple stacktrace macro
 1.32 13-Apr-2016  ozaki-r branches: 1.32.2;
ddb: rename show arptab to show routes

show arptab command of ddb is now inappropriate because it actually dumps
routes but arp entries aren't routes anymore. So rename it to show routes
and move the code from if_arp.c to route.c.

ok christos@
 1.31 06-Jan-2013  christos branches: 1.31.14;
remove previous, dmesg just works.
 1.30 06-Jan-2013  christos Add "show dmesg" that prints the contents of the message buffer.
 1.29 05-Jan-2013  christos Add "show panic" that shows the current panic string. two ports had it, and
it could be easily made MI.
 1.28 10-Feb-2012  christos branches: 1.28.6;
add __printflike where needed
 1.27 26-May-2011  joerg branches: 1.27.4; 1.27.8;
Introduce DDB_EXPR_FMT and replace the logic around DB_EXPR_T_IS_QUAD.
 1.26 10-Apr-2011  christos Add:
usage: show proc [/a] [/p] address|pid
/a == argument is an address of any lwp
/p == argument is a pid [default]
From: Vladimir Kirillov proger at wilab dot org dot ua
 1.25 18-Feb-2009  yamt branches: 1.25.4; 1.25.6;
- fix vmem unittest. rename VMEM_DEBUG so that it won't be abused again.
- reimplement vmem sanity checks with less code duplication.
- reimplement ddb vmem-related commands in a more consistent ways.
remove automatic whatis.
 1.24 25-Nov-2008  ad branches: 1.24.4;
Add some basic DDB stuff for modules.
 1.23 10-Jul-2008  blymn branches: 1.23.2;
Add a show files command that prints the vnodes associated with a
given struct proc and, if LOCKDEBUG is built in, the lock status of
the uvmobject.
 1.22 28-Apr-2008  martin branches: 1.22.2; 1.22.4; 1.22.6;
Remove clause 3 and 4 from TNF licenses
 1.21 07-Sep-2007  rmind branches: 1.21.20; 1.21.22; 1.21.24;
Implementation of POSIX message queues.

Reviewed by: <ad>, <tech-kern>
 1.20 30-Apr-2007  rmind branches: 1.20.2; 1.20.6; 1.20.8;
Import of POSIX Asynchronous I/O.
Seems to be quite stable. Some work still left to do.

Please note, that syscalls are not yet MP-safe, because
of the file and vnode subsystems.

Reviewed by: <tech-kern>, <ad>
 1.19 22-Feb-2007  matt branches: 1.19.4; 1.19.6;
Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.18 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.17 21-Jan-2006  uwe branches: 1.17.24;
Add CONSTCOND to DB_EXPR_T_IS_QUAD.
 1.16 01-Dec-2005  yamt branches: 1.16.2;
add "show all pools" command for ddb.
 1.15 01-Jun-2005  drochner branches: 1.15.2;
more constification fallout
 1.14 29-May-2005  christos Add lots of const.
 1.13 29-Apr-2005  yamt move decl of db_machine_command_table from db_interface.h to db_command.c
to avoid an array of incomplete type. found by gcc4.
 1.12 20-Sep-2003  thorpej branches: 1.12.8;
Add a "show sched_qs" command to dump the run queues. Format is:
1 pid.lid (p_comm)
pid.lid (p_comm)
...

If a queue has procs, but no sched_whichqs bit, it shows:
!1 pid.lid (p_comm)
 1.11 22-May-2003  briggs branches: 1.11.2;
Somehow overlooked in earlier commits: prototype db_kgdb_cmd().
 1.10 17-May-2003  scw On some platforms, sizeof(db_expr_t) > sizeof(long), so add a method
to select the right format string (at compile time) when displaying
variables of type db_expr_t.

This fixes a problem where ddb(4) would only display the low 32-bits
of registers for an ILP32 kernel on SH5, even though registers
(and db_expr_t) are always 64-bits wide.
 1.9 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.8 09-Nov-2001  thorpej Remove unneeded declarations of the db_machine_init() function. The
ARM ports are the only ones that actually have one, and it is about
to change.
 1.7 31-Jul-2001  atatat branches: 1.7.4;
Add an easy way to dump the message buffer from ddb.
 1.6 22-Jan-2001  jdolecek branches: 1.6.2; 1.6.4;
Require the machine-dependant DDB commands to be in db_machine_command_table[]
and link it directly to db_command_table[] so that it's not necessary
to do this at runtime. Make db_machine_command_table[] const on all ports.
g/c now unneded stuff, like db_machine_commands_install(), db_machine_init()

Patch written by enami.
 1.5 26-May-2000  jhawk Rename the machine-specific stack trace printing functions
from db_stack_trace_cmd() to db_stack_trace_print(),
and add an additional argument, a function pointer for an
output routine (i.e. printf() or db_printf()).

Add db_stack_trace_cmd() in db_command.[ch], calling
db_stack_trace_print() with db_printf() as the printer.

Move count==-1 special handling from db_stack_trace_print() [nee
db_stack_trace_cmd()] to db_stack_trace_cmd() [nascent here].

Again, I'm unable to test compilation on all affected platforms,
so advance apologies for potential brokenness.
 1.4 20-May-2000  jhawk Install "show arptab" (db_show_arptab) in the ddb command tree.
Move prototype from netinet/if_inarp.h to ddb/db_interface.h.
Change function to have standard ddb parameters (though they're
ignored).
 1.3 05-Sep-1998  christos branches: 1.3.12;
Assign copyright to TNF.
 1.2 07-May-1997  gwr Add db_kill_proc().
 1.1 05-Feb-1996  christos DDB prototype changes.
 1.3.12.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.6.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.4.1 03-Aug-2001  lukem update to -current
 1.6.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.6.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.7.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.11.2.5 11-Dec-2005  christos Sync with head.
 1.11.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.8.1 29-Apr-2005  kent sync with -current
 1.15.2.4 27-Oct-2007  yamt sync with head.
 1.15.2.3 03-Sep-2007  yamt sync with head.
 1.15.2.2 26-Feb-2007  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.2.1 01-Feb-2006  yamt sync with head.
 1.17.24.2 07-May-2007  yamt sync with head.
 1.17.24.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.19.6.1 11-Jul-2007  mjf Sync with head.
 1.19.4.2 09-Oct-2007  ad Sync with head.
 1.19.4.1 08-Jun-2007  ad Sync with head.
 1.20.8.1 06-Nov-2007  matt sync with HEAD
 1.20.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.20.2.1 10-Sep-2007  skrll Sync with HEAD.
 1.21.24.2 04-May-2009  yamt sync with head.
 1.21.24.1 16-May-2008  yamt sync with head.
 1.21.22.1 18-May-2008  yamt sync with head.
 1.21.20.3 17-Jan-2009  mjf Sync with HEAD.
 1.21.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.21.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.22.6.1 19-Oct-2008  haad Sync with HEAD.
 1.22.4.1 18-Jul-2008  simonb Sync with head.
 1.22.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.23.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.23.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.24.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.4.2 31-May-2011  rmind sync with head
 1.25.4.1 21-Apr-2011  rmind sync with head
 1.27.8.1 18-Feb-2012  mrg merge to -current.
 1.27.4.2 23-Jan-2013  yamt sync with head
 1.27.4.1 17-Apr-2012  yamt sync with head
 1.28.6.2 03-Dec-2017  jdolecek update from HEAD
 1.28.6.1 25-Feb-2013  tls resync with head
 1.31.14.2 05-Feb-2017  skrll Sync with HEAD
 1.31.14.1 22-Apr-2016  skrll Sync with HEAD
 1.32.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.36.4.1 10-Jun-2019  christos Sync with HEAD
 1.37.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 31-May-2020  rin Switch from kmem_intr_alloc(sz, KM_NOSLEEP) to kmem_alloc(sz, KM_SLEEP).

Clearly document these functions are *not* for DDB session, but for
permanent data storage when initializing DDB.
 1.3 31-May-2020  rin XXX
DDB can be running in the interrupt context, e.g., when activated from
console. Therefore, we use kmem_intr_alloc(9) and friends in order to
avoid assertion failure.
 1.2 08-Mar-2009  mrg branches: 1.2.2; 1.2.4; 1.2.6;
include ddb headers *after* sys/types.h or sys/param.h.
 1.1 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.2.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.6.1 08-Mar-2009  jym file db_kernel.c was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.2.4.2 04-May-2009  yamt sync with head.
 1.2.4.1 08-Mar-2009  yamt file db_kernel.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.2.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.2.2.1 08-Mar-2009  skrll file db_kernel.c was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.27 30-Aug-2022  riastradh ddb(9): New db_num_to_strbuf.

Like db_num_to_str, but writes to caller-provided buffer instead of
returning pointer to static storage.
 1.26 29-Jul-2020  uwe db_get_line - raw access to the DDB command line.

Provide a way for DDB commands to access the remainder of the command
line as-is.
 1.25 22-Nov-2019  ad Fix crash(8). Will revisit.
 1.24 02-Oct-2019  rin Simplify logic to get rid of implicit dependence on order of ASCII
codes of upper and lower cases ('a' > 'A').

Found by the lgtm bot.

No functional changes intended.
 1.23 29-Sep-2019  uwe Print db> prompt in db_read_line(), not db_readline().

The former is what DDB repl calls. The latter performs the actual
input so let other code use it without the unwanted db> prompt. It's
already used by ACPI (and AcpiOsWaitCommandReady supplies its own
prompt). I also use it for my uncommitted Forth scripting for DDB.
 1.22 26-May-2011  joerg branches: 1.22.56; 1.22.60;
Introduce DDB_EXPR_FMT and replace the logic around DB_EXPR_T_IS_QUAD.
 1.21 07-Mar-2009  ad branches: 1.21.4; 1.21.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.20 27-Nov-2005  yamt branches: 1.20.74; 1.20.84; 1.20.90;
make DDB_COMMANDONENTER sysctl. (ddb.commandonenter)
suggested by Christos Zoulas.
 1.19 26-Nov-2005  yamt add a new option DDB_COMMANDONENTER.
which can be useful for eg. broken console input.
 1.18 17-May-2003  scw branches: 1.18.2; 1.18.18; 1.18.26;
On some platforms, sizeof(db_expr_t) > sizeof(long), so add a method
to select the right format string (at compile time) when displaying
variables of type db_expr_t.

This fixes a problem where ddb(4) would only display the low 32-bits
of registers for an ILP32 kernel on SH5, even though registers
(and db_expr_t) are always 64-bits wide.
 1.17 02-Mar-2003  enami Don't specify string width in the low level function like db_num_to_str.
The pretty printing should be done much higher level, and anyway the
value 10 doesn't make sense.
 1.16 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.15 12-Nov-2001  lukem add RCSIDs
 1.14 08-Jul-2000  sommerfeld branches: 1.14.2; 1.14.4;
printf format safety
 1.13 06-Jun-2000  soren #include <sys/systm.h> for the snprintf() prototype.
 1.12 06-Jun-2000  jhawk Stop using DDB-specific "%n" kprintf() format specifier. This was
important as db_sym() can be called through printf() rather than
db_printf(), causing a trap as the standard %n usage is invoked.

The DDB-specific %n code should disappear from subr_prf.c soon...
 1.11 12-Apr-1999  pk branches: 1.11.2; 1.11.10;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.10 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.9 03-Feb-1997  cgd branches: 1.9.20;
fix various 64-bitness bugs.
 1.8 05-Feb-1996  christos DDB prototype changes.
 1.7 09-Oct-1994  mycroft db_error() does not return.
 1.6 09-Oct-1994  mycroft Clean up #includes.
 1.5 09-Oct-1994  mycroft Add prototypes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.20.2 12-Apr-1999  pk branches: 1.9.20.2.2;
Pullup copyright text corrections.
 1.9.20.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.9.20.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.14.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.18.26.1 29-Nov-2005  yamt sync with head.
 1.18.18.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 11-Dec-2005  christos Sync with head.
 1.20.90.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.84.1 28-Apr-2009  skrll Sync with HEAD.
 1.20.74.1 04-May-2009  yamt sync with head.
 1.21.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.1 31-May-2011  rmind sync with head
 1.22.60.2 01-Mar-2020  martin Pull up following revision(s) (requested by riastradh in ticket #746):

sys/ddb/db_lex.c: revision 1.25

Fix crash(8). Will revisit.
 1.22.60.1 26-Jan-2020  martin Pull up following revision(s) (requested by uwe in ticket #655):

sys/ddb/db_input.c: revision 1.27
sys/ddb/db_lex.c: revision 1.23

Print db> prompt in db_read_line(), not db_readline().
The former is what DDB repl calls. The latter performs the actual
input so let other code use it without the unwanted db> prompt. It's
already used by ACPI (and AcpiOsWaitCommandReady supplies its own
prompt). I also use it for my uncommitted Forth scripting for DDB.
 1.22.56.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17 30-Aug-2022  riastradh ddb(9): New db_num_to_strbuf.

Like db_num_to_str, but writes to caller-provided buffer instead of
returning pointer to static storage.
 1.16 29-Jul-2020  uwe db_get_line - raw access to the DDB command line.

Provide a way for DDB commands to access the remainder of the command
line as-is.
 1.15 27-Nov-2005  yamt make DDB_COMMANDONENTER sysctl. (ddb.commandonenter)
suggested by Christos Zoulas.
 1.14 26-Nov-2005  yamt add a new option DDB_COMMANDONENTER.
which can be useful for eg. broken console input.
 1.13 15-Feb-2002  simonb branches: 1.13.16; 1.13.32; 1.13.40;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.12 06-Jun-2000  jhawk branches: 1.12.4; 1.12.6;
Stop using DDB-specific "%n" kprintf() format specifier. This was
important as db_sym() can be called through printf() rather than
db_printf(), causing a trap as the standard %n usage is invoked.

The DDB-specific %n code should disappear from subr_prf.c soon...
 1.11 30-Mar-2000  simonb branches: 1.11.2;
Remove redundant decl of db_radix, it's also in <ddb/db_output.h>.
 1.10 12-Apr-1999  pk branches: 1.10.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.9 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.8 03-Feb-1997  cgd branches: 1.8.20;
fix various 64-bitness bugs.
 1.7 05-Feb-1996  christos DDB prototype changes.
 1.6 09-Oct-1994  mycroft Clean up #includes.
 1.5 09-Oct-1994  mycroft Add prototypes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 15-Feb-1994  mycroft Remove RCS logs.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.20.2 12-Apr-1999  pk branches: 1.8.20.2.2;
Pullup copyright text corrections.
 1.8.20.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.8.20.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.11.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.12.6.1 16-Mar-2002  jdolecek Catch up with -current.
 1.12.4.1 28-Feb-2002  nathanw Catch up to -current.
 1.13.40.1 29-Nov-2005  yamt sync with head.
 1.13.32.1 21-Jun-2006  yamt sync with head.
 1.13.16.1 11-Dec-2005  christos Sync with head.
 1.7 12-Apr-2011  mrg include <sys/cpu.h> when using cpu specific info. fixes building
these as part of sparc64 crash(8).
 1.6 14-Jan-2011  rmind branches: 1.6.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.5 17-Dec-2009  rmind branches: 1.5.4;
Replace few USER_TO_UAREA/UAREA_TO_USER uses, reduce sys/user.h inclusions.
 1.4 09-Mar-2009  mrg branches: 1.4.2; 1.4.4; 1.4.6;
include <stdbool.h> if not _KERNEL, and don't include kauth.h if _KERNEL.

now crash builds on i386.
 1.3 08-Mar-2009  mrg include <sys/user.h>
 1.2 08-Mar-2009  mrg include ddb headers *after* sys/types.h or sys/param.h.
 1.1 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.4.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.6.1 09-Mar-2009  jym file db_lwp.c was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.4.4.3 11-Mar-2010  yamt sync with head
 1.4.4.2 04-May-2009  yamt sync with head.
 1.4.4.1 09-Mar-2009  yamt file db_lwp.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.4.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.4.2.1 09-Mar-2009  skrll file db_lwp.c was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.5.4.2 21-Apr-2011  rmind sync with head
 1.5.4.1 05-Mar-2011  rmind sync with head
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2 10-Feb-2012  christos add __printflike where needed
 1.1 07-Mar-2009  ad branches: 1.1.2; 1.1.4; 1.1.6; 1.1.18; 1.1.22;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.1.22.1 18-Feb-2012  mrg merge to -current.
 1.1.18.1 17-Apr-2012  yamt sync with head
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 07-Mar-2009  jym file db_lwp.h was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 07-Mar-2009  yamt file db_lwp.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.1.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1 07-Mar-2009  skrll file db_lwp.h was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.38 07-Oct-2023  ad Oops, fix crash(8) build
 1.37 07-Oct-2023  ad Add db_print_timespec().
 1.36 26-Jan-2020  uwe Fix typo in comment.
 1.35 12-Sep-2019  uwe branches: 1.35.2;
db_putchar - check if we need to wrap at $maxwidth after whitespace.
That fixes orphaned first character in something like:

|Stopped in ... longsymbol+0xf00: |
|i
|nsn
 1.34 16-Sep-2018  mrg branches: 1.34.4;
call cnpollc(1) and cnpollc(0) around cngetc().

(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still). not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)
 1.33 01-Sep-2012  matt branches: 1.33.32; 1.33.38; 1.33.40;
Use _KERNEL_OPT
 1.32 01-Sep-2012  matt Make DB_MAX_LINES a kernel option
 1.31 17-Jul-2011  joerg branches: 1.31.2;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.30 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.29 11-Dec-2005  christos branches: 1.29.74; 1.29.84; 1.29.90;
merge ktrace-lwp.
 1.28 29-May-2005  christos Add lots of const.
 1.27 15-Feb-2002  simonb branches: 1.27.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.26 12-Nov-2001  lukem add RCSIDs
 1.25 01-Jul-2001  mrg branches: 1.25.2;
allow one to #define DB_MAX_LINE and DB_MAX_WIDTH independantly.
 1.24 24-Feb-2001  cgd branches: 1.24.2;
Avoid crud after #endif.
 1.23 09-Aug-2000  tv Add two new functions, db_format_radix() and db_format_hex(), which supplant
the former %r and %z nonstandard kprintf strings.
 1.22 30-Mar-2000  augustss Die, register, die!
 1.21 08-Mar-2000  jdolecek Fix obvious off-by-one error in db_output().
Fixes kern/9570 by John Hawkinson.
 1.20 28-Oct-1999  lukem - change db_cmd_list() to list commands vertically rather than horizontally
- sort entries in the various command tables, so that the `help' lists
are easier to use. this included hacking db_machine_commands_install()
to search for the "machine" entry to change the `more cmds' pointer,
rather than assuming it was the first entry
- add a `sync' command, which is effectively `reboot 0x100'.
- remove db_help_cmd(); it was unused (and was almost a duplicate of
db_cmd_list()).
- move some extern decls to db_output.h, since they're used in more than one
place now
- rename NEXT_TAB to DB_NEXT_TAB and move to db_output.h
 1.19 12-Apr-1999  pk branches: 1.19.2; 1.19.4; 1.19.6;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.18 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.17 24-Oct-1997  chuck branches: 1.17.8;
kill db_ksprintn, db_printf_guts, kdbprintf, db_printf.
db_printf moves to kern/subr_prf.c and uses the new kprintf located there.
 1.16 03-Feb-1997  cgd needs systm.h for prototypes
 1.15 28-Oct-1996  fvdl Make this compile with -Wcast-qual
 1.14 25-Sep-1996  christos Recognize %.2x as %02x
 1.13 01-Apr-1996  christos Fix cut'n'paste'o in %p previous fix.
 1.12 31-Mar-1996  christos Recognize %p formats so that ps/m works in ddb
 1.11 30-Mar-1996  christos - Fix db_printf format args.
- Recognize ':' as recursive printf; fixes PR/835
- cleanup error(1) output.
 1.10 05-Feb-1996  christos DDB prototype changes.
 1.9 16-Oct-1995  mycroft Fix nits pointed out by GCC 2.7.
 1.8 29-Jun-1994  deraadt knf
 1.7 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.6 18-Dec-1993  mycroft Canonicalize all #includes.
 1.5 02-Aug-1993  mycroft branches: 1.5.2;
Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
 1.4 15-Jul-1993  brezak Add 'ps' command. Add -more- pager to output from Mach ddb.
 1.3 20-May-1993  cgd add explicit rcs id
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.17.8.2 12-Apr-1999  pk branches: 1.17.8.2.2;
Pullup copyright text corrections.
 1.17.8.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.17.8.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.19.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.4.1 15-Nov-1999  fvdl Sync with -current
 1.19.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.19.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.24.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.24.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.24.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.25.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.25.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.27.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.90.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.29.84.1 28-Apr-2009  skrll Sync with HEAD.
 1.29.74.1 04-May-2009  yamt sync with head.
 1.31.2.1 30-Oct-2012  yamt sync with head
 1.33.40.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.33.40.1 10-Jun-2019  christos Sync with HEAD
 1.33.38.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.33.32.1 27-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1037):

sys/dev/usb/uhub.c: revision 1.139
sys/external/bsd/dwc2/dwc2.c: revision 1.55
sys/ddb/db_output.c: revision 1.34
sys/ddb/db_command.c: revision 1.160
sys/dev/usb/ehci.c: revision 1.264
sys/dev/usb/xhci.c: revision 1.99
sys/dev/usb/ehci.c: revision 1.265
sys/kern/subr_userconf.c: revision 1.27
sys/dev/usb/ehcivar.h: revision 1.46
sys/dev/usb/ohci.c: revision 1.287
sys/dev/usb/uhci.c: revision 1.284
sys/dev/usb/usbdi.c: revision 1.178
sys/dev/usb/usb.c: revision 1.172
sys/dev/pci/xhci_pci.c: revision 1.14
sys/dev/usb/usb.c: revision 1.173
sys/dev/usb/usb.c: revision 1.174
share/man/man4/usb.4: revision 1.110
sys/ddb/db_command.c: revision 1.159
sys/dev/usb/usb_subr.c: revision 1.227
sys/dev/usb/uhcivar.h: revision 1.56
(all via patch)

consolidate the handling of polling across HC drivers, and generic USB:
- don't take mutexes if polling
- normalise the code across all drivers
- add some not yet code to block discovery to/from polling
- minor CSE
- adjust comment for usbd_set_polling() to reality now i properly
understand what it is used for and why.

this, with a hack to make RB_ASKNAME to wait 5 seconds allows boot -a
work with USB keyboards. there are still multiple issues remaining:
- discovery and polling need to be mutually exclusive
- attachment of ukbd and wskbd is not handled by config_pending, and
the 5 second delay isn't going to always be enough.

call cnpollc(1) and cnpollc(0) around cngetc().
(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still). not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)


When this file is used when not building the kernel (eg: /usr/sbin/crash)
make cnpollc() go away.


reorder some struct members to remove holes.


add config_pending usage to uhub and general USB device attachment.
- call config_pending_incr() and config_pending_decr() around attaching
devices against "usbdevif" attribute.

uhub:
- convert sc_explorepending and sc_running to bool. add new sc_first_explore.
- call config_pending_incr() at the start of uhub_attach(). dropped in
uhub_explore(), if this is the first explore.


implement a gross hack to fix "boot -a" on systems with usb keyboards on
systems with ehci handover to uhci (and maybe ohci), and fix a similar
problem for "boot -s".

there is effort to ensure that all devices attached via USB are probed
before RB_ASKNAME or RB_SINGLE attempts to ask any questions on the console,
and largely this works, often by chance, today, for USB disks and root.
i've recently pushed this more into uhub and general USB device attachment
as well, and kept a config_pending reference across the first explore of
a bus. these fix many issues with directly attached hubs.

however, on systems where devices connected to ehci ports are handed over
to a companion uhci or ohci port, it may not be the first, or even second,
bus explore that finds the device finally before attachment, and at this
point all config_pending references are dropped.

there is no direct communication between drivers, the potentials are
looked up but their device_t is only used for generic things like the name,
so informing the correct companion to expect a device and deal with the
config_pending references is not possible without some fairly ugly layer
violations or multi-level callbacks (eg, we have "ehci0", and usually an
the relevant companion, eg, "uhci2", but it is the uhub that uhci2 has
attached that will deal with the device attachment.)

with the above fixes to generic USB code, the disown happens during the
first explore. the hack works by, at this point, checking if (a) root
is not mounted, (b) single user or ask name are set, and (c) if the hack
as not been triggered already. if all 3 conditions are true, then a
config_pending_incr() is called and a callback is triggered for (default)
5 seconds to call config_pending_decr(). ehci detach pauses waiting for
this callback if scheduled.

this allows enough time for the uhub and the ukbd/wskbd to attach before
the RK_ASKROOT prompts appear. testing shows it takes between 1.5 and
2 seconds for the keyboard to appear after the disown occurs.

Index: dev/usb/ehcivar.c
- new sc_compcallout, sc_compcallout, sc_complock, and a state for th
handover hack.

Index: dev/usb/ehci.c
ehci_init():
- use aprint_normal_dev() instead of manual device_xname().
- initialise sc_compcallout, sc_compcallout, sc_complock, and sc_comp_state.
ehci_detach():
- if there are companion controllers, tear own the above, including waiting
if there is a callback scheduled.
ehci_disown_callback():
- new callout to call config_pending_decr() in the the future.
schedule this ca
ehci_disown_sched_callback():
- if booting to single user or asking names, call config_pending_incr() and
schedule the callout above, default 5 second delay.
ehci_disown():
- if disowning a port call ehci_disown_sched_callback().
deal with partial attach failures in usb_attach vs usb_detach aka PR 53598.
- make sure xhci's sc->sc_ios is NULL if failure happens.
- rearrange usb_attach() / usb_doattach() to make it simpler to clean up.
- move usb_async_intr softint into usb_once_init(). previously, each USB
controller would start a new one, and leave the old one leaked.
- handle controller interrupts without a bus attached


remove usb(4)'s "flags 1" code. it has been dead for a while,
as it runs during the interrupts part of configuration now,
and all the devices try attach as early as possible, including
any root or boot required disk or keyboard device, which is
what this flag was for.
 1.34.4.1 26-Jan-2020  martin Pull up following revision(s) (requested by uwe in ticket #654):

sys/ddb/db_output.c: revision 1.35
sys/ddb/db_output.c: revision 1.36

db_putchar - check if we need to wrap at $maxwidth after whitespace.

That fixes orphaned first character in something like:
|Stopped in ... longsymbol+0xf00: |
|i
|nsn

Fix typo in comment.
 1.35.2.1 29-Feb-2020  ad Sync with head.
 1.24 07-Oct-2023  ad Oops, fix crash(8) build
 1.23 07-Oct-2023  ad Add db_print_timespec().
 1.22 28-Jun-2020  simonb Protect against multiple inclusion.
 1.21 15-Mar-2012  joerg Add __printflike attribution to use vprintf and friends with an argument
as format string.
 1.20 10-Feb-2012  christos add __printflike where needed
 1.19 17-Jul-2011  joerg branches: 1.19.2; 1.19.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.18 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.17 05-Jun-2002  drochner branches: 1.17.108; 1.17.118; 1.17.124;
provide a db_vprintf() which is exactly what the name suggests
 1.16 15-Feb-2002  simonb branches: 1.16.8;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.15 09-Aug-2000  tv branches: 1.15.2; 1.15.4;
Add two new functions, db_format_radix() and db_format_hex(), which supplant
the former %r and %z nonstandard kprintf strings.
 1.14 09-Aug-2000  tv Change kprintf attribute to printf.
 1.13 28-Oct-1999  lukem - change db_cmd_list() to list commands vertically rather than horizontally
- sort entries in the various command tables, so that the `help' lists
are easier to use. this included hacking db_machine_commands_install()
to search for the "machine" entry to change the `more cmds' pointer,
rather than assuming it was the first entry
- add a `sync' command, which is effectively `reboot 0x100'.
- remove db_help_cmd(); it was unused (and was almost a duplicate of
db_cmd_list()).
- move some extern decls to db_output.h, since they're used in more than one
place now
- rename NEXT_TAB to DB_NEXT_TAB and move to db_output.h
 1.12 12-Apr-1999  pk branches: 1.12.2; 1.12.4; 1.12.6;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.11 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.10 24-Oct-1997  chuck branches: 1.10.8;
kill kdbprintf [use db_printf]
 1.9 04-Apr-1996  cgd change more __kprintf__ format attributes to use __kprintf_attribute__,
rather than just __attribute__, so they can be #defined out on non-NetBSD
versions of gcc.
 1.8 31-Mar-1996  christos Add __kprintf__ attributes to the printf functions
 1.7 05-Feb-1996  christos DDB prototype changes.
 1.6 16-Oct-1995  mycroft Fix nits pointed out by GCC 2.7.
 1.5 09-Oct-1994  mycroft Add prototypes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 15-Feb-1994  mycroft Remove RCS logs.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.8.2 12-Apr-1999  pk branches: 1.10.8.2.2;
Pullup copyright text corrections.
 1.10.8.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.10.8.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.4.1 15-Nov-1999  fvdl Sync with -current
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.15.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.15.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.16.8.1 20-Jun-2002  gehenna catch up with -current.
 1.17.124.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.118.1 28-Apr-2009  skrll Sync with HEAD.
 1.17.108.1 04-May-2009  yamt sync with head.
 1.19.6.2 05-Apr-2012  mrg sync to latest -current.
 1.19.6.1 18-Feb-2012  mrg merge to -current.
 1.19.2.1 17-Apr-2012  yamt sync with head
 1.12 21-Nov-2023  riastradh ddb: New db_stack_trace_print_ra.

Takes an optional extra argument for the return address so that the
stack parser has a chance to use instruction-dependent interpretation
of the frame to find parent frames.

Implemented only on Alpha for now, which needs it. Other
architectures just ignore the extra argument.

PR port-alpha/57716

XXX pullup-10
XXX pullup-9
XXX pullup-8
 1.11 06-Oct-2021  uwe KNF: The function type must be declared on a line by itself.
 1.10 20-Jul-2021  christos need <sys/param.h> for COHERENCY_UNIT
 1.9 27-Jan-2019  pgoyette branches: 1.9.16;
Merge the [pgoyette-compat] branch
 1.8 27-May-2018  uwe branches: 1.8.2;
Add missing $NetBSD$ comment at the beginning.
 1.7 17-Feb-2018  sevan branches: 1.7.2;
Opt to print a backtrace on panic by default with the intention of improving bug reports.
Instead of relying on ddb.onpanic=2, introduce a new sysctl called dumpstack to handle this.
via <jmcneill> channeled through <mrg> on tech-kern[1]

[1] https://mail-index.netbsd.org/tech-kern/2018/02/15/msg023103.html
 1.6 28-Dec-2017  christos - add ddb.panicstackframes to avoid scrolling the interesting parts of panic
stacktraces off.
- change valuep to void * to avoid casts
- sort and use c99 initializers in variables array
 1.5 27-Oct-2017  joerg Revert printf return value change.
 1.4 27-Oct-2017  utkarsh009 [syzkaller] Cast all the printf's to (void *)
> as a result of new printf(9) declaration.
 1.3 22-Jan-2014  christos branches: 1.3.4;
add a return in the panic message
 1.2 10-Feb-2013  christos branches: 1.2.2; 1.2.4;
need <sys/types.h> for various crap that other headers use (pid_t etc).
 1.1 10-Feb-2013  apb Move the DDB-specific part of vpanic() to a new db_panic() function,
defined in ddb/db_panic.c and declared in ddb/ddbvar.h. No functional
change.

The copyright years in db_panic.c are the years in which changes were
made to the code that has now been moved to db_panic.c. No pre-NetBSD
copyright notice is needed because revision 1.12 of subr_prf.c had only
the trivial "#ifdef DDB \\ Debugger(); \\ #endif"
 1.2.4.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.2 25-Feb-2013  tls resync with head
 1.2.4.1 10-Feb-2013  tls file db_panic.c was added on branch tls-maxphys on 2013-02-25 00:29:10 +0000
 1.2.2.1 18-May-2014  rmind sync with head
 1.3.4.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.3.4.1 22-Jan-2014  yamt file db_panic.c was added on branch yamt-pagecache on 2014-05-22 11:40:19 +0000
 1.7.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.8.2.1 10-Jun-2019  christos Sync with HEAD
 1.9.16.1 01-Aug-2021  thorpej Sync with HEAD.
 1.29 10-Mar-2020  christos Make the db_kernelonly() macro visible to all files and re-use it.
Register access is kernel only.
 1.28 12-Apr-2011  mrg branches: 1.28.56;
include <sys/cpu.h> when using cpu specific info. fixes building
these as part of sparc64 crash(8).
 1.27 07-Mar-2009  ad branches: 1.27.4; 1.27.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.26 22-Feb-2007  thorpej branches: 1.26.42; 1.26.52; 1.26.58;
TRUE -> true, FALSE -> false
 1.25 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.24 16-Nov-2006  christos branches: 1.24.4;
__unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 11-Dec-2005  christos branches: 1.22.20; 1.22.22;
merge ktrace-lwp.
 1.21 01-Jun-2005  drochner branches: 1.21.2;
more constification fallout
 1.20 29-May-2005  christos Add lots of const.
 1.19 10-Nov-2002  thorpej branches: 1.19.6;
Fix signed/unsigned comparison warnings.
 1.18 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.17 12-Nov-2001  lukem add RCSIDs
 1.16 13-May-2001  ross branches: 1.16.2;
The current API for MD support doesn't directly support the documented /u
option to show reg /u. Fix this by adding a modif[ier] field to struct
db_variable.
 1.15 18-Jan-2001  jdolecek branches: 1.15.2;
make db_[e]regs[] const
 1.14 09-Aug-2000  tv Add two new functions, db_format_radix() and db_format_hex(), which supplant
the former %r and %z nonstandard kprintf strings.
 1.13 06-Jun-2000  jhawk Stop using DDB-specific "%n" kprintf() format specifier. This was
important as db_sym() can be called through printf() rather than
db_printf(), causing a trap as the standard %n usage is invoked.

The DDB-specific %n code should disappear from subr_prf.c soon...
 1.12 30-Mar-2000  augustss branches: 1.12.2;
Die, register, die!
 1.11 12-Apr-1999  pk branches: 1.11.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.10 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.9 12-Feb-1999  thorpej branches: 1.9.2;
Fix printf format problems on Alpha.
 1.8 31-Jan-1998  ross Print more info on ps/w, note the current proc, and properly declare db_maxoff.
 1.7 04-Feb-1997  cgd fix printf format widths
 1.6 03-Feb-1997  mycroft db_expr_t became a long.
 1.5 05-Feb-1996  christos DDB prototype changes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.9.2.2 12-Apr-1999  pk branches: 1.9.2.2.2;
Pullup copyright text corrections.
 1.9.2.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.9.2.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.12.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.2.4 11-Nov-2002  nathanw Catch up to -current
 1.15.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.15.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.16.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.16.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.6.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.2.2 26-Feb-2007  yamt sync with head.
 1.21.2.1 30-Dec-2006  yamt sync with head.
 1.22.22.2 10-Dec-2006  yamt sync with head.
 1.22.22.1 22-Oct-2006  yamt sync with head
 1.22.20.1 18-Nov-2006  ad Sync with head.
 1.24.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.26.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.26.42.1 04-May-2009  yamt sync with head.
 1.27.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.27.4.1 21-Apr-2011  rmind sync with head
 1.28.56.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.16 15-Apr-2024  skrll Fix alignment of ddb 'ps/[lw]' output. LID matches PID and has more digits.
 1.15 22-Jan-2024  skrll Fix column alignment in ps/w output
 1.14 11-Jan-2021  simonb branches: 1.14.18;
For "ps/a" print all of p_comm instead of just the first 10 chars, add a
space after PID, left justify the command name.
 1.13 30-Oct-2020  skrll branches: 1.13.2;
Trailing whitespace
 1.12 04-Apr-2020  mlelstv also print the LWP reference count.
 1.11 26-Feb-2020  hikaru Correct PPID of "show all procs/n"
 1.10 15-Feb-2020  ad - Move the LW_RUNNING flag back into l_pflag: updating l_flag without lock
in softint_dispatch() is risky. May help with the "softint screwup"
panic.

- Correct the memory barriers around zombies switching into oblivion.
 1.9 08-Jan-2020  ad Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
calling cpu_switchto(). It's not safe to let other actors mess with the
LWP (in particular l->l_cpu) while it's still context switching. This
removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead. Everything
is in cache anyway so it wasn't buying much by trying to avoid saving old
state. This means cpu_switchto() will never be called with prevlwp ==
NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
 1.8 02-Nov-2018  maxv branches: 1.8.6;
no, should be dst
 1.7 02-Nov-2018  maxv Don't overflow on the strings we read. Introduce db_read_string(), which
stops on '\0'. Probably this doesn't matter a lot because the read is
supposed to be safe, but let's not have bugs in the debugger.

Detected by kASan, via skrll@ on aarch64, by typing "ps/l" on DDB.
 1.6 23-Oct-2011  jym branches: 1.6.52; 1.6.54;
Like ddb(4) "ps/l", use '>' sign to indicate running LWPs for the /w
modifier.
 1.5 12-Apr-2011  nakayama Fix GENERIC_SUN4U build.
 1.4 10-Apr-2011  christos Add:
usage: show proc [/a] [/p] address|pid
/a == argument is an address of any lwp
/p == argument is a pid [default]
From: Vladimir Kirillov proger at wilab dot org dot ua
 1.3 09-Mar-2009  mrg branches: 1.3.2; 1.3.4; 1.3.6; 1.3.10; 1.3.12;
include <stdbool.h> if not _KERNEL, and don't include kauth.h if _KERNEL.

now crash builds on i386.
 1.2 08-Mar-2009  mrg include ddb headers *after* sys/types.h or sys/param.h.
 1.1 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.3.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.10.1 21-Apr-2011  rmind sync with head
 1.3.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.6.1 09-Mar-2009  jym file db_proc.c was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.3.4.2 04-May-2009  yamt sync with head.
 1.3.4.1 09-Mar-2009  yamt file db_proc.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.3.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.3.2.1 09-Mar-2009  skrll file db_proc.c was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.6.54.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.54.1 10-Jun-2019  christos Sync with HEAD
 1.6.52.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.8.6.2 29-Feb-2020  ad Sync with head.
 1.8.6.1 17-Jan-2020  ad Sync with head.
 1.13.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.14.18.1 18-Apr-2024  martin Pull up following revision(s) (requested by skrll in ticket #665):

sys/ddb/db_proc.c: revision 1.16

Fix alignment of ddb 'ps/[lw]' output. LID matches PID and has more digits.
 1.1 07-Mar-2009  ad branches: 1.1.2; 1.1.4; 1.1.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 07-Mar-2009  jym file db_proc.h was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 07-Mar-2009  yamt file db_proc.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.1.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1 07-Mar-2009  skrll file db_proc.h was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.33 19-Sep-2014  matt Add description of inst_return
 1.32 19-Oct-2013  martin Mark a potentialy unused variable
 1.31 23-Sep-2007  martin branches: 1.31.56; 1.31.66; 1.31.72;
Minor clenaup - db_cmd_loop_done is a bool nowadays, so use true/false
instead of 0/1.
Also make db_init_commands() non-static.
 1.30 22-Feb-2007  thorpej branches: 1.30.4; 1.30.16; 1.30.18; 1.30.20;
TRUE -> true, FALSE -> false
 1.29 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.28 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.27 16-Nov-2006  christos branches: 1.27.4;
__unused removal on arguments; approved by core.
 1.26 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.25 02-Apr-2006  he branches: 1.25.8; 1.25.10;
Now that BKPT_SET takes two arguments, supply the second argument.
 1.24 11-Dec-2005  christos branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10; 1.24.12;
merge ktrace-lwp.
 1.23 01-Jun-2005  drochner branches: 1.23.2;
more constification fallout
 1.22 15-Feb-2002  simonb branches: 1.22.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.21 12-Nov-2001  lukem add RCSIDs
 1.20 30-Mar-2000  augustss branches: 1.20.6; 1.20.8;
Die, register, die!
 1.19 21-Apr-1999  thorpej branches: 1.19.2;
Fix a problem where SOFTWARE_SSTEP would skip one instruction each time
on the Alpha.
 1.18 12-Apr-1999  pk Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.17 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.16 25-Nov-1998  mycroft branches: 1.16.4;
Do branch forking for inst_return() instructions, too.
 1.15 04-Jul-1998  jonathan defopt DDB.
 1.14 03-Apr-1998  pk If `SOFTWARE_SSTEP' is defined then kgdb_stub.c needs the single-step
emulation in db_run.c:

- re-arrange `db_*_single_step()' and `db_*_temp_breakpoint()' -
which are only used in the `SOFTWARE_SSTEP' case - so these
are available to the KGDB code.
- make other code in db_run.c conditional on `DDB'.
 1.13 10-Dec-1997  pk Fixes for software-assisted single-stepping from Chuck Silvers.
 1.12 10-Sep-1997  pk Use the macro PC_ADVANCE(), if defined, to skip over a breakpoint.
 1.11 26-Jun-1997  thorpej branches: 1.11.4;
Fixup the software single-step code (used on architectures where there
is no hardware support for single-stepping):
- Fix branch prediction and delay slot computation (for the MIPS).
- Correctly deal with branch taken vs. branch not taken cases, and
self-branches.
- General cleanup, including types botches.
Partially from Mach 3, with a bunch of cleanup work by me.
 1.10 06-Feb-1997  gwr FIXUP_PC_AFTER_BREAK now takes an arg of type db_regs_t *
 1.9 03-Feb-1997  cgd part of the SOFTWARE_SSTEP code was mips-specific. #ifdef it appropriately.
fix various 64-bitness bugs.
fix various -Wall bugs.
 1.8 05-Feb-1996  christos DDB prototype changes.
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 18-Dec-1993  mycroft Canonicalize all #includes.
 1.3 15-Dec-1993  briggs Non i386 machines are polite and don't point at instructions. They
count 'em. Just to be nice, access the program counter with a macro...
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.2 22-Jan-1994  briggs Get rid of explicit reference to i386 register.
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.11.4.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.16.4.2 12-Apr-1999  pk branches: 1.16.4.2.2;
Pullup copyright text corrections.
 1.16.4.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.16.4.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.19.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.20.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.20.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.6.2 28-Feb-2002  nathanw Catch up to -current.
 1.20.6.1 14-Nov-2001  nathanw Catch up to -current.
 1.22.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.23.2.4 27-Oct-2007  yamt sync with head.
 1.23.2.3 26-Feb-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 21-Jun-2006  yamt sync with head.
 1.24.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.24.10.1 19-Apr-2006  elad sync with head.
 1.24.8.1 11-Apr-2006  yamt sync with head
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.25.10.2 10-Dec-2006  yamt sync with head.
 1.25.10.1 22-Oct-2006  yamt sync with head
 1.25.8.1 18-Nov-2006  ad Sync with head.
 1.27.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.30.20.1 06-Oct-2007  yamt sync with head.
 1.30.18.1 06-Nov-2007  matt sync with HEAD
 1.30.16.1 02-Oct-2007  joerg Sync with HEAD.
 1.30.4.1 09-Oct-2007  ad Sync with head.
 1.31.72.1 18-May-2014  rmind sync with head
 1.31.66.2 03-Dec-2017  jdolecek update from HEAD
 1.31.66.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31.56.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.11 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.10 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.9 11-Dec-2005  christos branches: 1.9.26;
merge ktrace-lwp.
 1.8 01-Jun-2005  drochner branches: 1.8.2;
more constification fallout
 1.7 15-Feb-2002  simonb branches: 1.7.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.6 15-Feb-2001  cgd branches: 1.6.2; 1.6.4;
put crud after #endif in comments
 1.5 12-Apr-1999  pk branches: 1.5.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.4 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.3 05-Feb-1996  christos branches: 1.3.24;
DDB prototype changes.
 1.2 09-Oct-1994  mycroft Clean up #includes.
 1.1 09-Oct-1994  mycroft Add prototypes.
 1.3.24.2 12-Apr-1999  pk branches: 1.3.24.2.2;
Pullup copyright text corrections.
 1.3.24.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.3.24.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.1 12-Mar-2001  bouyer Sync with HEAD.
 1.6.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.7.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.1 26-Feb-2007  yamt sync with head.
 1.9.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.71 30-Aug-2022  riastradh ddb(9): Make db_symstr safe to use concurrently with pserialize(9).
 1.70 30-Aug-2022  riastradh ddb(4): Use db_num_to_strbuf in db_symstr.

Simplifies it and will make safer to use.
 1.69 13-Dec-2021  kre mv out: label into the #ifdef _KERNEL section, as it is only
referenced from there. Hopefully ubbreak buikd of usr.sbin/crash
 1.68 13-Dec-2021  chs ddb: fix function names of "noreturn" functions in stack traces.

when looking up function names for stack traces (where the addresses are the
return addresses of function calls), if the address is the first instruction
in the function, assume that the function being called is marked "noreturn"
and that the function containing the call is actually the function immediately
before the address that we looked up. to find the correct function name,
do the lookup again with (address - 1) and then add one to the offset within
the function that we find.
 1.67 12-Apr-2021  mrg avoid assigning both signed and unsigned variables in the same statement.
 1.66 30-Mar-2020  maya branches: 1.66.6;
Remove a.out leftovers (unused)
 1.65 03-Nov-2017  maxv branches: 1.65.4;
Handle absolute relocations coming from the kernel: preserve SHN_ABS in
the kernel and module symbols, and when relocating a symbol that has
SHN_ABS, take its value as-is and don't return an error if it equals zero.

Sent on tech-kern@.
 1.64 10-Feb-2012  christos branches: 1.64.6;
fix printf formats.
 1.63 09-Feb-2012  christos Re-indent, and factor out strlen() now that we have more space.
No functional change.
 1.62 09-Feb-2012  christos Remove bogus code in the non kernel case involving end[]. In this case
end[] is the end of the crash program symbols, so using that as the
end of the kernel symbol table is just wrong.
 1.61 11-Apr-2011  mrg branches: 1.61.4; 1.61.8;
avoid compiling dead code into crash.
 1.60 11-Apr-2011  mrg obsolete DB_AOUT_SYMBOLS. however, we need to leave most of the code
in db_sym.[ch] as it is used by the elf version of crash(8).

i will be cleaning up the db_sym.c code in a follow up commit to avoid
having dead code compiled.
 1.59 07-Mar-2009  ad branches: 1.59.4; 1.59.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.58 30-Nov-2008  martin branches: 1.58.4;
As discussed on tech-kern: mutex_init is too heavyweight for early bootstrap
phases, so move the initialization of the ksyms mutex back into main via
a function called ksyms_init. Rename the existing (but quite different)
ksyms_init* variations into ksyms_addsyms_elf() and ksyms_addsyms_explicit()
and adapt machdep code accordingly.
 1.57 24-Oct-2008  christos branches: 1.57.2;
don't hold locks in ddb (call ksyms_getval_unlocked()), pointed out by ad.
 1.56 22-Feb-2007  thorpej branches: 1.56.38; 1.56.42; 1.56.48;
TRUE -> true, FALSE -> false
 1.55 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.54 16-Nov-2006  christos branches: 1.54.4;
__unused removal on arguments; approved by core.
 1.53 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.52 11-Dec-2005  christos branches: 1.52.20; 1.52.22;
merge ktrace-lwp.
 1.51 29-May-2005  christos branches: 1.51.2;
Add lots of const.
 1.50 28-Mar-2005  christos remove stray error(1) comment.
 1.49 26-Feb-2005  perry nuke trailing whitespace
 1.48 15-Feb-2005  cube The way I handled /dev/ksyms requests vs. kernel requests was completely
broken. Inside the kernel, we always have to use the real values of the
st_name fields, and only do the math when the request comes from userland.

No need for ksyms_getval_from{kernel,userland} hack anymore. However, a
different version will be asked for pull-up in -2{,-0}, one that doesn't
break the API, that is.

Fixes PR#29133 from Jens Kessmeier.
 1.47 16-Jan-2005  chs branches: 1.47.2;
reduce db_maxoff from 256MB to 1MB, that should be plenty.
 1.46 21-Apr-2004  itojun branches: 1.46.4;
kill sprintf, use snprintf
 1.45 17-Nov-2003  cube o Fix a bug in ksyms that changed the real meaning of st_name entries for
symbols, and made it impossible for the kernel to use that value, and
correctly find symbols from LKMs.
o Allow LKM users to use DDB to debug the entry function of a LKM by
loading the symbol table with the temporary name /lkmtemp/ before calling
it, and then renaming it once we know the module name.

Approved by ragge@.
 1.44 25-Oct-2003  christos fix uninitialized variable
 1.43 05-Oct-2003  scw Tweak the previous change to ensure symbol addresses are correctly
sign-extended on cpus with 64-bit registers.
 1.42 03-Sep-2003  ragge long -> unsigned long, so that correct pointer is sent in function call.
 1.41 17-May-2003  scw branches: 1.41.2;
Don't assume sizeof(db_expr_t) == sizeof(long).
Ditto for sizeof(db_addr_t), although I don't think this
one is currently an issue.
 1.40 16-May-2003  itojun use strlcpy [change prototype of db_symstr to pass size_t; noone seem to use it]
 1.39 11-May-2003  jdolecek make couple ksym functions' arguments const
 1.38 28-Apr-2003  ragge By accident db_symstr() was removed, which H�vard pointed out.
Readded now.
 1.37 25-Apr-2003  ragge Mobe the SYMTAB_SPACE stuff to ksyms_init, so that it can be used without
DDB compiled-in.
 1.36 24-Apr-2003  ragge db_sym_numargs() disappeared by mistake, restore it.
 1.35 24-Apr-2003  ragge Teach DDB to use ksyms instead of it's own symbol table management.
Note: For a.out kernels (beware!) DDB will still use the old stuff.
 1.34 16-Apr-2003  jdolecek make parameter 'name' for db_del_symbol_table() const
 1.33 10-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.32 04-Nov-2002  itohy Dump DDB_* and SYMTAB_SPACE options to opt_ddbparam.h rather than opt_ddb.h.
These options are used in limited files but #include "opt_ddb.h" are
everywhere, and changing them caused almost full recompilation.
 1.31 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.30 05-Jan-2002  jhawk Add db_symstr(), a parallel interface to db_printsym() that
writes to a string rather than outputs to the supplied printer.
This is convenient for disassemblers that are structured to
build a long string and print it later.

Perhaps db_printsym() should be changed to use this interface...
 1.29 20-Nov-2001  lukem - pull in opt_kgdb.h where necessary
- replace opt_kgdb_machdep.h with opt_kgdb.h
- defparam opt_kgdb.h:
KGDB_DEV KGDB_DEVNAME KGDB_DEVADDR KGDB_DEVRATE KGDB_DEVMODE
- move from opt_ddbparam.h to opt_ddb.h:
DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE DDB_BREAK_CHAR SYMTAB_SPACE
- replace KGDBDEV with KGDB_DEV
- replace KGDBADDR with KGDB_DEVADDR
- replace KGDBMODE with KGDB_DEVMODE
- replace KGDBRATE with KGDB_DEVRATE
- use `9600' instead of `0x2580' for 9600 baud rate
- use correct quotes for options KGDB_DEVNAME="\"com\""
- use correct quotes for options KGDB_DEV="17*256+0"
- remove unnecessary dependancy on Makefile for kgdb_stub.o
- minor whitespace cleanup
 1.28 12-Nov-2001  lukem add RCSIDs
 1.27 08-Nov-2001  christos PR/14498: Wesley Chen: Print a return after enumerating the matching symbols.
 1.26 13-Jun-2001  simonb branches: 1.26.2; 1.26.6;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.25 17-Jan-2001  jdolecek branches: 1.25.2;
constify a little
 1.24 11-Aug-2000  tv Missed change of parameter for %r->db_format_radix() change.
 1.23 09-Aug-2000  tv Add two new functions, db_format_radix() and db_format_hex(), which supplant
the former %r and %z nonstandard kprintf strings.
 1.22 06-Jun-2000  jhawk Stop using DDB-specific "%n" kprintf() format specifier. This was
important as db_sym() can be called through printf() rather than
db_printf(), causing a trap as the standard %n usage is invoked.

The DDB-specific %n code should disappear from subr_prf.c soon...
 1.21 25-May-2000  jhawk branches: 1.21.2;
Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.20 22-May-2000  jhawk Add a "sifting" command to ddb (named from the Sun OpenPROM command of
the same name); it searches the symbol table(s) for all symbols matching
a given substring, and prints.

Extremely useful for when you forget that critical symbol name.

Also, with /F support (cf. "ls -F") to print a char indicating the
symbol type.
 1.19 30-Mar-2000  augustss Die, register, die!
 1.18 26-Jun-1999  simonb branches: 1.18.2;
Fix tyop in error message.
 1.17 12-Apr-1999  pk Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.16 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.15 04-Dec-1998  thorpej branches: 1.15.4;
- Make the ddb_init() interface consistent for a.out and ELF.
- Allow DDB to run-time switch for a.out or ELF symbol table support.
 1.14 26-Jun-1997  thorpej Pass the current DDB symbol table to X_db_symbol_values().
 1.13 03-Feb-1997  cgd fix various 64-bitness bugs.
fix various db_printf format bugs (long vs. int, etc.).
 1.12 05-Feb-1996  christos DDB prototype changes.
 1.11 24-Nov-1995  cgd fix paste-o
 1.10 23-Nov-1995  cgd db_lastsym (cast from pointer) should be long not int. db_maxoff -> db_expr_t
 1.9 24-May-1995  gwr Avoid printing values as "end+0x...."
 1.8 09-Oct-1994  mycroft db_error() does not return.
 1.7 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.6 18-Dec-1993  mycroft Canonicalize all #includes.
 1.5 02-Aug-1993  mycroft branches: 1.5.2;
Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
 1.4 22-Jul-1993  brezak Allow adding more than one symbol table at runtime. For LKM.
 1.3 10-Jul-1993  brezak Print symbolic args and line no's in stack traces.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.15.4.2 12-Apr-1999  pk branches: 1.15.4.2.2;
Pullup copyright text corrections.
 1.15.4.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.15.4.2.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.15.4.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.18.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.18.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.25.2.6 11-Nov-2002  nathanw Catch up to -current
 1.25.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.25.2.4 11-Jan-2002  nathanw More catchup.
 1.25.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.25.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.25.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.26.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.26.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.26.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.41.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.41.2.7 01-Apr-2005  skrll Sync with HEAD.
 1.41.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.41.2.5 17-Feb-2005  skrll Sync with HEAD.
 1.41.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.41.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.41.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.41.2.1 03-Aug-2004  skrll Sync with HEAD
 1.46.4.1 29-Apr-2005  kent sync with -current
 1.47.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.51.2.2 26-Feb-2007  yamt sync with head.
 1.51.2.1 30-Dec-2006  yamt sync with head.
 1.52.22.2 10-Dec-2006  yamt sync with head.
 1.52.22.1 22-Oct-2006  yamt sync with head
 1.52.20.1 18-Nov-2006  ad Sync with head.
 1.54.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.56.48.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.56.42.1 04-May-2009  yamt sync with head.
 1.56.38.1 17-Jan-2009  mjf Sync with HEAD.
 1.57.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.57.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.58.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.59.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.59.4.1 21-Apr-2011  rmind sync with head
 1.61.8.1 18-Feb-2012  mrg merge to -current.
 1.61.4.1 17-Apr-2012  yamt sync with head
 1.64.6.1 03-Dec-2017  jdolecek update from HEAD
 1.65.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.66.6.1 17-Apr-2021  thorpej Sync with HEAD.
 1.25 10-Feb-2012  christos add __printflike where needed
 1.24 11-Apr-2011  mrg branches: 1.24.4; 1.24.8;
obsolete DB_AOUT_SYMBOLS. however, we need to leave most of the code
in db_sym.[ch] as it is used by the elf version of crash(8).

i will be cleaning up the db_sym.c code in a follow up commit to avoid
having dead code compiled.
 1.23 22-Feb-2007  matt branches: 1.23.66; 1.23.72;
Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.22 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.21 11-Dec-2005  christos branches: 1.21.26;
merge ktrace-lwp.
 1.20 29-May-2005  christos branches: 1.20.2;
Add lots of const.
 1.19 16-May-2003  itojun branches: 1.19.2;
use strlcpy [change prototype of db_symstr to pass size_t; noone seem to use it]
 1.18 24-Apr-2003  ragge Teach DDB to use ksyms instead of it's own symbol table management.
Note: For a.out kernels (beware!) DDB will still use the old stuff.
 1.17 16-Apr-2003  jdolecek make parameter 'name' for db_del_symbol_table() const
 1.16 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.15 05-Jan-2002  jhawk Add db_symstr(), a parallel interface to db_printsym() that
writes to a string rather than outputs to the supplied printer.
This is convenient for disassemblers that are structured to
build a long string and print it later.

Perhaps db_printsym() should be changed to use this interface...
 1.14 17-Jan-2001  jdolecek branches: 1.14.2; 1.14.4;
constify a little
 1.13 25-May-2000  jhawk Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.12 22-May-2000  jhawk Add a "sifting" command to ddb (named from the Sun OpenPROM command of
the same name); it searches the symbol table(s) for all symbols matching
a given substring, and prints.

Extremely useful for when you forget that critical symbol name.

Also, with /F support (cf. "ls -F") to print a char indicating the
symbol type.
 1.11 12-Apr-1999  pk branches: 1.11.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.10 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.9 04-Dec-1998  thorpej branches: 1.9.4;
- Make the ddb_init() interface consistent for a.out and ELF.
- Allow DDB to run-time switch for a.out or ELF symbol table support.
 1.8 31-Jan-1998  ross Print more info on ps/w, note the current proc, and properly declare db_maxoff.
 1.7 05-Feb-1996  christos DDB prototype changes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 15-Feb-1994  mycroft Remove RCS logs.
 1.3 22-Jul-1993  brezak Allow adding more than one symbol table at runtime. For LKM.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.4.2 12-Apr-1999  pk branches: 1.9.4.2.2;
Pullup copyright text corrections.
 1.9.4.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.9.4.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.14.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.1 11-Jan-2002  nathanw More catchup.
 1.19.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.1 26-Feb-2007  yamt sync with head.
 1.21.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.23.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.23.66.1 21-Apr-2011  rmind sync with head
 1.24.8.1 18-Feb-2012  mrg merge to -current.
 1.24.4.1 17-Apr-2012  yamt sync with head
 1.3 15-Oct-2023  riastradh ddb: Constify db_syncobj_owner argument.

No need for it to be writable, and the actual type of the struct lwp
member is const.
 1.2 12-Jul-2023  riastradh branches: 1.2.2;
ddb: Cast pointer to uintptr_t, then to db_expr_t.

Avoids warnings about conversion between pointer and integer of
different size on some architectures.
 1.1 09-Jul-2023  riastradh ddb: New `show all tstiles' command.

Shows who's waiting for which locks and what the owner is up to.

XXX pullup-10
 1.2.2.2 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

sys/arch/m68k/include/mutex.h: revision 1.13
sys/arch/arm/include/cpu.h: revision 1.125
sys/arch/sun68k/include/intr.h: revision 1.21
sys/arch/arm/include/mutex.h: revision 1.28
sys/sys/rwlock.h: revision 1.18
sys/arch/powerpc/include/mutex.h: revision 1.7
sys/arch/arm/include/mutex.h: revision 1.29
sys/arch/powerpc/include/mutex.h: revision 1.8
sys/uvm/uvm_param.h: revision 1.42
sys/sys/ksem.h: revision 1.16
sys/arch/x86/include/mutex.h: revision 1.10
sys/sys/proc.h: revision 1.372
sys/sys/ksem.h: revision 1.17
sys/arch/ia64/include/mutex.h: revision 1.8
sys/arch/evbarm/include/intr.h: revision 1.29
sys/sys/lua.h: revision 1.9
sys/arch/next68k/include/intr.h: revision 1.23
sys/arch/ia64/include/mutex.h: revision 1.9
sys/arch/hp300/include/intr.h: revision 1.35
sys/arch/hp300/include/intr.h: revision 1.36
sys/arch/sparc/include/cpu.h: revision 1.111
sys/arch/hppa/include/mutex.h: revision 1.16
sys/arch/vax/include/intr.h: revision 1.31
sys/arch/hppa/include/mutex.h: revision 1.17
sys/arch/news68k/include/intr.h: revision 1.28
sys/arch/hppa/include/mutex.h: revision 1.18
sys/arch/hppa/include/intr.h: revision 1.3
sys/arch/hppa/include/mutex.h: revision 1.19
sys/arch/hppa/include/intr.h: revision 1.4
sys/sys/sched.h: revision 1.92
sys/opencrypto/cryptodev.h: revision 1.51
sys/arch/vax/include/mutex.h: revision 1.20
sys/arch/sparc64/include/mutex.h: revision 1.10
sys/arch/ia64/include/sapicvar.h: revision 1.2
sys/arch/riscv/include/mutex.h: revision 1.5
sys/arch/amiga/dev/grfabs_cc.c: revision 1.39
sys/external/bsd/drm2/include/linux/idr.h: revision 1.11
sys/arch/riscv/include/mutex.h: revision 1.6
sys/ddb/files.ddb: revision 1.16
sys/arch/mac68k/include/intr.h: revision 1.32
share/man/man4/ddb.4: revision 1.203
sys/ddb/db_command.c: revision 1.183
sys/arch/mips/include/mutex.h: revision 1.10
sys/ddb/db_command.c: revision 1.184
sys/arch/x68k/include/intr.h: revision 1.22
sys/arch/sparc/include/psl.h: revision 1.51
sys/arch/or1k/include/mutex.h: revision 1.4
sys/arch/mips/include/mutex.h: revision 1.11
sys/arch/arm/xscale/pxa2x0_intr.h: revision 1.16
sys/arch/sparc64/include/cpu.h: revision 1.134
sys/arch/sparc/include/psl.h: revision 1.52
sys/arch/or1k/include/mutex.h: revision 1.5
sys/arch/mvme68k/include/intr.h: revision 1.22
sys/arch/luna68k/include/intr.h: revision 1.16
external/cddl/osnet/sys/sys/kcondvar.h: revision 1.6
sys/arch/sparc/include/mutex.h: revision 1.12
sys/arch/sparc/include/mutex.h: revision 1.13
sys/arch/usermode/include/mutex.h: revision 1.5
sys/arch/usermode/include/mutex.h: revision 1.6
sys/kern/kern_core.c: revision 1.38
usr.sbin/crash/Makefile: revision 1.49
sys/arch/amiga/include/intr.h: revision 1.23
sys/arch/alpha/include/mutex.h: revision 1.12
sys/arch/alpha/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.16
sys/ddb/ddb.h: revision 1.6
sys/arch/sparc64/include/mutex.h: revision 1.8
sys/arch/sh3/include/mutex.h: revision 1.12
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.17
sys/ddb/db_syncobj.c: revision 1.1
sys/arch/vax/include/mutex.h: revision 1.18
sys/arch/sparc64/include/psl.h: revision 1.63
sys/arch/sparc64/include/mutex.h: revision 1.9
sys/arch/sh3/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/obio.c: revision 1.13
sys/arch/atari/include/intr.h: revision 1.23
sys/ddb/db_syncobj.c: revision 1.2
sys/arch/vax/include/mutex.h: revision 1.19
sys/arch/evbarm/g42xxeb/obio.c: revision 1.14
sys/arch/evbarm/g42xxeb/obio.c: revision 1.15
sys/arch/cesfic/include/intr.h: revision 1.14
sys/ddb/db_syncobj.h: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.134
sys/arch/evbarm/g42xxeb/obio.c: revision 1.16
sys/arch/cesfic/include/intr.h: revision 1.15
sys/arch/arm/xscale/pxa2x0_intr.c: revision 1.26
sys/sys/cpu_data.h: revision 1.54
sys/arch/m68k/include/mutex.h: revision 1.12
sys/arch/ia64/acpi/madt.c: revision 1.6

sys/rwlock.h: Make this more self-contained for bool.

machine/mutex.h: Sprinkle includes so this can be used by crash(8).

ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

sys: Rip <sys/resourcevar.h> out of <uvm/uvm_param.h>.

And thus out of <sys/param.h>, which is exceedingly overused and
fragile and delenda est.

Should fix (some) issues with the recent inclusion of machine/lock.h
in various machine/mutex.h files.

arm/mutex.h: Need machine/intr.h, machine/lock.h.

For ipl_cookie_t and __cpu_simple_lock_t.
evbarm/intr.h: Define ipl_cookie_t before including ARM_INTR_IMPL.

Otherwise arm/mutex.h doesn't work, due to a cyclic dependency which
should really be fixed.
opencrypto/cryptodev.h: Fix includes.
- Move sys/condvar.h under #ifdef _KERNEL.
- Add some other necessary includes and forward declarations.
- Sort.

hp300/intr.h: Fix missing includes.
linux/idr.h: Need <sys/mutex.h> for kmutex_t.
amiga/intr.h: Don't define spl*() functions if !_KERNEL.

This is used by crash(8) now, and what's important is ipl_cookie_t.
cesfic/intr.h: Expose ipl_cookie_t to userland for crash(8).
cesfic/intr.h: Expose ipl_cookie_t to userland only with _KMEMUSER.

Probably not necessary but let's be a little more cautious about
this.

atari/intr.h: Expose ipl_cookie_t with _KMEMUSER for crash(8).

arm/cpu.h: Need sys/param.h for COHERENCY_UNIT.

Nix machine/param.h -- not meant to be used directly, pulled in by
sys/param.h.

Move the definition of ipl_cookie_t out of the kernel-only sections,
some _KMEMUSER applications need it.

ddb: Cast pointer to uintptr_t first before db_expr_t.

hppa/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

luna68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

mvme68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

news68k/intr.h: Fix includes. Put some definitions under _KERNEL.

next68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

sys/ksem.h: Hack around fstat(8) abuse of _KERNEL.

sun68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

vax/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

x68k/intr.h: Put functions under _KERNEL so crash(8) can use this.

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

Explicitly include <sys/mutex.h> for kmutex_t.

Replace kmutex_t * (which may be undefined here) with struct kmutex *,
suggested by Taylor.

hp300/intr.h: Put most of this under #ifdef _KERNEL.
Only ipl_cookie_t really needs to be exposed now, for crash(8).

mac68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).
Make inclusion of sys/intr.h explicit for spl*.

fix hppa and vax builds.

machine/lock.h isn't necessary for __cpu_simple_lock_t, it's in
sys/types.h. avoids cpu_data.h vs sched.h include order issues.

move the hppa ipl_t typedef with the moved usage of it.
machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.

ddb: Cast pointer to uintptr_t, then to db_expr_t.
Avoids warnings about conversion between pointer and integer of
different size on some architectures.

re-fix hppa builds.

this file uses __cpu_simple_lock(), not just the underlying type,
so it does need machine/lock.h.

Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex. Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT. Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.

ia64: Need sys/types.h for u_int, vaddr_t; sys/mutex.h for kmutex_t.

explicitly include no longer implicitly included sys/mutex.h.

arm/xscale: Use sys/bitops.h fls32 - 1 instead of 31 - __builtin_clz.
Sidesteps namespace collision with `#define bits ...' in net/zlib.c.

complete the previous - there were two calls to find_first_bit() to fix.

arm/xscale: Missed a spot with previous find_first_bit commit.

evbarm/g42xxeb: Fix off-by-one in previous.

The original find_first_bit(x) was 31 - __builtin_clz((uint32_t)x),
which is equivalent to fls32(x) - 1, not to fls32(x).

Note that fls32 is 1-based and returns 0 for x=0.
 1.2.2.1 12-Jul-2023  martin file db_syncobj.c was added on branch netbsd-10 on 2023-08-09 17:42:03 +0000
 1.3 15-Oct-2023  riastradh ddb: Constify db_syncobj_owner argument.

No need for it to be writable, and the actual type of the struct lwp
member is const.
 1.2 15-Oct-2023  riastradh sys/lwp.h: Nix sys/syncobj.h dependency.

Remove it in ddb/db_syncobj.h too.

New sys/wchan.h defines wchan_t so that users need not pull in
sys/syncobj.h to get it.

Sprinkle #include <sys/syncobj.h> in .c files where it is now needed.
 1.1 09-Jul-2023  riastradh branches: 1.1.2;
ddb: New `show all tstiles' command.

Shows who's waiting for which locks and what the owner is up to.

XXX pullup-10
 1.1.2.2 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

sys/arch/m68k/include/mutex.h: revision 1.13
sys/arch/arm/include/cpu.h: revision 1.125
sys/arch/sun68k/include/intr.h: revision 1.21
sys/arch/arm/include/mutex.h: revision 1.28
sys/sys/rwlock.h: revision 1.18
sys/arch/powerpc/include/mutex.h: revision 1.7
sys/arch/arm/include/mutex.h: revision 1.29
sys/arch/powerpc/include/mutex.h: revision 1.8
sys/uvm/uvm_param.h: revision 1.42
sys/sys/ksem.h: revision 1.16
sys/arch/x86/include/mutex.h: revision 1.10
sys/sys/proc.h: revision 1.372
sys/sys/ksem.h: revision 1.17
sys/arch/ia64/include/mutex.h: revision 1.8
sys/arch/evbarm/include/intr.h: revision 1.29
sys/sys/lua.h: revision 1.9
sys/arch/next68k/include/intr.h: revision 1.23
sys/arch/ia64/include/mutex.h: revision 1.9
sys/arch/hp300/include/intr.h: revision 1.35
sys/arch/hp300/include/intr.h: revision 1.36
sys/arch/sparc/include/cpu.h: revision 1.111
sys/arch/hppa/include/mutex.h: revision 1.16
sys/arch/vax/include/intr.h: revision 1.31
sys/arch/hppa/include/mutex.h: revision 1.17
sys/arch/news68k/include/intr.h: revision 1.28
sys/arch/hppa/include/mutex.h: revision 1.18
sys/arch/hppa/include/intr.h: revision 1.3
sys/arch/hppa/include/mutex.h: revision 1.19
sys/arch/hppa/include/intr.h: revision 1.4
sys/sys/sched.h: revision 1.92
sys/opencrypto/cryptodev.h: revision 1.51
sys/arch/vax/include/mutex.h: revision 1.20
sys/arch/sparc64/include/mutex.h: revision 1.10
sys/arch/ia64/include/sapicvar.h: revision 1.2
sys/arch/riscv/include/mutex.h: revision 1.5
sys/arch/amiga/dev/grfabs_cc.c: revision 1.39
sys/external/bsd/drm2/include/linux/idr.h: revision 1.11
sys/arch/riscv/include/mutex.h: revision 1.6
sys/ddb/files.ddb: revision 1.16
sys/arch/mac68k/include/intr.h: revision 1.32
share/man/man4/ddb.4: revision 1.203
sys/ddb/db_command.c: revision 1.183
sys/arch/mips/include/mutex.h: revision 1.10
sys/ddb/db_command.c: revision 1.184
sys/arch/x68k/include/intr.h: revision 1.22
sys/arch/sparc/include/psl.h: revision 1.51
sys/arch/or1k/include/mutex.h: revision 1.4
sys/arch/mips/include/mutex.h: revision 1.11
sys/arch/arm/xscale/pxa2x0_intr.h: revision 1.16
sys/arch/sparc64/include/cpu.h: revision 1.134
sys/arch/sparc/include/psl.h: revision 1.52
sys/arch/or1k/include/mutex.h: revision 1.5
sys/arch/mvme68k/include/intr.h: revision 1.22
sys/arch/luna68k/include/intr.h: revision 1.16
external/cddl/osnet/sys/sys/kcondvar.h: revision 1.6
sys/arch/sparc/include/mutex.h: revision 1.12
sys/arch/sparc/include/mutex.h: revision 1.13
sys/arch/usermode/include/mutex.h: revision 1.5
sys/arch/usermode/include/mutex.h: revision 1.6
sys/kern/kern_core.c: revision 1.38
usr.sbin/crash/Makefile: revision 1.49
sys/arch/amiga/include/intr.h: revision 1.23
sys/arch/alpha/include/mutex.h: revision 1.12
sys/arch/alpha/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.16
sys/ddb/ddb.h: revision 1.6
sys/arch/sparc64/include/mutex.h: revision 1.8
sys/arch/sh3/include/mutex.h: revision 1.12
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.17
sys/ddb/db_syncobj.c: revision 1.1
sys/arch/vax/include/mutex.h: revision 1.18
sys/arch/sparc64/include/psl.h: revision 1.63
sys/arch/sparc64/include/mutex.h: revision 1.9
sys/arch/sh3/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/obio.c: revision 1.13
sys/arch/atari/include/intr.h: revision 1.23
sys/ddb/db_syncobj.c: revision 1.2
sys/arch/vax/include/mutex.h: revision 1.19
sys/arch/evbarm/g42xxeb/obio.c: revision 1.14
sys/arch/evbarm/g42xxeb/obio.c: revision 1.15
sys/arch/cesfic/include/intr.h: revision 1.14
sys/ddb/db_syncobj.h: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.134
sys/arch/evbarm/g42xxeb/obio.c: revision 1.16
sys/arch/cesfic/include/intr.h: revision 1.15
sys/arch/arm/xscale/pxa2x0_intr.c: revision 1.26
sys/sys/cpu_data.h: revision 1.54
sys/arch/m68k/include/mutex.h: revision 1.12
sys/arch/ia64/acpi/madt.c: revision 1.6

sys/rwlock.h: Make this more self-contained for bool.

machine/mutex.h: Sprinkle includes so this can be used by crash(8).

ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

sys: Rip <sys/resourcevar.h> out of <uvm/uvm_param.h>.

And thus out of <sys/param.h>, which is exceedingly overused and
fragile and delenda est.

Should fix (some) issues with the recent inclusion of machine/lock.h
in various machine/mutex.h files.

arm/mutex.h: Need machine/intr.h, machine/lock.h.

For ipl_cookie_t and __cpu_simple_lock_t.
evbarm/intr.h: Define ipl_cookie_t before including ARM_INTR_IMPL.

Otherwise arm/mutex.h doesn't work, due to a cyclic dependency which
should really be fixed.
opencrypto/cryptodev.h: Fix includes.
- Move sys/condvar.h under #ifdef _KERNEL.
- Add some other necessary includes and forward declarations.
- Sort.

hp300/intr.h: Fix missing includes.
linux/idr.h: Need <sys/mutex.h> for kmutex_t.
amiga/intr.h: Don't define spl*() functions if !_KERNEL.

This is used by crash(8) now, and what's important is ipl_cookie_t.
cesfic/intr.h: Expose ipl_cookie_t to userland for crash(8).
cesfic/intr.h: Expose ipl_cookie_t to userland only with _KMEMUSER.

Probably not necessary but let's be a little more cautious about
this.

atari/intr.h: Expose ipl_cookie_t with _KMEMUSER for crash(8).

arm/cpu.h: Need sys/param.h for COHERENCY_UNIT.

Nix machine/param.h -- not meant to be used directly, pulled in by
sys/param.h.

Move the definition of ipl_cookie_t out of the kernel-only sections,
some _KMEMUSER applications need it.

ddb: Cast pointer to uintptr_t first before db_expr_t.

hppa/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

luna68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

mvme68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

news68k/intr.h: Fix includes. Put some definitions under _KERNEL.

next68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

sys/ksem.h: Hack around fstat(8) abuse of _KERNEL.

sun68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

vax/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

x68k/intr.h: Put functions under _KERNEL so crash(8) can use this.

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

Explicitly include <sys/mutex.h> for kmutex_t.

Replace kmutex_t * (which may be undefined here) with struct kmutex *,
suggested by Taylor.

hp300/intr.h: Put most of this under #ifdef _KERNEL.
Only ipl_cookie_t really needs to be exposed now, for crash(8).

mac68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).
Make inclusion of sys/intr.h explicit for spl*.

fix hppa and vax builds.

machine/lock.h isn't necessary for __cpu_simple_lock_t, it's in
sys/types.h. avoids cpu_data.h vs sched.h include order issues.

move the hppa ipl_t typedef with the moved usage of it.
machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.

ddb: Cast pointer to uintptr_t, then to db_expr_t.
Avoids warnings about conversion between pointer and integer of
different size on some architectures.

re-fix hppa builds.

this file uses __cpu_simple_lock(), not just the underlying type,
so it does need machine/lock.h.

Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex. Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT. Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.

ia64: Need sys/types.h for u_int, vaddr_t; sys/mutex.h for kmutex_t.

explicitly include no longer implicitly included sys/mutex.h.

arm/xscale: Use sys/bitops.h fls32 - 1 instead of 31 - __builtin_clz.
Sidesteps namespace collision with `#define bits ...' in net/zlib.c.

complete the previous - there were two calls to find_first_bit() to fix.

arm/xscale: Missed a spot with previous find_first_bit commit.

evbarm/g42xxeb: Fix off-by-one in previous.

The original find_first_bit(x) was 31 - __builtin_clz((uint32_t)x),
which is equivalent to fls32(x) - 1, not to fls32(x).

Note that fls32 is 1-based and returns 0 for x=0.
 1.1.2.1 09-Jul-2023  martin file db_syncobj.h was added on branch netbsd-10 on 2023-08-09 17:42:03 +0000
 1.26 12-Mar-2019  skrll KNF
 1.25 09-Feb-2011  matt branches: 1.25.56;
Since curlwp and curproc must always be non-NULL, remove the == NULL branches.
 1.24 21-Feb-2007  thorpej branches: 1.24.66; 1.24.72; 1.24.74;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.23 11-Dec-2005  christos branches: 1.23.26;
merge ktrace-lwp.
 1.22 26-Feb-2005  perry branches: 1.22.4;
nuke trailing whitespace
 1.21 28-Apr-2003  briggs branches: 1.21.2; 1.21.10; 1.21.12;
Add a rudimentary 'trap to kgdb' command if KGDB is defined. This allows
systems with only one serial port for console, etc., to have at least some
basic access to remote-kgdb-over-serial, even if it is a bit awkward.
 1.20 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.19 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.18 12-Nov-2001  lukem add RCSIDs
 1.17 20-Dec-2000  jhawk branches: 1.17.2; 1.17.4;
When we hit a breakpoint in a process, print the pid of the process as
well as the command name (p_comm) of the process.
 1.16 18-Jul-2000  jeffs Provide some info on what db_trap_callback() is for in the code.
 1.15 17-Jul-2000  jeffs Move platform db_trap callback from arch/mips into ddb as suggested by
jhawk. This callback is used by platform code to manage things like
watchdogs that should be disabled while in ddb. Done as a callback
for processors such as mips that support lots of different systems.
 1.14 12-Apr-1999  pk branches: 1.14.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.13 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.12 16-Aug-1998  rvb branches: 1.12.6;
Indent to 4 space for tabs 2 and 3 like the rest of the code
 1.11 15-Aug-1998  ross Have to fix the `(int)curproc' lossage now; kernel builds die here on alpha.

BTW, KNF requires the additional, not-technically-need `!= NULL'.
 1.10 14-Aug-1998  rvb Print program name when entering the debugger
 1.9 05-Feb-1996  christos DDB prototype changes.
 1.8 02-Dec-1994  gwr Leave db_recover as it was on entry to avoid endless "exception in ddb"...
(Don't need to frob it at all here because db_command_loop does it.)
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 04-Apr-1994  mycroft Try to deal with db_print_loc_and_inst() generatings a fault.
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.12.6.2 12-Apr-1999  pk branches: 1.12.6.2.2;
Pullup copyright text corrections.
 1.12.6.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.12.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.14.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.17.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.17.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.2.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.17.2.5 24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.17.2.4 28-Feb-2002  nathanw LWPify a little more.
 1.17.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.17.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.17.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.21.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.10.1 29-Apr-2005  kent sync with -current
 1.21.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.22.4.1 26-Feb-2007  yamt sync with head.
 1.23.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.24.74.1 17-Feb-2011  bouyer Sync with HEAD
 1.24.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.66.1 05-Mar-2011  rmind sync with head
 1.25.56.1 10-Jun-2019  christos Sync with HEAD
 1.4 31-Dec-2011  christos include stddef.h for offsetof
 1.3 31-Dec-2011  christos - fix offsetof usage, and redundant defines
- kill pointer casts to 0
 1.2 02-Feb-2010  tron branches: 1.2.12; 1.2.16;
Include "ctype.h" in the central place which deals with building the
kernel debugger as a userland program.
 1.1 07-Mar-2009  ad branches: 1.1.2; 1.1.4; 1.1.6;
Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 07-Mar-2009  jym file db_user.h was added on branch jym-xensuspend on 2009-05-13 17:19:04 +0000
 1.1.4.3 11-Mar-2010  yamt sync with head
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 07-Mar-2009  yamt file db_user.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.1.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1 07-Mar-2009  skrll file db_user.h was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.2.16.1 18-Feb-2012  mrg merge to -current.
 1.2.12.1 17-Apr-2012  yamt sync with head
 1.47 10-Mar-2020  christos Make the db_kernelonly() macro visible to all files and re-use it.
Register access is kernel only.
 1.46 17-Feb-2018  sevan branches: 1.46.4;
Opt to print a backtrace on panic by default with the intention of improving bug reports.
Instead of relying on ddb.onpanic=2, introduce a new sysctl called dumpstack to handle this.
via <jmcneill> channeled through <mrg> on tech-kern[1]

[1] https://mail-index.netbsd.org/tech-kern/2018/02/15/msg023103.html
 1.45 28-Dec-2017  christos - add ddb.panicstackframes to avoid scrolling the interesting parts of panic
stacktraces off.
- change valuep to void * to avoid casts
- sort and use c99 initializers in variables array
 1.44 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.43 02-Jun-2012  dsl branches: 1.43.2; 1.43.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.42 11-Mar-2009  martin branches: 1.42.12;
Switch the default value (if no options DDB_ONPANIC is defined) for
ddb.onpanic to 1, change it back to 0 in sysctl.conf and make sure
postinstall installs this setting.
This avoids us trying to dump while booting from install CD, but keeps
the default the same once we are far enough through /etc/rc.d. Failing
earlier is unlikely to be recovered by an automatic reboot.
OK: core.
 1.41 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.40 30-Jan-2009  ad branches: 1.40.2;
Default DDB_ONPANIC to zero. The end product is ultimately for the
consumption of users external to the project, users who are unlikely to
be kernel hackers with the motivation to debug crashes. In this situation
rebooting and creating a crash dump is more appropriate than interrupting
normal service for an unbounded amount of time, while also leaving the
machine at cryptic db> prompt.
 1.39 22-Feb-2007  matt branches: 1.39.42; 1.39.52; 1.39.54;
Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.38 16-Nov-2006  christos branches: 1.38.4;
__unused removal on arguments; approved by core.
 1.37 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.36 30-Aug-2006  christos branches: 1.36.2; 1.36.4;
fix incomplete initializer.
 1.35 14-May-2006  christos XXX: GCC uninitialized.
 1.34 27-Nov-2005  yamt branches: 1.34.4; 1.34.6; 1.34.8; 1.34.12;
make DDB_COMMANDONENTER sysctl. (ddb.commandonenter)
suggested by Christos Zoulas.
 1.33 01-Jun-2005  drochner branches: 1.33.2; 1.33.8;
more constification fallout
 1.32 29-Sep-2004  reinoud Implement ddb setting that allows all ddb output to be teed into the
kernel message buffer/log. Its off by default and can be switched on in the
kernel configuration on build time, be set as a variable in ddb and be set
using sysctl.

This adds the sysctl value
ddb.tee_msgbuf = 0
by default.

The functionality is especially added and aimed for developers who are not
blessed with a serial console and wish to keep all their ddb output in the
log. Specifying /l as a modifier to some selected commands will also put
the output in the log but not all commands provide one nor has the same
meaning for all commands.

This feature could in the future also be implemented as an ddb command but
that could lead to more bloat allthough maybe easier for non developpers to
use when mailing their backtraces from kernel crashes.
 1.31 25-May-2004  atatat Sysctl descriptions under ddb subtree
 1.30 24-Mar-2004  atatat branches: 1.30.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.29 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.28 29-Jun-2003  fvdl branches: 1.28.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.27 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.26 10-Nov-2002  thorpej Avoid a GCC 3.3 strict alias warning.
 1.25 04-Nov-2002  itohy Dump DDB_* and SYMTAB_SPACE options to opt_ddbparam.h rather than opt_ddb.h.
These options are used in limited files but #include "opt_ddb.h" are
everywhere, and changing them caused almost full recompilation.
 1.24 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.23 20-Nov-2001  lukem - pull in opt_kgdb.h where necessary
- replace opt_kgdb_machdep.h with opt_kgdb.h
- defparam opt_kgdb.h:
KGDB_DEV KGDB_DEVNAME KGDB_DEVADDR KGDB_DEVRATE KGDB_DEVMODE
- move from opt_ddbparam.h to opt_ddb.h:
DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE DDB_BREAK_CHAR SYMTAB_SPACE
- replace KGDBDEV with KGDB_DEV
- replace KGDBADDR with KGDB_DEVADDR
- replace KGDBMODE with KGDB_DEVMODE
- replace KGDBRATE with KGDB_DEVRATE
- use `9600' instead of `0x2580' for 9600 baud rate
- use correct quotes for options KGDB_DEVNAME="\"com\""
- use correct quotes for options KGDB_DEV="17*256+0"
- remove unnecessary dependancy on Makefile for kgdb_stub.o
- minor whitespace cleanup
 1.22 12-Nov-2001  lukem add RCSIDs
 1.21 11-Apr-2001  msaitoh branches: 1.21.2;
fix invalid reference to $fromconsole via DDB
 1.20 17-Jan-2001  jdolecek branches: 1.20.2;
constify a little
 1.19 05-Jul-2000  jhawk "set" now displays the name of the variable, old value, and new value,
just as "write" does.
 1.18 27-Jun-2000  mrg remove include of <vm/vm.h>
 1.17 28-Oct-1999  lukem branches: 1.17.6;
- change db_cmd_list() to list commands vertically rather than horizontally
- sort entries in the various command tables, so that the `help' lists
are easier to use. this included hacking db_machine_commands_install()
to search for the "machine" entry to change the `more cmds' pointer,
rather than assuming it was the first entry
- add a `sync' command, which is effectively `reboot 0x100'.
- remove db_help_cmd(); it was unused (and was almost a duplicate of
db_cmd_list()).
- move some extern decls to db_output.h, since they're used in more than one
place now
- rename NEXT_TAB to DB_NEXT_TAB and move to db_output.h
 1.16 12-Apr-1999  pk branches: 1.16.2; 1.16.4; 1.16.6;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.15 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.14 29-Oct-1998  jonathan branches: 1.14.6;
Add options DDB_FROMCONSOLE and sysctl ddb.fromconsole, analagous to
DDB_ONPANIC. Lets user ignore breaks but enter DDB on panic. Intended
for machines where debug on panic is useful, but DDB entry is not,
(public-access console, or terminal-servers which send spurious breaks)

Add new ddb hook, console_debugger(), which decides whether or not to
ignore console ddb requests. Console drivers should be updated to call
console_debugger(), not Debugger(), in response to serial-console
break or ddb keyboard sequence.
 1.13 04-Jul-1998  jonathan defopt DDB.
 1.12 31-Jan-1998  ross Print more info on ps/w, note the current proc, and properly declare db_maxoff.
 1.11 04-Feb-1997  cgd make variable pointers (in variable declaration structs) be 'long *', so
that the common case can be handled with no hassles on all machines.
fix up the various internal variables which are also exported via sysctl
(and which therefore must be 'int's) to do the right thing via a special
read/write function.
 1.10 03-Feb-1997  cgd fix various 64-bitness bugs.
 1.9 09-Jan-1997  thorpej Define db_onpanic variable; if non-zero, the DDB will be entered when
the kernel panics. It may be initialized to 0 with the kernel option
"DDB_ONPANIC=0", and is patchable. It may be changed at run-time
from within the DDB (as a DDB variable) or via the ddb.onpanic sysctl
node.

Export all DDB built-in variables via sysctl.
 1.8 05-Feb-1996  christos DDB prototype changes.
 1.7 09-Oct-1994  mycroft db_error() does not return.
 1.6 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.5 18-Dec-1993  mycroft Canonicalize all #includes.
 1.4 02-Aug-1993  mycroft branches: 1.4.2;
Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
 1.3 15-Jul-1993  brezak Add 'ps' command. Add -more- pager to output from Mach ddb.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.14.6.2 12-Apr-1999  pk branches: 1.14.6.2.2;
Pullup copyright text corrections.
 1.14.6.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.14.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.16.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.4.1 15-Nov-1999  fvdl Sync with -current
 1.16.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.16.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.16.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.17.6.1 30-Sep-2001  he Pull up revision 1.21 (requested by msaitoh):
Fix which variable is tweaked for ``fromconsole''.
 1.20.2.5 11-Nov-2002  nathanw Catch up to -current
 1.20.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.20.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.20.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.20.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.21.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.21.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.28.2.7 11-Dec-2005  christos Sync with head.
 1.28.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.5 19-Oct-2004  skrll Sync with HEAD
 1.28.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.28.2.2 03-Aug-2004  skrll Sync with HEAD
 1.28.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.30.2.1 28-May-2004  tron Pull up revision 1.31 (requested by atatat in ticket #390):
Sysctl descriptions under ddb subtree
 1.33.8.1 29-Nov-2005  yamt sync with head.
 1.33.2.3 26-Feb-2007  yamt sync with head.
 1.33.2.2 30-Dec-2006  yamt sync with head.
 1.33.2.1 21-Jun-2006  yamt sync with head.
 1.34.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.34.8.2 03-Sep-2006  yamt sync with head.
 1.34.8.1 24-May-2006  yamt sync with head.
 1.34.6.1 01-Jun-2006  kardel Sync with head.
 1.34.4.1 09-Sep-2006  rpaulo sync with head
 1.36.4.2 10-Dec-2006  yamt sync with head.
 1.36.4.1 22-Oct-2006  yamt sync with head
 1.36.2.1 18-Nov-2006  ad Sync with head.
 1.38.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.39.54.2 12-Mar-2009  snj Pull up following revision(s) (requested by martin in ticket #564):
etc/sysctl.conf: revision 1.6
sys/ddb/db_variables.c: revision 1.42
usr.sbin/postinstall/postinstall: revision 1.91
Switch the default value (if no options DDB_ONPANIC is defined) for
ddb.onpanic to 1, change it back to 0 in sysctl.conf and make sure
postinstall installs this setting.
This avoids us trying to dump while booting from install CD, but keeps
the default the same once we are far enough through /etc/rc.d. Failing
earlier is unlikely to be recovered by an automatic reboot.
OK: core.
 1.39.54.1 24-Feb-2009  snj Pull up following revision(s) (requested by ad in ticket #487):
sys/ddb/db_variables.c: revision 1.40
Default DDB_ONPANIC to zero. The end product is ultimately for the
consumption of users external to the project, users who are unlikely to
be kernel hackers with the motivation to debug crashes. In this situation
rebooting and creating a crash dump is more appropriate than interrupting
normal service for an unbounded amount of time, while also leaving the
machine at cryptic db> prompt.
 1.39.52.2 28-Apr-2009  skrll Sync with HEAD.
 1.39.52.1 03-Mar-2009  skrll Sync with HEAD.
 1.39.42.1 04-May-2009  yamt sync with head.
 1.40.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.42.12.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.42.12.1 30-Oct-2012  yamt sync with head
 1.43.4.1 18-May-2014  rmind sync with head
 1.43.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.16 28-Dec-2017  christos - add ddb.panicstackframes to avoid scrolling the interesting parts of panic
stacktraces off.
- change valuep to void * to avoid casts
- sort and use c99 initializers in variables array
 1.15 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.14 11-Dec-2005  christos branches: 1.14.26;
merge ktrace-lwp.
 1.13 01-Jun-2005  drochner branches: 1.13.2;
more constification fallout
 1.12 15-Feb-2002  simonb branches: 1.12.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.11 13-May-2001  ross branches: 1.11.2;
The current API for MD support doesn't directly support the documented /u
option to show reg /u. Fix this by adding a modif[ier] field to struct
db_variable.
 1.10 18-Jan-2001  jdolecek branches: 1.10.2;
make db_[e]regs[] const
 1.9 17-Jan-2001  jdolecek constify a little
 1.8 12-Apr-1999  pk branches: 1.8.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.7 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.6 04-Feb-1997  cgd branches: 1.6.20;
make variable pointers (in variable declaration structs) be 'long *', so
that the common case can be handled with no hassles on all machines.
fix up the various internal variables which are also exported via sysctl
(and which therefore must be 'int's) to do the right thing via a special
read/write function.
 1.5 05-Feb-1996  christos DDB prototype changes.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 15-Feb-1994  mycroft Remove RCS logs.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.20.2 12-Apr-1999  pk branches: 1.6.20.2.2;
Pullup copyright text corrections.
 1.6.20.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.6.20.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.2.1 11-Feb-2001  bouyer Sync with HEAD.
 1.10.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.10.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.12.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.1 26-Feb-2007  yamt sync with head.
 1.14.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.27 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.26 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.25 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.24 16-Nov-2006  christos branches: 1.24.4;
__unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 11-Dec-2005  christos branches: 1.22.20; 1.22.22;
merge ktrace-lwp.
 1.21 01-Jun-2005  drochner branches: 1.21.2;
more constification fallout
 1.20 09-Nov-2003  scw Fix format string warnings for platforms where
sizeof(db_addr_t) > sizeof(long). e.g. ILP32 on sh5.
 1.19 15-Feb-2002  simonb branches: 1.19.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.18 12-Nov-2001  lukem add RCSIDs
 1.17 13-Oct-2001  bjh21 When setting watchpoints, call pmap_update() for each watchpoint, rather
than at the end, since they may be in different pmaps. This avoids a null
pointer dereference that was causing panics when resuming from DDB on arm26.
 1.16 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

Currently this is a no-op on most platforms, so they should see no difference.

Reviewed by Jason.
 1.15 02-Jun-2001  chs branches: 1.15.2; 1.15.4;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.14 24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.13 30-Mar-2000  augustss branches: 1.13.6;
Die, register, die!
 1.12 12-Apr-1999  pk branches: 1.12.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.11 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.10 13-Aug-1998  eeh branches: 1.10.6;
Merge paddr_t changes into the main branch.
 1.9 30-Mar-1996  christos branches: 1.9.18;
Fix db_printf format specifications.
 1.8 05-Feb-1996  christos DDB prototype changes.
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 08-Jan-1994  mycroft Rearrange some #includes.
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.9.18.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.10.6.2 12-Apr-1999  pk branches: 1.10.6.2.2;
Pullup copyright text corrections.
 1.10.6.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.10.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.13.6.5 28-Feb-2002  nathanw Catch up to -current.
 1.13.6.4 14-Nov-2001  nathanw Catch up to -current.
 1.13.6.3 22-Oct-2001  nathanw Catch up to -current.
 1.13.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.13.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.15.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.15.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.15.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.19.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.16.1 03-Aug-2004  skrll Sync with HEAD
 1.21.2.2 26-Feb-2007  yamt sync with head.
 1.21.2.1 30-Dec-2006  yamt sync with head.
 1.22.22.2 10-Dec-2006  yamt sync with head.
 1.22.22.1 22-Oct-2006  yamt sync with head
 1.22.20.1 18-Nov-2006  ad Sync with head.
 1.24.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.18 22-Feb-2007  matt Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.17 11-Dec-2005  christos branches: 1.17.26;
merge ktrace-lwp.
 1.16 01-Jun-2005  drochner branches: 1.16.2;
more constification fallout
 1.15 15-Feb-2002  simonb branches: 1.15.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.14 02-Jun-2001  chs branches: 1.14.2;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.13 15-Feb-2001  cgd branches: 1.13.2;
put crud after #endif in comments
 1.12 12-Apr-1999  pk branches: 1.12.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.11 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.10 13-Aug-1998  eeh branches: 1.10.6;
Merge paddr_t changes into the main branch.
 1.9 05-Feb-1996  christos branches: 1.9.18;
DDB prototype changes.
 1.8 09-Oct-1994  mycroft Get rid of unneeded `extern's.
 1.7 09-Oct-1994  mycroft Clean up #includes.
 1.6 09-Oct-1994  mycroft Add prototypes.
 1.5 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.4 15-Feb-1994  mycroft Remove RCS logs.
 1.3 08-Jan-1994  mycroft Rearrange some #includes.
 1.2 20-May-1993  cgd add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.18.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.10.6.2 12-Apr-1999  pk branches: 1.10.6.2.2;
Pullup copyright text corrections.
 1.10.6.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.10.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.2.1 12-Mar-2001  bouyer Sync with HEAD.
 1.13.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.13.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.15.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.1 26-Feb-2007  yamt sync with head.
 1.17.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.28 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.27 06-Jun-2015  matt branches: 1.27.18;
Add support for 'q' qualifier for 64-bit values on examine and write.
Align data to long so that the MD parts can use aligned load/stores.
Don't use db_extend but use db_expr_t based expressions.
 1.26 02-Feb-2010  tron branches: 1.26.22; 1.26.40;
Include "ctype.h" in the central place which deals with building the
kernel debugger as a userland program.
 1.25 01-Feb-2010  tron Include "ctype.h" if we are not building a kernel to fix the build
of crash(8).
 1.24 31-Jan-2010  phx New modifiers for the "write" command: /BHL. They act like /bhl but do not
read the old value from memory before writing.
 1.23 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.22 22-Feb-2007  thorpej branches: 1.22.42; 1.22.52; 1.22.58;
TRUE -> true, FALSE -> false
 1.21 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.20 16-Nov-2006  christos branches: 1.20.4;
__unused removal on arguments; approved by core.
 1.19 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.18 11-Dec-2005  christos branches: 1.18.20; 1.18.22;
merge ktrace-lwp.
 1.17 01-Jun-2005  drochner branches: 1.17.2;
more constification fallout
 1.16 15-Feb-2002  simonb branches: 1.16.16;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.15 12-Nov-2001  lukem add RCSIDs
 1.14 06-Jun-2000  jhawk branches: 1.14.4; 1.14.6;
Stop using DDB-specific "%n" kprintf() format specifier. This was
important as db_sym() can be called through printf() rather than
db_printf(), causing a trap as the standard %n usage is invoked.

The DDB-specific %n code should disappear from subr_prf.c soon...
 1.13 25-May-2000  jhawk branches: 1.13.2;
Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.12 30-Mar-2000  augustss Die, register, die!
 1.11 12-Apr-1999  pk branches: 1.11.2;
Quote "AS IS" as in the majority of Carnegy Mellon notices.
 1.10 06-Apr-1999  pk Fix a pasto in copyright text which has been procreating like rabbits..
 1.9 12-Feb-1999  thorpej branches: 1.9.2;
Fix printf format problems on Alpha.
 1.8 04-Feb-1997  cgd fix printf format widths
 1.7 03-Feb-1997  mycroft db_expr_t became a long.
 1.6 05-Feb-1996  christos DDB prototype changes.
 1.5 09-Oct-1994  mycroft db_error() does not return.
 1.4 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.3 18-Dec-1993  mycroft Canonicalize all #includes.
 1.2 20-May-1993  cgd branches: 1.2.4;
add explicit rcs id
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2.4.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.9.2.2 12-Apr-1999  pk branches: 1.9.2.2.2;
Pullup copyright text corrections.
 1.9.2.1 07-Apr-1999  pk Pull up from trunk: copyright text warts.
 1.9.2.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.13.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.14.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.14.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.14.4.1 14-Nov-2001  nathanw Catch up to -current.
 1.16.16.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.2 26-Feb-2007  yamt sync with head.
 1.17.2.1 30-Dec-2006  yamt sync with head.
 1.18.22.2 10-Dec-2006  yamt sync with head.
 1.18.22.1 22-Oct-2006  yamt sync with head
 1.18.20.1 18-Nov-2006  ad Sync with head.
 1.20.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.22.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.22.42.2 11-Mar-2010  yamt sync with head
 1.22.42.1 04-May-2009  yamt sync with head.
 1.26.40.1 22-Sep-2015  skrll Sync with HEAD
 1.26.22.1 03-Dec-2017  jdolecek update from HEAD
 1.27.18.1 10-Jun-2019  christos Sync with HEAD
 1.80 02-Nov-2023  martin Back out the following revisions on behalf of core:

sys/sys/lwp.h: revision 1.228
sys/sys/pipe.h: revision 1.40
sys/kern/uipc_socket.c: revision 1.306
sys/kern/kern_sleepq.c: revision 1.84
sys/rump/librump/rumpkern/locks_up.c: revision 1.13
sys/kern/sys_pipe.c: revision 1.165
usr.bin/fstat/fstat.c: revision 1.119
sys/rump/librump/rumpkern/locks.c: revision 1.87
sys/ddb/db_xxx.c: revision 1.78
sys/ddb/db_command.c: revision 1.187
sys/sys/condvar.h: revision 1.18
sys/ddb/db_interface.h: revision 1.42
sys/sys/socketvar.h: revision 1.166
sys/kern/uipc_syscalls.c: revision 1.209
sys/kern/kern_condvar.c: revision 1.60

Add cv_fdrestart() [...]
Use cv_fdrestart() to implement fo_restart.
Simplify/streamline pipes a little bit [...]

This changes have caused regressions and need to be debugged.
The cv_fdrestart() addition needs more discussion.
 1.79 15-Oct-2023  martin When converting from db_expr_t to a pointer cast via uintptr_t
to help kernels where the size differs (e.g. 32bit sparc64 kernels)
 1.78 13-Oct-2023  ad Simplify/streamline pipes a little bit:

- Allocate only one struct pipe not two (no need to be bidirectional here).
- Then use f_flag (FREAD/FWRITE) to figure out what to do in the fileops.
- Never wake the other side or acquire long-term (I/O) lock unless needed.
- Whenever possible, defer wakeups until after locks have been released.
- Do some things locklessly in pipe_ioctl() and pipe_poll().

Some notable results:

- -30% latency on a 486DX2/66 doing 1 byte ping-pong within a single process.
- 2.5x less lock contention during "make cleandir" of src on a 48 CPU machine.
- 1.5x bandwith with 1kB messages on the same 48 CPU machine (8kB: same b/w).
 1.77 08-Oct-2023  martin For architectures (mips64) where sizeof(db_expr_t) != sizeof(kcondvar_t *)
cast through uintptr_t.
 1.76 07-Oct-2023  ad Add some simple DDB show commands: condvar, selinfo, sleepq
 1.75 23-May-2020  ad Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.74 10-Mar-2020  christos Make the db_kernelonly() macro visible to all files and re-use it.
Register access is kernel only.
 1.73 01-Feb-2020  riastradh Load struct fdfile::ff_file with atomic_load_consume.

Exceptions: when we're only testing whether it's there, not about to
dereference it.

Note: We do not use atomic_store_release to set it because the
preceding mutex_exit should be enough.

(That said, it's not clear the mutex_enter/exit is needed unless
refcnt > 0 already, in which case maybe it would be a win to switch
from the membar implied by mutex_enter to the membar implied by
atomic_store_release -- which I would generally expect to be much
cheaper. And a little clearer without a long comment.)
 1.72 01-Feb-2020  riastradh Load struct filedesc::fd_dt with atomic_load_consume.

Exceptions: when fd_refcnt <= 1, or when holding fd_lock.

While here:

- Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused.
=> This is used only in fd_close and fd_abort, where it holds.
- Move bounds check assertion in fd_putfile to where it matters.
- Store fd_dt with atomic_store_release.
- Move load of fd_dt under lock in knote_fdclose.
- Omit membar_consumer in fdesc_readdir.
=> atomic_load_consume serves the same purpose now.
=> Was needed only on alpha anyway.
 1.71 27-Feb-2015  ozaki-r branches: 1.71.18; 1.71.22; 1.71.24;
Don't use an unset value as an address

Instead, show usage if no address is passed.
 1.70 05-Sep-2014  matt branches: 1.70.2;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.69 06-Jan-2013  christos remove previous, dmesg just works.
 1.68 06-Jan-2013  christos Add "show dmesg" that prints the contents of the message buffer.
 1.67 05-Jan-2013  christos Add "show panic" that shows the current panic string. two ports had it, and
it could be easily made MI.
 1.66 03-Dec-2011  christos branches: 1.66.8;
If we are DIAGNOSTIC don't try to go further if we failed to take the
lock, because we are going to trigger a KASSERT. Also hold the lock
longer and take the proc lock for kpsignal(). Maybe we should add
mutex_steal() and mutex_return() for the debugger? Lock correction
suggestion from jmcneill.
 1.65 02-Dec-2011  christos deal with the proc_lock mutex.
 1.64 12-Jun-2011  rmind branches: 1.64.2;
Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.63 31-May-2011  christos branches: 1.63.2;
re-instate db_kill_proc
 1.62 19-Jul-2009  rmind branches: 1.62.4; 1.62.6;
Add #ifdef MQUEUE for db_show_mqueue_cmd().

XXX: Wrong. DDB should be dynamic, modular, etc.
 1.61 24-May-2009  ad More changes to improve kern_descrip.c.

- Avoid atomics in more places.
- Remove the per-descriptor mutex, and just use filedesc_t::fd_lock.
It was only being used to synchronize close, and in any case we needed
to take fd_lock to free the descriptor slot.
- Optimize certain paths for the <NDFDFILE case.
- Sprinkle more comments and assertions.
- Cache more stuff in filedesc_t.
- Fix numerous minor bugs spotted along the way.
- Restructure how the open files array is maintained, for clarity and so
that we can eliminate the membar_consumer() call in fd_getfile(). This is
mostly syntactic sugar; the main functional change is that fd_nfiles now
lives alongside the open file array.

Some measurements with libmicro:

- simple file syscalls are like close() are between 1 to 10% faster.
- some nice improvements, e.g. poll(1000) which is ~50% faster.
 1.60 21-Mar-2009  ad Make 'show event', 'dmesg' work with crash(8).
XXX dmesg fails exactly the same way as /sbin/dmesg.
 1.59 09-Mar-2009  mrg include <stdbool.h> if not _KERNEL, and don't include kauth.h if _KERNEL.

now crash builds on i386.
 1.58 08-Mar-2009  mrg include ddb headers *after* sys/types.h or sys/param.h.
 1.57 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.56 18-Feb-2009  yamt - fix vmem unittest. rename VMEM_DEBUG so that it won't be abused again.
- reimplement vmem sanity checks with less code duplication.
- reimplement ddb vmem-related commands in a more consistent ways.
remove automatic whatis.
 1.55 04-Feb-2009  ad branches: 1.55.2;
Default 'show all procs' to /l. People tend to type 'ps' without modifiers
when providing information about deadlocks. Without the thread info it's
not very useful.
 1.54 25-Nov-2008  ad Add some basic DDB stuff for modules.
 1.53 14-Nov-2008  ad ifdef AIO
 1.52 03-Oct-2008  rmind branches: 1.52.2; 1.52.4;
Replace more intptr_t to uintptr_t when casting VA.
 1.51 14-Jul-2008  blymn Take care not to dereference NULL datapointer from fd table
Make output more readable and label what lock we are examining.
 1.50 10-Jul-2008  blymn Fix indents.
 1.49 10-Jul-2008  blymn Add a show files command that prints the vnodes associated with a
given struct proc and, if LOCKDEBUG is built in, the lock status of
the uvmobject.
 1.48 02-Dec-2007  ad branches: 1.48.14; 1.48.18; 1.48.20; 1.48.22; 1.48.24;
ps/w: display LWP info.
 1.47 07-Sep-2007  rmind branches: 1.47.6;
Implementation of POSIX message queues.

Reviewed by: <ad>, <tech-kern>
 1.46 19-Jul-2007  dsl branches: 1.46.4; 1.46.6; 1.46.8;
include cdefs.h before opt_xxx.h
 1.45 09-Jul-2007  ad branches: 1.45.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.44 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.43 30-Apr-2007  rmind Import of POSIX Asynchronous I/O.
Seems to be quite stable. Some work still left to do.

Please note, that syscalls are not yet MP-safe, because
of the file and vnode subsystems.

Reviewed by: <tech-kern>, <ad>
 1.42 22-Feb-2007  matt branches: 1.42.4; 1.42.6;
Fix lossage from boolean_t -> bool and updated x86 bus_dma.
 1.41 09-Feb-2007  ad branches: 1.41.2;
Merge newlock2 to head.
 1.40 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.39 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.38 14-May-2006  elad branches: 1.38.8; 1.38.10;
integrate kauth.
 1.37 22-Jan-2006  uwe branches: 1.37.2; 1.37.4; 1.37.6; 1.37.8; 1.37.10;
db_show_sched_qs: fix pointer cast lint considers troublesome.
 1.36 22-Jan-2006  uwe Add /l to show all procs usage.
 1.35 22-Jan-2006  uwe This is not IOCCC. Replace " >"[cp == p] with conditional expression.
Makes lint happy. Probably generates better code too (does on sh3).
 1.34 03-Dec-2005  he branches: 1.34.2;
After addition of "show all pools", we now need <sys/pool.h> here.
Fixes build problem for mac68k.
 1.33 01-Dec-2005  yamt add "show all pools" command for ddb.
 1.32 15-Oct-2005  yamt - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
from sys/bufq.h to sys/bufq_impl.h.
(is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c. (not tested)
 1.31 01-Jun-2005  drochner branches: 1.31.2;
more constification fallout
 1.30 26-Feb-2005  perry nuke trailing whitespace
 1.29 27-Jul-2004  nathanw branches: 1.29.4; 1.29.6;
Make ddb's "show sched_qs" aware of big-endian sched_qs arrangements.
 1.28 20-Sep-2003  thorpej Add a "show sched_qs" command to dump the run queues. Format is:
1 pid.lid (p_comm)
pid.lid (p_comm)
...

If a queue has procs, but no sched_whichqs bit, it shows:
!1 pid.lid (p_comm)
 1.27 07-Sep-2003  uwe Widen FLAGS column for ps/l so that all defined l_flag flags fit.
 1.26 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.25 02-Jul-2003  simonb branches: 1.25.2;
Allow the dmesg command to show the last N bytes of the kernel message
buffer.
 1.24 29-Jun-2003  fvdl Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.23 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.22 15-May-2003  atatat (1) Don't print the message buffer (via ddb's dmesg command) if the
message buffer has not yet been set up, mimicking code from the top of
the sysctl routine for retrieving the message buffer.

(2) Add a /l modifier to the trace command. This makes it print the
backtrace using printf() instead of db_printf(), which has the nice
side-effect of also putting it into the message buffer. A kernel with
ddb in it but disabled (ie, ddb.onpanic set to zero) will print a
backtrace (which ends up in the message buffer) before dumping (or
not, depending on the value of kern.dump_on_panic) and rebooting, but
if ddb is not disabled, the backtrace is not printed, and there's no
way to get it to display a backtrace such that you can retrieve it
after the dump. The backtrace printed by gdb is sometimes a little
different.

(3) Documentation for the above.
 1.21 28-Apr-2003  briggs Add a rudimentary 'trap to kgdb' command if KGDB is defined. This allows
systems with only one serial port for console, etc., to have at least some
basic access to remote-kgdb-over-serial, even if it is a bit awkward.
 1.20 04-Feb-2003  thorpej New callout implementation. This is based on callwheel implementation
done by Artur Grabowski and Thomas Nordin for OpenBSD, which is more
efficient in several ways than the callwheel implementation that it is
replacing. It has been adapted to our pre-existing callout API, and
also provides the slightly more efficient (and much more intuitive)
API (adapted to the callout_*() naming scheme) that the OpenBSD version
provides.

Among other things, this shaves a bunch of cycles off rescheduling-in-
the-future a callout which is already scheduled, which the common case
for TCP timers (notably REXMT and KEEP).

The API has been simplified a bit, as well. The (very confusing to
a good many people) "ACTIVE" state for callouts has gone away. There
is now only "PENDING" (scheduled to fire in the future) and "EXPIRED"
(has fired, and the function called).

Kernel version bump not done; we'll ride the 1.6N bump that happened
with the malloc(9) change.
 1.19 23-Jan-2003  pk Zombie procs have no lwps.
 1.18 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.17 26-Aug-2002  scw branches: 1.17.2;
Casting from a pointer, to a db_expr_t, has to go via an intptr_t.
(db_expr_t == int64_t on sh5, for example).
 1.16 15-Feb-2002  simonb branches: 1.16.8;
ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.15 12-Nov-2001  lukem add RCSIDs
 1.14 15-Sep-2001  chs use a for loop instead of goto.
 1.13 11-Sep-2001  thorpej Optimization suggested by Bill Sommerfeld: Keep a hint as to the
"earliest" firing callout in a bucket. This allows us to skip
the scan up the bucket if no callouts are due in the bucket.

A cheap O(1) hint update is done at callout insertion (if new callout
is earlier than hint) and removal (is bucket empty). A thorough
refresh of the hint is done when the bucket is traversed.

This doesn't matter much on machines with small values of hz
(e.g. i386), but on systems with large values of hz (e.g. Alpha),
it has a definite positive effect.

Also, keep the callwheel stats in evcnts, so that you can view them
with "vmstat -e".
 1.12 31-Jul-2001  atatat branches: 1.12.2;
Add an easy way to dump the message buffer from ddb.
 1.11 28-Nov-2000  thorpej branches: 1.11.2; 1.11.4;
Make sure values for a %llx are long long.
 1.10 28-Nov-2000  eeh Implement db_show_callout() again.
 1.9 25-May-2000  jhawk Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.8 26-Mar-2000  kleink Cast timeval members to types we know the printf conversions of.
 1.7 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.6 22-Jul-1999  thorpej branches: 1.6.2;
XXX LOCKING XXX of allproc; DDB runs with interrupts blocked, and MD
code should suspend other processors, so this probably isn't a problem,
but the comment is added anyhow.
 1.5 08-Sep-1998  thorpej branches: 1.5.8;
- Use proclists[], rather than checking allproc and zombproc explicitly.
- Add some comments about locking.
 1.4 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.3 31-Jan-1998  ross branches: 1.3.2;
Print more info on ps/w, note the current proc, and properly declare db_maxoff.
 1.2 24-Oct-1997  chuck fix printf formatting of "ps" (aka "show all proc") so that lines never
overflow (always hated that).

replaced "/m" flag with:
/a == show process address info
/n == show normal process info [currently the default]
/w == show process wait/emul info
 1.1 21-May-1997  gwr Move some DDB stuff here from kern_clock.c and kern_proc.c
 1.3.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.5.8.1 02-Aug-1999  thorpej Update from trunk.
 1.6.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.11.4.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.11.4.4 16-Mar-2002  jdolecek Catch up with -current.
 1.11.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.11.4.1 03-Aug-2001  lukem update to -current
 1.11.2.8 27-Aug-2002  nathanw Catch up to -current.
 1.11.2.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.11.2.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.11.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.11.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.11.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.11.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.12.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.16.8.1 29-Aug-2002  gehenna catch up with -current.
 1.17.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.25.2.9 11-Dec-2005  christos Sync with head.
 1.25.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.25.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.4 12-Aug-2004  skrll Sync with HEAD.
 1.25.2.3 03-Aug-2004  skrll Sync with HEAD
 1.25.2.2 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.25.2.1 02-Jul-2003  darrenr file db_xxx.c was added on branch ktrace-lwp on 2003-07-02 15:25:58 +0000
 1.29.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.29.4.1 29-Apr-2005  kent sync with -current
 1.31.2.6 07-Dec-2007  yamt sync with head
 1.31.2.5 27-Oct-2007  yamt sync with head.
 1.31.2.4 03-Sep-2007  yamt sync with head.
 1.31.2.3 26-Feb-2007  yamt sync with head.
 1.31.2.2 30-Dec-2006  yamt sync with head.
 1.31.2.1 21-Jun-2006  yamt sync with head.
 1.34.2.1 01-Feb-2006  yamt sync with head.
 1.37.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.8.2 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.37.8.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.37.6.1 24-May-2006  yamt sync with head.
 1.37.4.1 01-Jun-2006  kardel Sync with head.
 1.37.2.1 09-Sep-2006  rpaulo sync with head
 1.38.10.2 10-Dec-2006  yamt sync with head.
 1.38.10.1 22-Oct-2006  yamt sync with head
 1.38.8.2 18-Nov-2006  ad Sync with head.
 1.38.8.1 21-Oct-2006  ad Update for proc_representative_lwp() / calcru() signature change.
 1.41.2.4 07-May-2007  yamt sync with head.
 1.41.2.3 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.41.2.2 17-Feb-2007  yamt remove the now unused definition of RQMASK. from Daniel Sieger.
 1.41.2.1 17-Feb-2007  yamt - separate context switching and thread scheduling.
- introduce idle lwp.
- change some related MD/MI interfaces and implement i386 version.
 1.42.6.1 11-Jul-2007  mjf Sync with head.
 1.42.4.3 09-Oct-2007  ad Sync with head.
 1.42.4.2 08-Jun-2007  ad Sync with head.
 1.42.4.1 27-May-2007  ad ps/l: show the LWP name.
 1.45.2.2 10-Sep-2007  skrll Sync with HEAD.
 1.45.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.46.8.2 19-Jul-2007  dsl include cdefs.h before opt_xxx.h
 1.46.8.1 19-Jul-2007  dsl file db_xxx.c was added on branch matt-mips64 on 2007-07-19 21:54:52 +0000
 1.46.6.2 09-Jan-2008  matt sync with HEAD
 1.46.6.1 06-Nov-2007  matt sync with HEAD
 1.46.4.2 03-Dec-2007  joerg Sync with HEAD.
 1.46.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.47.6.1 08-Dec-2007  mjf Sync with HEAD.
 1.48.24.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.48.24.1 19-Oct-2008  haad Sync with HEAD.
 1.48.22.1 18-Jul-2008  simonb Sync with head.
 1.48.20.2 10-Oct-2008  skrll Sync with HEAD.
 1.48.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.48.18.3 19-Aug-2009  yamt sync with head.
 1.48.18.2 20-Jun-2009  yamt sync with head
 1.48.18.1 04-May-2009  yamt sync with head.
 1.48.14.3 17-Jan-2009  mjf Sync with HEAD.
 1.48.14.2 05-Oct-2008  mjf Sync with HEAD.
 1.48.14.1 28-Sep-2008  mjf Sync with HEAD.
 1.52.4.1 24-Feb-2009  snj branches: 1.52.4.1.4;
Pull up following revision(s) (requested by ad in ticket #488):
share/man/man4/ddb.4: revision 1.122
sys/ddb/db_xxx.c: revision 1.55 via patch
Default 'show all procs' to /l. People tend to type 'ps' without modifiers
when providing information about deadlocks. Without the thread info it's
not very useful.
 1.52.4.1.4.1 16-Feb-2012  matt Make ps /l also printout the uarea.
 1.52.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.52.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.52.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.55.2.2 23-Jul-2009  jym Sync with HEAD.
 1.55.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.62.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.62.4.2 12-Jun-2011  rmind sync with head
 1.62.4.1 16-Mar-2010  rmind Change struct uvm_object::vmobjlock to be dynamically allocated with
mutex_obj_alloc(). It allows us to share the locks among UVM objects.
 1.63.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.64.2.2 23-Jan-2013  yamt sync with head
 1.64.2.1 17-Apr-2012  yamt sync with head
 1.66.8.2 03-Dec-2017  jdolecek update from HEAD
 1.66.8.1 25-Feb-2013  tls resync with head
 1.70.2.1 06-Apr-2015  skrll Sync with HEAD
 1.71.24.1 29-Feb-2020  ad Sync with head.
 1.71.22.1 20-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1921):

sys/kern/kern_event.c: revision 1.106
sys/kern/sys_select.c: revision 1.51
sys/kern/subr_exec_fd.c: revision 1.10
sys/kern/sys_aio.c: revision 1.46
sys/kern/kern_descrip.c: revision 1.244
sys/kern/kern_descrip.c: revision 1.245
sys/ddb/db_xxx.c: revision 1.72
sys/ddb/db_xxx.c: revision 1.73
sys/miscfs/fdesc/fdesc_vnops.c: revision 1.132
sys/kern/uipc_usrreq.c: revision 1.195
sys/kern/sys_descrip.c: revision 1.36
sys/kern/uipc_usrreq.c: revision 1.196
sys/kern/uipc_socket2.c: revision 1.135
sys/kern/uipc_socket2.c: revision 1.136
sys/kern/kern_sig.c: revision 1.383
sys/kern/kern_sig.c: revision 1.384
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.107
sys/miscfs/procfs/procfs_vnops.c: revision 1.208
sys/kern/subr_exec_fd.c: revision 1.9
sys/kern/kern_descrip.c: revision 1.252
(all via patch)

Load struct filedesc::fd_dt with atomic_load_consume.

Exceptions: when fd_refcnt <= 1, or when holding fd_lock.

While here:
- Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused.
=> This is used only in fd_close and fd_abort, where it holds.
- Move bounds check assertion in fd_putfile to where it matters.
- Store fd_dt with atomic_store_release.
- Move load of fd_dt under lock in knote_fdclose.
- Omit membar_consumer in fdesc_readdir.
=> atomic_load_consume serves the same purpose now.
=> Was needed only on alpha anyway.

Load struct fdfile::ff_file with atomic_load_consume.
Exceptions: when we're only testing whether it's there, not about to
dereference it.

Note: We do not use atomic_store_release to set it because the
preceding mutex_exit should be enough.

(That said, it's not clear the mutex_enter/exit is needed unless
refcnt > 0 already, in which case maybe it would be a win to switch
from the membar implied by mutex_enter to the membar implied by
atomic_store_release -- which I would generally expect to be much
cheaper. And a little clearer without a long comment.)
kern_descrip.c: Fix membars around reference count decrement.

In general, the `last one out hit the lights' style of reference
counting (as opposed to the `whoever's destroying must wait for
pending users to finish' style) requires memory barriers like so:

... usage of resources associated with object ...
membar_release();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_acquire();
... freeing of resources associated with object ...

This way, all usage happens-before all freeing. This fixes several
errors:
- fd_close failed to ensure whatever its caller did would
happen-before the freeing, in the case where another thread is
concurrently trying to close the fd (ff->ff_file == NULL).
Fix: Add membar_release before atomic_dec_uint(&ff->ff_refcnt) in
that branch.
- fd_close failed to ensure all loads its caller had issued will have
happened-before the freeing, in the case where the fd is still in
use by another thread (fdp->fd_refcnt > 1 and ff->ff_refcnt-- > 0).
Fix: Change membar_producer to membar_release before
atomic_dec_uint(&ff->ff_refcnt).
- fd_close failed to ensure that any usage of fp by other callers
would happen-before any freeing it does.
Fix: Add membar_acquire after atomic_dec_uint_nv(&ff->ff_refcnt).
- fd_free failed to ensure that any usage of fdp by other callers
would happen-before any freeing it does.
Fix: Add membar_acquire after atomic_dec_uint_nv(&fdp->fd_refcnt).

While here, change membar_exit -> membar_release. No semantic
change, just updating away from the legacy API.
 1.71.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6 09-Jul-2023  riastradh ddb: New `show all tstiles' command.

Shows who's waiting for which locks and what the owner is up to.

XXX pullup-10
 1.5 31-May-2020  rin branches: 1.5.20;
Revert introduction of db_alloc.h.

db_alloc() and friends are already provided in crash.c.
Sorry for confusing you...
 1.4 31-May-2020  rin Introduce db_alloc.h.

Provide db_alloc() and friends to userland, i.e., crash(8).
 1.3 04-Mar-2018  mlelstv Add command to print device list.
 1.2 10-Apr-2009  ad branches: 1.2.2; 1.2.4; 1.2.6;
add boilerplate missed in initial commit
 1.1 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.2.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.6.1 10-Apr-2009  jym file ddb.h was added on branch jym-xensuspend on 2009-05-13 17:19:05 +0000
 1.2.4.2 04-May-2009  yamt sync with head.
 1.2.4.1 10-Apr-2009  yamt file ddb.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:32 +0000
 1.2.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.2.2.1 10-Apr-2009  skrll file ddb.h was added on branch nick-hppapmap on 2009-04-28 07:35:13 +0000
 1.5.20.1 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

sys/arch/m68k/include/mutex.h: revision 1.13
sys/arch/arm/include/cpu.h: revision 1.125
sys/arch/sun68k/include/intr.h: revision 1.21
sys/arch/arm/include/mutex.h: revision 1.28
sys/sys/rwlock.h: revision 1.18
sys/arch/powerpc/include/mutex.h: revision 1.7
sys/arch/arm/include/mutex.h: revision 1.29
sys/arch/powerpc/include/mutex.h: revision 1.8
sys/uvm/uvm_param.h: revision 1.42
sys/sys/ksem.h: revision 1.16
sys/arch/x86/include/mutex.h: revision 1.10
sys/sys/proc.h: revision 1.372
sys/sys/ksem.h: revision 1.17
sys/arch/ia64/include/mutex.h: revision 1.8
sys/arch/evbarm/include/intr.h: revision 1.29
sys/sys/lua.h: revision 1.9
sys/arch/next68k/include/intr.h: revision 1.23
sys/arch/ia64/include/mutex.h: revision 1.9
sys/arch/hp300/include/intr.h: revision 1.35
sys/arch/hp300/include/intr.h: revision 1.36
sys/arch/sparc/include/cpu.h: revision 1.111
sys/arch/hppa/include/mutex.h: revision 1.16
sys/arch/vax/include/intr.h: revision 1.31
sys/arch/hppa/include/mutex.h: revision 1.17
sys/arch/news68k/include/intr.h: revision 1.28
sys/arch/hppa/include/mutex.h: revision 1.18
sys/arch/hppa/include/intr.h: revision 1.3
sys/arch/hppa/include/mutex.h: revision 1.19
sys/arch/hppa/include/intr.h: revision 1.4
sys/sys/sched.h: revision 1.92
sys/opencrypto/cryptodev.h: revision 1.51
sys/arch/vax/include/mutex.h: revision 1.20
sys/arch/sparc64/include/mutex.h: revision 1.10
sys/arch/ia64/include/sapicvar.h: revision 1.2
sys/arch/riscv/include/mutex.h: revision 1.5
sys/arch/amiga/dev/grfabs_cc.c: revision 1.39
sys/external/bsd/drm2/include/linux/idr.h: revision 1.11
sys/arch/riscv/include/mutex.h: revision 1.6
sys/ddb/files.ddb: revision 1.16
sys/arch/mac68k/include/intr.h: revision 1.32
share/man/man4/ddb.4: revision 1.203
sys/ddb/db_command.c: revision 1.183
sys/arch/mips/include/mutex.h: revision 1.10
sys/ddb/db_command.c: revision 1.184
sys/arch/x68k/include/intr.h: revision 1.22
sys/arch/sparc/include/psl.h: revision 1.51
sys/arch/or1k/include/mutex.h: revision 1.4
sys/arch/mips/include/mutex.h: revision 1.11
sys/arch/arm/xscale/pxa2x0_intr.h: revision 1.16
sys/arch/sparc64/include/cpu.h: revision 1.134
sys/arch/sparc/include/psl.h: revision 1.52
sys/arch/or1k/include/mutex.h: revision 1.5
sys/arch/mvme68k/include/intr.h: revision 1.22
sys/arch/luna68k/include/intr.h: revision 1.16
external/cddl/osnet/sys/sys/kcondvar.h: revision 1.6
sys/arch/sparc/include/mutex.h: revision 1.12
sys/arch/sparc/include/mutex.h: revision 1.13
sys/arch/usermode/include/mutex.h: revision 1.5
sys/arch/usermode/include/mutex.h: revision 1.6
sys/kern/kern_core.c: revision 1.38
usr.sbin/crash/Makefile: revision 1.49
sys/arch/amiga/include/intr.h: revision 1.23
sys/arch/alpha/include/mutex.h: revision 1.12
sys/arch/alpha/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.16
sys/ddb/ddb.h: revision 1.6
sys/arch/sparc64/include/mutex.h: revision 1.8
sys/arch/sh3/include/mutex.h: revision 1.12
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.17
sys/ddb/db_syncobj.c: revision 1.1
sys/arch/vax/include/mutex.h: revision 1.18
sys/arch/sparc64/include/psl.h: revision 1.63
sys/arch/sparc64/include/mutex.h: revision 1.9
sys/arch/sh3/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/obio.c: revision 1.13
sys/arch/atari/include/intr.h: revision 1.23
sys/ddb/db_syncobj.c: revision 1.2
sys/arch/vax/include/mutex.h: revision 1.19
sys/arch/evbarm/g42xxeb/obio.c: revision 1.14
sys/arch/evbarm/g42xxeb/obio.c: revision 1.15
sys/arch/cesfic/include/intr.h: revision 1.14
sys/ddb/db_syncobj.h: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.134
sys/arch/evbarm/g42xxeb/obio.c: revision 1.16
sys/arch/cesfic/include/intr.h: revision 1.15
sys/arch/arm/xscale/pxa2x0_intr.c: revision 1.26
sys/sys/cpu_data.h: revision 1.54
sys/arch/m68k/include/mutex.h: revision 1.12
sys/arch/ia64/acpi/madt.c: revision 1.6

sys/rwlock.h: Make this more self-contained for bool.

machine/mutex.h: Sprinkle includes so this can be used by crash(8).

ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

sys: Rip <sys/resourcevar.h> out of <uvm/uvm_param.h>.

And thus out of <sys/param.h>, which is exceedingly overused and
fragile and delenda est.

Should fix (some) issues with the recent inclusion of machine/lock.h
in various machine/mutex.h files.

arm/mutex.h: Need machine/intr.h, machine/lock.h.

For ipl_cookie_t and __cpu_simple_lock_t.
evbarm/intr.h: Define ipl_cookie_t before including ARM_INTR_IMPL.

Otherwise arm/mutex.h doesn't work, due to a cyclic dependency which
should really be fixed.
opencrypto/cryptodev.h: Fix includes.
- Move sys/condvar.h under #ifdef _KERNEL.
- Add some other necessary includes and forward declarations.
- Sort.

hp300/intr.h: Fix missing includes.
linux/idr.h: Need <sys/mutex.h> for kmutex_t.
amiga/intr.h: Don't define spl*() functions if !_KERNEL.

This is used by crash(8) now, and what's important is ipl_cookie_t.
cesfic/intr.h: Expose ipl_cookie_t to userland for crash(8).
cesfic/intr.h: Expose ipl_cookie_t to userland only with _KMEMUSER.

Probably not necessary but let's be a little more cautious about
this.

atari/intr.h: Expose ipl_cookie_t with _KMEMUSER for crash(8).

arm/cpu.h: Need sys/param.h for COHERENCY_UNIT.

Nix machine/param.h -- not meant to be used directly, pulled in by
sys/param.h.

Move the definition of ipl_cookie_t out of the kernel-only sections,
some _KMEMUSER applications need it.

ddb: Cast pointer to uintptr_t first before db_expr_t.

hppa/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

luna68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

mvme68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

news68k/intr.h: Fix includes. Put some definitions under _KERNEL.

next68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

sys/ksem.h: Hack around fstat(8) abuse of _KERNEL.

sun68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

vax/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

x68k/intr.h: Put functions under _KERNEL so crash(8) can use this.

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

Explicitly include <sys/mutex.h> for kmutex_t.

Replace kmutex_t * (which may be undefined here) with struct kmutex *,
suggested by Taylor.

hp300/intr.h: Put most of this under #ifdef _KERNEL.
Only ipl_cookie_t really needs to be exposed now, for crash(8).

mac68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).
Make inclusion of sys/intr.h explicit for spl*.

fix hppa and vax builds.

machine/lock.h isn't necessary for __cpu_simple_lock_t, it's in
sys/types.h. avoids cpu_data.h vs sched.h include order issues.

move the hppa ipl_t typedef with the moved usage of it.
machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.

ddb: Cast pointer to uintptr_t, then to db_expr_t.
Avoids warnings about conversion between pointer and integer of
different size on some architectures.

re-fix hppa builds.

this file uses __cpu_simple_lock(), not just the underlying type,
so it does need machine/lock.h.

Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex. Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT. Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.

ia64: Need sys/types.h for u_int, vaddr_t; sys/mutex.h for kmutex_t.

explicitly include no longer implicitly included sys/mutex.h.

arm/xscale: Use sys/bitops.h fls32 - 1 instead of 31 - __builtin_clz.
Sidesteps namespace collision with `#define bits ...' in net/zlib.c.

complete the previous - there were two calls to find_first_bit() to fix.

arm/xscale: Missed a spot with previous find_first_bit commit.

evbarm/g42xxeb: Fix off-by-one in previous.

The original find_first_bit(x) was 31 - __builtin_clz((uint32_t)x),
which is equivalent to fls32(x) - 1, not to fls32(x).

Note that fls32 is 1-based and returns 0 for x=0.
 1.14 06-Oct-2021  uwe Sort variable declarations. Add short comments while here.

The list was neither sorted nor grouped logically when db_dumpstack
and db_panicstackframes were added to modify the panic behavior.
 1.13 17-Feb-2018  sevan Opt to print a backtrace on panic by default with the intention of improving bug reports.
Instead of relying on ddb.onpanic=2, introduce a new sysctl called dumpstack to handle this.
via <jmcneill> channeled through <mrg> on tech-kern[1]

[1] https://mail-index.netbsd.org/tech-kern/2018/02/15/msg023103.html
 1.12 28-Dec-2017  christos - add ddb.panicstackframes to avoid scrolling the interesting parts of panic
stacktraces off.
- change valuep to void * to avoid casts
- sort and use c99 initializers in variables array
 1.11 10-Feb-2013  apb Move the DDB-specific part of vpanic() to a new db_panic() function,
defined in ddb/db_panic.c and declared in ddb/ddbvar.h. No functional
change.

The copyright years in db_panic.c are the years in which changes were
made to the code that has now been moved to db_panic.c. No pre-NetBSD
copyright notice is needed because revision 1.12 of subr_prf.c had only
the trivial "#ifdef DDB \\ Debugger(); \\ #endif"
 1.10 10-Feb-2013  apb read_symtab_from_file used to be defined in ddb/db_aout.c, but that
file was deleted in 2011. Now delete the declaration in ddb/ddbvar.h.
 1.9 28-Apr-2008  martin branches: 1.9.34; 1.9.44;
Remove clause 3 and 4 from TNF licenses
 1.8 11-Dec-2005  christos branches: 1.8.70; 1.8.72; 1.8.74;
merge ktrace-lwp.
 1.7 29-Sep-2004  reinoud Implement ddb setting that allows all ddb output to be teed into the
kernel message buffer/log. Its off by default and can be switched on in the
kernel configuration on build time, be set as a variable in ddb and be set
using sysctl.

This adds the sysctl value
ddb.tee_msgbuf = 0
by default.

The functionality is especially added and aimed for developers who are not
blessed with a serial console and wish to keep all their ddb output in the
log. Specifying /l as a modifier to some selected commands will also put
the output in the log but not all commands provide one nor has the same
meaning for all commands.

This feature could in the future also be implemented as an ddb command but
that could lead to more bloat allthough maybe easier for non developpers to
use when mailing their backtraces from kernel crashes.
 1.6 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.3 15-Feb-2002  simonb ANSIfy, KNF.
Make some variables and functions static when not used outside of a module.
Make variables in headers extern.
Delete the unused db_find_watchpoint() function.
 1.2 29-Oct-1998  jonathan branches: 1.2.24; 1.2.26;
Add options DDB_FROMCONSOLE and sysctl ddb.fromconsole, analagous to
DDB_ONPANIC. Lets user ignore breaks but enter DDB on panic. Intended
for machines where debug on panic is useful, but DDB entry is not,
(public-access console, or terminal-servers which send spurious breaks)

Add new ddb hook, console_debugger(), which decides whether or not to
ignore console ddb requests. Console drivers should be updated to call
console_debugger(), not Debugger(), in response to serial-console
break or ddb keyboard sequence.
 1.1 04-Jul-1998  jonathan defopt DDB.
 1.2.26.1 16-Mar-2002  jdolecek Catch up with -current.
 1.2.24.1 28-Feb-2002  nathanw Catch up to -current.
 1.5.2.5 19-Oct-2004  skrll Sync with HEAD
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.8.74.1 16-May-2008  yamt sync with head.
 1.8.72.1 18-May-2008  yamt sync with head.
 1.8.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.44.1 25-Feb-2013  tls resync with head
 1.9.34.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.16 09-Jul-2023  riastradh ddb: New `show all tstiles' command.

Shows who's waiting for which locks and what the owner is up to.

XXX pullup-10
 1.15 06-Oct-2021  uwe branches: 1.15.4;
Add DDB_DUMPSTACK to opt_ddbparam.h.
PR kern/56445
 1.14 06-Oct-2021  uwe One option per-line for opt_ddbparam.h options. Sort.
 1.13 06-Feb-2021  dbj defparam DB_MAX_WIDTH
 1.12 04-Mar-2018  mlelstv branches: 1.12.16;
Add command to print device list.
 1.11 28-Dec-2017  christos - add ddb.panicstackframes to avoid scrolling the interesting parts of panic
stacktraces off.
- change valuep to void * to avoid casts
- sort and use c99 initializers in variables array
 1.10 16-Nov-2014  uebayasi Define ddb module.
 1.9 10-Feb-2013  apb Hook the new ddb/db_panic.c to the build.
 1.8 01-Sep-2012  matt branches: 1.8.2;
Make DB_MAX_LINES a kernel option
 1.7 28-Jul-2011  uebayasi branches: 1.7.2;
Define SYMTAB_SPACE in opt_ksyms.h, not opt_ddbparam.h. Ensure
that ddb(4) code is independent of SYMTAB_SPACE value.
 1.6 11-Apr-2011  mrg obsolete DB_AOUT_SYMBOLS. however, we need to leave most of the code
in db_sym.[ch] as it is used by the elf version of crash(8).

i will be cleaning up the db_sym.c code in a follow up commit to avoid
having dead code compiled.
 1.5 27-Sep-2009  bsh branches: 1.5.4; 1.5.6;
kgdb still needs db_{get,put}_value in ddb/db_access.c when SOFTWARE_SSTEP is defined in db_machdep.h.
 1.4 31-Mar-2009  reinoud KGDB does no longer refers to ddb/db_access. Fixes compilation problems of KGDB
kernels.
 1.3 07-Mar-2009  ad Make ddb compile and work in userspace. Mostly this is comprised of three
types of changes:

- Add a few new methods to replace stuff like p_find(), CPU_INFO_FOREACH.

- Use db_read_bytes() instead of accessing kernel structures directly,
and similar changes.

- Add ifdef _KERNEL where the above hasn't been done, and an XXX comment.
 1.2 22-Sep-2007  martin branches: 1.2.24; 1.2.32; 1.2.38;
Add a new option DDB_VERBOSE_HELP that adds online help to ddb.
From Adam Hamsik.
Minor modifications by me, all bugs are probably mine.
 1.1 27-Nov-2005  thorpej branches: 1.1.2; 1.1.4; 1.1.22; 1.1.36; 1.1.50; 1.1.52;
Move DDB files to files.ddb
XXX couple of kgdb references -- clean up later
 1.1.52.1 06-Nov-2007  matt sync with HEAD
 1.1.50.1 02-Oct-2007  joerg Sync with HEAD.
 1.1.36.1 09-Oct-2007  ad Sync with head.
 1.1.22.3 27-Oct-2007  yamt sync with head.
 1.1.22.2 21-Jun-2006  yamt sync with head.
 1.1.22.1 27-Nov-2005  yamt file files.ddb was added on branch yamt-lazymbuf on 2006-06-21 15:02:11 +0000
 1.1.4.2 11-Dec-2005  christos Sync with head.
 1.1.4.1 27-Nov-2005  christos file files.ddb was added on branch ktrace-lwp on 2005-12-11 10:28:47 +0000
 1.1.2.2 29-Nov-2005  yamt sync with head.
 1.1.2.1 27-Nov-2005  yamt file files.ddb was added on branch yamt-readahead on 2005-11-29 21:23:07 +0000
 1.2.38.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.32.1 28-Apr-2009  skrll Sync with HEAD.
 1.2.24.2 11-Mar-2010  yamt sync with head
 1.2.24.1 04-May-2009  yamt sync with head.
 1.5.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.5.4.1 21-Apr-2011  rmind sync with head
 1.7.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.7.2.1 30-Oct-2012  yamt sync with head
 1.8.2.2 03-Dec-2017  jdolecek update from HEAD
 1.8.2.1 25-Feb-2013  tls resync with head
 1.12.16.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15.4.1 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

sys/arch/m68k/include/mutex.h: revision 1.13
sys/arch/arm/include/cpu.h: revision 1.125
sys/arch/sun68k/include/intr.h: revision 1.21
sys/arch/arm/include/mutex.h: revision 1.28
sys/sys/rwlock.h: revision 1.18
sys/arch/powerpc/include/mutex.h: revision 1.7
sys/arch/arm/include/mutex.h: revision 1.29
sys/arch/powerpc/include/mutex.h: revision 1.8
sys/uvm/uvm_param.h: revision 1.42
sys/sys/ksem.h: revision 1.16
sys/arch/x86/include/mutex.h: revision 1.10
sys/sys/proc.h: revision 1.372
sys/sys/ksem.h: revision 1.17
sys/arch/ia64/include/mutex.h: revision 1.8
sys/arch/evbarm/include/intr.h: revision 1.29
sys/sys/lua.h: revision 1.9
sys/arch/next68k/include/intr.h: revision 1.23
sys/arch/ia64/include/mutex.h: revision 1.9
sys/arch/hp300/include/intr.h: revision 1.35
sys/arch/hp300/include/intr.h: revision 1.36
sys/arch/sparc/include/cpu.h: revision 1.111
sys/arch/hppa/include/mutex.h: revision 1.16
sys/arch/vax/include/intr.h: revision 1.31
sys/arch/hppa/include/mutex.h: revision 1.17
sys/arch/news68k/include/intr.h: revision 1.28
sys/arch/hppa/include/mutex.h: revision 1.18
sys/arch/hppa/include/intr.h: revision 1.3
sys/arch/hppa/include/mutex.h: revision 1.19
sys/arch/hppa/include/intr.h: revision 1.4
sys/sys/sched.h: revision 1.92
sys/opencrypto/cryptodev.h: revision 1.51
sys/arch/vax/include/mutex.h: revision 1.20
sys/arch/sparc64/include/mutex.h: revision 1.10
sys/arch/ia64/include/sapicvar.h: revision 1.2
sys/arch/riscv/include/mutex.h: revision 1.5
sys/arch/amiga/dev/grfabs_cc.c: revision 1.39
sys/external/bsd/drm2/include/linux/idr.h: revision 1.11
sys/arch/riscv/include/mutex.h: revision 1.6
sys/ddb/files.ddb: revision 1.16
sys/arch/mac68k/include/intr.h: revision 1.32
share/man/man4/ddb.4: revision 1.203
sys/ddb/db_command.c: revision 1.183
sys/arch/mips/include/mutex.h: revision 1.10
sys/ddb/db_command.c: revision 1.184
sys/arch/x68k/include/intr.h: revision 1.22
sys/arch/sparc/include/psl.h: revision 1.51
sys/arch/or1k/include/mutex.h: revision 1.4
sys/arch/mips/include/mutex.h: revision 1.11
sys/arch/arm/xscale/pxa2x0_intr.h: revision 1.16
sys/arch/sparc64/include/cpu.h: revision 1.134
sys/arch/sparc/include/psl.h: revision 1.52
sys/arch/or1k/include/mutex.h: revision 1.5
sys/arch/mvme68k/include/intr.h: revision 1.22
sys/arch/luna68k/include/intr.h: revision 1.16
external/cddl/osnet/sys/sys/kcondvar.h: revision 1.6
sys/arch/sparc/include/mutex.h: revision 1.12
sys/arch/sparc/include/mutex.h: revision 1.13
sys/arch/usermode/include/mutex.h: revision 1.5
sys/arch/usermode/include/mutex.h: revision 1.6
sys/kern/kern_core.c: revision 1.38
usr.sbin/crash/Makefile: revision 1.49
sys/arch/amiga/include/intr.h: revision 1.23
sys/arch/alpha/include/mutex.h: revision 1.12
sys/arch/alpha/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.16
sys/ddb/ddb.h: revision 1.6
sys/arch/sparc64/include/mutex.h: revision 1.8
sys/arch/sh3/include/mutex.h: revision 1.12
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.17
sys/ddb/db_syncobj.c: revision 1.1
sys/arch/vax/include/mutex.h: revision 1.18
sys/arch/sparc64/include/psl.h: revision 1.63
sys/arch/sparc64/include/mutex.h: revision 1.9
sys/arch/sh3/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/obio.c: revision 1.13
sys/arch/atari/include/intr.h: revision 1.23
sys/ddb/db_syncobj.c: revision 1.2
sys/arch/vax/include/mutex.h: revision 1.19
sys/arch/evbarm/g42xxeb/obio.c: revision 1.14
sys/arch/evbarm/g42xxeb/obio.c: revision 1.15
sys/arch/cesfic/include/intr.h: revision 1.14
sys/ddb/db_syncobj.h: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.134
sys/arch/evbarm/g42xxeb/obio.c: revision 1.16
sys/arch/cesfic/include/intr.h: revision 1.15
sys/arch/arm/xscale/pxa2x0_intr.c: revision 1.26
sys/sys/cpu_data.h: revision 1.54
sys/arch/m68k/include/mutex.h: revision 1.12
sys/arch/ia64/acpi/madt.c: revision 1.6

sys/rwlock.h: Make this more self-contained for bool.

machine/mutex.h: Sprinkle includes so this can be used by crash(8).

ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

sys: Rip <sys/resourcevar.h> out of <uvm/uvm_param.h>.

And thus out of <sys/param.h>, which is exceedingly overused and
fragile and delenda est.

Should fix (some) issues with the recent inclusion of machine/lock.h
in various machine/mutex.h files.

arm/mutex.h: Need machine/intr.h, machine/lock.h.

For ipl_cookie_t and __cpu_simple_lock_t.
evbarm/intr.h: Define ipl_cookie_t before including ARM_INTR_IMPL.

Otherwise arm/mutex.h doesn't work, due to a cyclic dependency which
should really be fixed.
opencrypto/cryptodev.h: Fix includes.
- Move sys/condvar.h under #ifdef _KERNEL.
- Add some other necessary includes and forward declarations.
- Sort.

hp300/intr.h: Fix missing includes.
linux/idr.h: Need <sys/mutex.h> for kmutex_t.
amiga/intr.h: Don't define spl*() functions if !_KERNEL.

This is used by crash(8) now, and what's important is ipl_cookie_t.
cesfic/intr.h: Expose ipl_cookie_t to userland for crash(8).
cesfic/intr.h: Expose ipl_cookie_t to userland only with _KMEMUSER.

Probably not necessary but let's be a little more cautious about
this.

atari/intr.h: Expose ipl_cookie_t with _KMEMUSER for crash(8).

arm/cpu.h: Need sys/param.h for COHERENCY_UNIT.

Nix machine/param.h -- not meant to be used directly, pulled in by
sys/param.h.

Move the definition of ipl_cookie_t out of the kernel-only sections,
some _KMEMUSER applications need it.

ddb: Cast pointer to uintptr_t first before db_expr_t.

hppa/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

luna68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

mvme68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

news68k/intr.h: Fix includes. Put some definitions under _KERNEL.

next68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

sys/ksem.h: Hack around fstat(8) abuse of _KERNEL.

sun68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

vax/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

x68k/intr.h: Put functions under _KERNEL so crash(8) can use this.

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

Explicitly include <sys/mutex.h> for kmutex_t.

Replace kmutex_t * (which may be undefined here) with struct kmutex *,
suggested by Taylor.

hp300/intr.h: Put most of this under #ifdef _KERNEL.
Only ipl_cookie_t really needs to be exposed now, for crash(8).

mac68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).
Make inclusion of sys/intr.h explicit for spl*.

fix hppa and vax builds.

machine/lock.h isn't necessary for __cpu_simple_lock_t, it's in
sys/types.h. avoids cpu_data.h vs sched.h include order issues.

move the hppa ipl_t typedef with the moved usage of it.
machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.

ddb: Cast pointer to uintptr_t, then to db_expr_t.
Avoids warnings about conversion between pointer and integer of
different size on some architectures.

re-fix hppa builds.

this file uses __cpu_simple_lock(), not just the underlying type,
so it does need machine/lock.h.

Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex. Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT. Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.

ia64: Need sys/types.h for u_int, vaddr_t; sys/mutex.h for kmutex_t.

explicitly include no longer implicitly included sys/mutex.h.

arm/xscale: Use sys/bitops.h fls32 - 1 instead of 31 - __builtin_clz.
Sidesteps namespace collision with `#define bits ...' in net/zlib.c.

complete the previous - there were two calls to find_first_bit() to fix.

arm/xscale: Missed a spot with previous find_first_bit commit.

evbarm/g42xxeb: Fix off-by-one in previous.

The original find_first_bit(x) was 31 - __builtin_clz((uint32_t)x),
which is equivalent to fls32(x) - 1, not to fls32(x).

Note that fls32 is 1-based and returns 0 for x=0.

RSS XML Feed