path: root/sys/sys/kdb.h
Commit message (Collapse)AuthorAgeFilesLines
* KDB: remove obsolete KDB_WHY_NDISMarius Strobl2021-01-261-1/+0
| | | | ndis(4) has been removed in bfc99943b04b46a6c1c885ce7bcc6f235b7422aa.
* Fix handling of NMIs from unknown sources (BMC, hypervisor)Eric van Gyzen2020-04-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Release kernels have no KDB backends enabled, so they discard an NMI if it is not due to a hardware failure. This includes NMIs from IPMI BMCs and hypervisors. Furthermore, the interaction of panic_on_nmi, kdb_on_nmi, and debugger_on_panic is confusing. Respond to all NMIs according to panic_on_nmi and debugger_on_panic. Remove kdb_on_nmi. Expand the meaning of panic_on_nmi by making it a bitfield. There are currently two bits: one for NMIs due to hardware failure, and one for all others. Leave room for more. If panic_on_nmi and debugger_on_panic are both true, don't actually panic, but directly enter the debugger, to allow someone to leave the debugger and [hopefully] resume normal execution. Reviewed by: kib MFC after: 2 weeks Relnotes: yes: machdep.kdb_on_nmi is gone; machdep.panic_on_nmi changed Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D24558 Notes: svn path=/head/; revision=360328
* Implement NetGDB(4)Conrad Meyer2019-10-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetGDB(4) is a component of a system using a panic-time network stack to remotely debug crashed FreeBSD kernels over the network, instead of traditional serial interfaces. There are three pieces in the complete NetGDB system. First, a dedicated proxy server must be running to accept connections from both NetGDB and gdb(1), and pass bidirectional traffic between the two protocols. Second, the NetGDB client is activated much like ordinary 'gdb' and similarly to 'netdump' in ddb(4) after a panic. Like other debugnet(4) clients (netdump(4)), the network interface on the route to the proxy server must be online and support debugnet(4). Finally, the remote (k)gdb(1) uses 'target remote <proxy>:<port>' (like any other TCP remote) to connect to the proxy server. The NetGDB v1 protocol speaks the literal GDB remote serial protocol, and uses a 1:1 relationship between GDB packets and sequences of debugnet packets (fragmented by MTU). There is no encryption utilized to keep debugging sessions private, so this is only appropriate for local segments or trusted networks. Submitted by: John Reimer <john.reimer AT emc.com> (earlier version) Discussed some with: emaste, markj Relnotes: sure Differential Revision: https://reviews.freebsd.org/D21568 Notes: svn path=/head/; revision=353700
* Don't enter DDB for fatal traps before panic by default.John Baldwin2018-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | Add a new 'debugger_on_trap' knob separate from 'debugger_on_panic' and make the calls to kdb_trap() in MD fatal trap handlers prior to calling panic() conditional on this new knob instead of 'debugger_on_panic'. Disable the new knob by default. Developers who wish to recover from a fatal fault by adjusting saved register state and retrying the faulting instruction can still do so by enabling the new knob. However, for the more common case this makes the user experience for panics due to a fatal fault match the user experience for other panics, e.g. 'c' in DDB will generate a crash dump and reboot the system rather than being stuck in an infinite loop of fatal fault messages and DDB prompts. Reviewed by: kib, avg MFC after: 2 months Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D17768 Notes: svn path=/head/; revision=340020
* set kdb_why to "trap" when calling kdb_trap from trap_fatalAndriy Gapon2018-04-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow to hook a ddb script to "kdb.enter.trap" event. Previously there was no specific name for this event, so it could only be handled by either "kdb.enter.unknown" or "kdb.enter.default" hooks. Both are very unspecific. Having a specific event is useful because the fatal trap condition is very similar to panic but it has an additional property that the current stack frame is the frame where the trap occurred. So, both a register dump and a stack bottom dump have additional information that can help analyze the problem. I have added the event only on architectures that have trap_fatal() function defined. I haven't looked at other architectures. Their maintainers can add support for the event later. Sample script: kdb.enter.trap=bt; show reg; x/aS $rsp,20; x/agx $rsp,20 Reviewed by: kib, jhb, markj MFC after: 11 days Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D15093 Notes: svn path=/head/; revision=332752
* Make kdb_reenter() silent when explicitly called from db_error().Edward Tomasz Napierala2017-11-281-0/+1
| | | | | | | | | | | | | This removes the useless backtrace on various ddb(4) user errors. Reviewed by: jhb@ Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D13212 Notes: svn path=/head/; revision=326314
* sys/sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326256
* Change kdb_active type to u_char.Mateusz Guzik2017-10-221-1/+1
| | | | | | | | | | Fixes warnings from gcc and keeps the small size. Perhaps nesting should be moved to another variablle. Reported by: ngie Notes: svn path=/head/; revision=324863
* Mark kdb_active as __read_frequently and switch to bool to eat less space.Mateusz Guzik2017-10-201-1/+1
| | | | Notes: svn path=/head/; revision=324789
* Add constant missed in r244099Alfred Perlstein2012-12-101-0/+1
| | | | | | | KDB entered due to KASSERT. Notes: svn path=/head/; revision=244100
* - Extend the KDB interface to add a per-debugger callback to print aJohn Baldwin2012-04-121-5/+9
| | | | | | | | | | | | | | backtrace for an arbitrary thread (rather than the calling thread). A kdb_backtrace_thread() wrapper function uses the configured debugger if possible, otherwise it falls back to using stack(9) if that is available. - Replace a direct call to db_trace_thread() in propagate_priority() with a call to kdb_backtrace_thread() instead. MFC after: 1 week Notes: svn path=/head/; revision=234190
* Attempt to make break-to-debugger and alternative break-to-debugger moreRobert Watson2011-08-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | accessible: (1) Always compile in support for breaking into the debugger if options KDB is present in the kernel. (2) Disable both by default, but allow them to be enabled via tunables and sysctls debug.kdb.break_to_debugger and debug.kdb.alt_break_to_debugger. (3) options BREAK_TO_DEBUGGER and options ALT_BREAK_TO_DEBUGGER continue to behave as before -- only now instead of compiling in break-to-debugger support, they change the default values of the above sysctls to enable those features by default. Current kernel configurations should, therefore, continue to behave as expected. (4) Migrate alternative break-to-debugger state machine logic out of individual device drivers into centralised KDB code. This has a number of upsides, but also one downside: it's now tricky to release sio spin locks when entering the debugger, so we don't. However, similar logic does not exist in other device drivers, including uart. (5) dcons requires some special handling; unlike other console types, it allows overriding KDB's own debugger selection, so we need a new interface to KDB to allow that to work. GENERIC kernels in -CURRENT will now support break-to-debugger as long as appropriate boot/run-time options are set, which should improve the debuggability of BETA kernels significantly. MFC after: 3 weeks Reviewed by: kib, nwhitehorn Approved by: re (bz) Notes: svn path=/head/; revision=225203
* Disconnect sun4v architecture from the three.Attilio Rao2011-05-141-1/+1
| | | | | | | | | | | | Some files keep the SUN4V tags as a code reference, for the future, if any rewamped sun4v support wants to be added again. Reviewed by: marius Tested by: sbruno Approved by: re Notes: svn path=/head/; revision=221869
* DTrace can enter the debugger from a probe. Add a WHY definition for this.John Birrell2008-05-231-0/+1
| | | | Notes: svn path=/head/; revision=179228
* Expand kdb_alt_break a little, most commonly used with the optionPeter Wemm2008-05-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | ALT_BREAK_TO_DEBUGGER. In addition to "Enter ~ ctrl-B" (to enter the debugger), there is now "Enter ~ ctrl-P" (force panic) and "Enter ~ ctrl-R" (request clean reboot, ala ctrl-alt-del on syscons). We've used variations of this at work. The force panic sequence is best used with KDB_UNATTENDED for when you just want it to dump and get on with it. The reboot request is a safer way of getting into single user than a power cycle. eg: you've hosed the ability to log in (pam, rtld, etc). It gives init the reboot signal, which causes an orderly reboot. I've taken my best guess at what the !x86 and non-sio code changes should be. This also makes sio release its spinlock before calling KDB/DDB. Notes: svn path=/head/; revision=178766
* Add a new 'why' argument to kdb_enter(), and a set of constants to useRobert Watson2007-12-251-1/+28
| | | | | | | | | | | | for that argument. This will allow DDB to detect the broad category of reason why the debugger has been entered, which it can use for the purposes of deciding which DDB script to run. Assign approximate why values to all current consumers of the kdb_enter() interface. Notes: svn path=/head/; revision=174898
* Don't enter the debugger if KDB_UNATTENDED is set or ifPaul Saab2005-04-201-0/+1
| | | | | | | | | debug.debugger_on_panic=0. MFC after: 2 weeks Notes: svn path=/head/; revision=145343
* /* -> /*- for license, minor formatting changesWarner Losh2005-01-071-1/+1
| | | | Notes: svn path=/head/; revision=139825
* Add kdb_thr_from_pid(), which given a PID returns the first threadMarcel Moolenaar2004-07-211-1/+2
| | | | | | | in the process. This is useful when working from or with a process. Notes: svn path=/head/; revision=132481
* Make kdb_dbbe_select() available as an interface function. This allowsMarcel Moolenaar2004-07-121-0/+1
| | | | | | | | | changing the backend from outside the KDB frontend. For example from within a backend. Rewrite kdb_sysctl_current to make use of this function as well. Notes: svn path=/head/; revision=132001
* Introduce the KDB debugger frontend. The frontend provides a frameworkMarcel Moolenaar2004-07-101-0/+78
in which multiple (presumably different) debugger backends can be configured and which provides basic services to those backends. Besides providing services to backends, it also serves as the single point of contact for any and all code that wants to make use of the debugger functions, such as entering the debugger or handling of the alternate break sequence. For this purpose, the frontend has been made non-optional. All debugger requests are forwarded or handed over to the current backend, if applicable. Selection of the current backend is done by the debug.kdb.current sysctl. A list of configured backends can be obtained with the debug.kdb.available sysctl. One can enter the debugger by writing to the debug.kdb.enter sysctl. Notes: svn path=/head/; revision=131903