Commit Graph

493 Commits

Author SHA1 Message Date
skrll d20ab3a0c2 Remove "also;" 2020-10-30 16:29:49 +00:00
skrll 155f2770cc Add a "show fdt" ddb command 2020-10-30 16:08:44 +00:00
skrll 3d56dc6d58 Sort the db_show_cmd entries 2020-10-30 07:17:29 +00:00
skrll 9fe75a0d78 Put the 'added from all sub cmds' comment above the four commands that
were added as part of the work in r1.98
2020-10-30 07:03:50 +00:00
skrll 0bdfd0c319 Whitespace 2020-10-30 06:59:43 +00:00
skrll f157d2e256 Trailing whitespace 2020-10-30 06:57:08 +00:00
uwe 54e5d2611a 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.
2020-07-29 23:29:42 +00:00
simonb afb79ab05b Protect against multiple inclusion. 2020-06-28 04:06:14 +00:00
rin d76d437a3f 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.
2020-05-31 23:34:34 +00:00
rin c3cc3a31be Revert introduction of db_alloc.h.
db_alloc() and friends are already provided in crash.c.
Sorry for confusing you...
2020-05-31 09:51:55 +00:00
rin 223a0956ca 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.
2020-05-31 09:42:46 +00:00
rin cd246064d2 Introduce db_alloc.h.
Provide db_alloc() and friends to userland, i.e., crash(8).
2020-05-31 09:40:09 +00:00
ad 0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
skrll 15572d36c9 Handle "no count" properly in db_kernhist_print_cmd 2020-04-13 11:43:27 +00:00
mlelstv 06d11bb0d0 also print the LWP reference count. 2020-04-04 13:59:16 +00:00
maya 5f3e77959d Remove a.out leftovers (unused) 2020-03-30 20:45:59 +00:00
christos 5a4646458a Make the db_kernelonly() macro visible to all files and re-use it.
Register access is kernel only.
2020-03-10 15:58:36 +00:00
christos 18fbafecbc print a message for the commands crash does not support.
Allow "show lock"
2020-03-09 01:46:24 +00:00
hikaru 5a05c3b804 Correct PPID of "show all procs/n" 2020-02-26 07:57:24 +00:00
ad 82002773ec - 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.
2020-02-15 18:12:14 +00:00
riastradh 17201b1c03 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.)
2020-02-01 02:23:23 +00:00
riastradh 8e6cd4ce57 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.
2020-02-01 02:23:03 +00:00
uwe 3c58a5dbfe Fix typo in comment. 2020-01-26 01:42:55 +00:00
ad 2ddceed1d9 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.
2020-01-08 17:38:41 +00:00
thorpej 599c240526 - 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.
2020-01-01 22:57:16 +00:00
ad 9b1e2fa25c 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.
2019-12-27 12:51:56 +00:00
joerg fcbdfe5fba Teach ddb(4) about printing the full mount list. 2019-12-15 20:29:08 +00:00
ad c8d15fa565 Fix crash(8). Will revisit. 2019-11-22 23:01:49 +00:00
rin df564de276 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.
2019-10-02 09:36:30 +00:00
uwe dc64369beb 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.
2019-09-29 02:49:59 +00:00
uwe 59ae426bf2 db_command - make setting have_addr more clear.
Don't set it to false that it's already initialized to.
2019-09-29 02:42:12 +00:00
uwe a11e9371ac db_command - make sure count is always initialized. 2019-09-29 02:35:39 +00:00
uwe 22d01b8c34 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.
2019-09-29 02:00:22 +00:00
mrg 3744368154 fix "show kernhist".
set addr = 0 if we don't have_addr and avoid using random garbage in addr.
2019-09-22 12:57:34 +00:00
uwe af5fcdd4a0 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
2019-09-12 18:43:02 +00:00
ryo 72ca669c4a db_get_qvalue() with size=8 on 64bit arch returns incorrect value. fixed. 2019-09-12 17:09:00 +00:00
ryo 6e5e6fa958 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.
2019-09-12 09:20:23 +00:00
ryo 77e643c7fb - examin/m displays with splitting by spaces as specified size
- add support 'q' modifier on all arch
- consider endianness
2019-09-10 09:32:04 +00:00
ryo 31e239d6f3 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")
2019-09-10 08:16:04 +00:00
kamil 47022302a1 Avoids signedness bit shift in db_get_value()
Appease UBSan.
2019-08-23 14:48:50 +00:00
mrg 3b128d1cd4 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?
2019-06-02 06:09:17 +00:00
skrll 5a515b48db KNF 2019-03-12 07:44:58 +00:00
mrg fbffadb9f8 - 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
2019-02-03 03:19:25 +00:00
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
maxv 038a8e9aad no, should be dst 2018-11-02 11:59:59 +00:00
maxv 7c827ea236 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.
2018-11-02 08:59:59 +00:00
kre a63b9e9c06 When this file is used when not building the kernel (eg: /usr/sbin/crash)
make cnpollc() go away.
2018-09-17 01:49:54 +00:00
mrg c2d6cd62e8 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.)
2018-09-16 23:18:55 +00:00
mrg e8bf3d6996 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().
2018-09-15 08:48:18 +00:00
mrg 60b1eff445 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.
2018-09-13 01:55:16 +00:00