aboutsummaryrefslogtreecommitdiff
path: root/sys/ddb/db_command.c
Commit message (Collapse)AuthorAgeFilesLines
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
* ddb: Enable 'thread <address>'Conrad Meyer2018-10-201-1/+1
| | | | | | | | | | | | | | | | | | Currently, the 'thread' command (to switch the debugger to another thread) only accepts decimal-encoded tids. Use the same parsing logic as 'show thread <arg>' to accept hex-encoded thread pointers in addition to decimal-encoded tids. Document the 'thread' command in ddb.4 and expand the 'show thread' documentation to cover the tid usage. Reported by: bwidawsk Reviewed by: bwidawsk (earlier version), kib (earlier version), markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D16962 Notes: svn path=/head/; revision=339486
* Restore db_radix on parse error, otherwise we'll silently change it toWarner Losh2018-04-171-0/+1
| | | | | | | 10 on a botched trace command. Notes: svn path=/head/; revision=332648
* SPDX: Consider code from Carnegie-Mellon University.Pedro F. Giffuni2017-11-301-0/+2
| | | | | | | Interesting cases, most likely from CMU Mach sources. Notes: svn path=/head/; revision=326403
* Make kdb_reenter() silent when explicitly called from db_error().Edward Tomasz Napierala2017-11-281-1/+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
* Point people towards our https web site for documentation, http accesses areGavin Atkinson2017-11-091-1/+1
| | | | | | | | | just redirected anyway. MFC after: 1 week Notes: svn path=/head/; revision=325594
* Improve ddb(4) error reporting a bit.Edward Tomasz Napierala2017-07-061-2/+3
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=320734
* Make ddb(4) a bit more user-friendly by improving "help".Edward Tomasz Napierala2017-07-061-1/+26
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=320733
* Correct the type of db_cmd_loop_done.Justin Hibbits2016-09-091-1/+1
| | | | | | | | | | | On big endian hardware that uses 1 byte bool a type mismatch of bool vs int will cause the least signifcant byte of db_cmd_loop_done to be set, but the MSB to be read, and read as 0. This causes ddb to stay in an infinite loop. MFC after: 1 week Notes: svn path=/head/; revision=305636
* ddb: Add 'show active trace' commandConrad Meyer2016-08-261-4/+42
| | | | | | | | | | | 'show active trace', or 'acttrace' for short, prints backtraces from running threads only. Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D7646 Notes: svn path=/head/; revision=304828
* ddb: for pointers replace 0 with NULL.Pedro F. Giffuni2016-04-151-2/+2
| | | | | | | | | Mostly cosmetical, no functional change. Found with devel/coccinelle. Notes: svn path=/head/; revision=298073
* ddb: de-registerPedro F. Giffuni2015-05-231-1/+1
| | | | Notes: svn path=/head/; revision=283315
* ddb: Use NULL for pointersPedro F. Giffuni2015-05-221-49/+49
| | | | | | | Hinted by: DragonflyBSD Notes: svn path=/head/; revision=283296
* ddb: finish converting boolean values.Pedro F. Giffuni2015-05-211-13/+13
| | | | | | | | | | | | The replacement started at r283088 was necessarily incomplete without replacing boolean_t with bool. This also involved cleaning some type mismatches and ansifying old C function declarations. Pointed out by: bde Discussed with: bde, ian, jhb Notes: svn path=/head/; revision=283248
* ddb: stop boolean screaming.Pedro F. Giffuni2015-05-181-6/+6
| | | | | | | | | | TRUE --> true FALSE--> false Hinted by: NetBSD Notes: svn path=/head/; revision=283088
* ddb: ANSI-fy function declarations.Pedro F. Giffuni2014-10-121-34/+12
| | | | | | | MFC after: 5 days Notes: svn path=/head/; revision=273006
* ddb: space/tab fixes.Pedro F. Giffuni2014-10-111-1/+1
| | | | | | | | | No functional change. MFC after: 3 days Notes: svn path=/head/; revision=272958
* handle longer commands so that lines don't overflow... people who addedJohn-Mark Gurney2014-06-021-2/+2
| | | | | | | commands forgot to check this... Notes: svn path=/head/; revision=266985
* Small textdump enhancements.Alfred Perlstein2012-11-011-0/+5
| | | | | | | | | | | | | | | | | Allow textdumps to be called explicitly from DDB. If "dump" is called in DDB and textdumps are enabled then abort the dump and tell the user to turn off textdumps. Add options TEXTDUMP_PREFERRED to turn textdumps on by default. Add options TEXTDUMP_VERBOSE to be a bit more verbose while textdumping. Reviewed by: rwatson MFC after: 2 weeks Notes: svn path=/head/; revision=242424
* Add 'findstack' ddb command to search either the thread kernel stackKonstantin Belousov2011-12-161-0/+1
| | | | | | | | | | or cached stack containing the specified kernel virtual address. Discussed with: pho MFC after: 1 week Notes: svn path=/head/; revision=228569
* Fix making kernel dumps from the debugger by creating a commandMarcel Moolenaar2011-06-071-0/+24
| | | | | | | | | | | | | for it. Do not not expect a developer to call doadump(). Calling doadump does not necessarily work when it's declared static. Nor does it necessarily do what was intended in the context of text dumps. The dump command always creates a core dump. Move printing of error messages from doadump to the dump command, now that we don't have to worry about being called from DDB. Notes: svn path=/head/; revision=222801
* - Add the possibility to reuse the already last used timeout when pattingAttilio Rao2011-04-271-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | the watchdog, via the watchdog(9) interface. For that, the WD_LASTVAL bitwise operation is used. It is mutually exclusive with any explicit timout passing to the watchdogs. The last timeout can be returned via the wdog_kern_last_timeout() KPI. - Add the possibility to pat the watchdogs installed via the watchdog(9) interface from the kernel. In order to do that the new KPI wdog_kern_pat() is offered and it does accept normalized nanoseconds or WD_LASTVAL. - Avoid to pass WD_ACTIVE down in the watchdog handlers. All the control bit processing should over to the upper layer functions and not passed down to the handlers at all. These changes are intended to be used in order to fix up the watchdog tripping in situation when the userland is busted, but protection is still wanted (examples: shutdown syncing / disk dumping). Sponsored by: Sandvine Incorporated Reviewed by: emaste, des, cognet MFC after: 2 weeks Notes: svn path=/head/; revision=221121
* Extend the DDB command "watchdog" with the ability to specify a timeoutAttilio Rao2011-04-051-8/+25
| | | | | | | | | | | | | | | | | | | value. The timeout is expressed in the form T(N) = (2^N * nanoseconds) and can be easilly extracted from the watchdog interface as a WD_TO_* macro. That new functionality is supposed to fix re-entering the kernel from DDB re-enabling the watchdog again (previously disabled) and also offer the possibility to break for deadlocked DDB commands. Please note that retro-compatibility is retained. Sponsored by: Sandvine Incorporated Approved by: des MFC after: 10 days Notes: svn path=/head/; revision=220362
* Modify kdb_trap() so that it re-calls the dbbe_trap function as long asMatthew D Fleming2011-02-181-3/+9
| | | | | | | | | | | | | | | | | | the debugger back-end has changed. This means that switching from ddb to gdb no longer requires a "step" which can be dangerous on an already-crashed kernel. Also add a capability to get from the gdb back-end back to ddb, by typing ^C in the console window. While here, simplify kdb_sysctl_available() by using sbuf_new_for_sysctl(), and use strlcpy() instead of strncpy() since the strlcpy semantic is desired. MFC after: 1 month Notes: svn path=/head/; revision=218825
* One more use for _SIG_VALID.Konstantin Belousov2010-07-121-1/+1
| | | | | | | | Submitted by: Garrett Cooper <yanegomi gmail com> MFC after: 1 week Notes: svn path=/head/; revision=209934
* MFp4 @178364:Bjoern A. Zeeb2010-05-241-5/+59
| | | | | | | | | | | | | | | | | | | | | Implement an optional delay to the ddb reset/reboot command. This allows textdumps to be run automatically with unattended reboots after a resonable timeout, while still permitting an administrator to break into debugger if attached to the console at the time of the event for further debugging. Cap the maximum delay at 1 week to avoid highly accidental results, and default to 15s in case of problems parsing the timeout value. Move hex2dec helper function from db_thread.c to db_command.c to make it generally available and prefix it with a "db_" to avoid namespace collisions. Reviewed by: rwatson MFC after: 4 weeks Notes: svn path=/head/; revision=208509
* Among signal generation syscalls, only sigqueue(2) is allowed by POSIXKonstantin Belousov2009-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | to fail due to lack of resources to queue siginfo. Add KSI_SIGQ flag that allows sigqueue_add() to fail while trying to allocate memory for new siginfo. When the flag is not set, behaviour is the same as for KSI_TRAP: if memory cannot be allocated, set bit in sq_kill. KSI_TRAP is kept to preserve KBI. Add SI_KERNEL si_code, to be used in siginfo.si_code when signal is generated by kernel. Deliver siginfo when signal is generated by kill(2) family of syscalls (SI_USER with properly filled si_uid and si_pid), or by kernel (SI_KERNEL, mostly job control or SIGIO). Since KSI_SIGQ flag is not set for the ksi, low memory condition cause old behaviour. Keep psignal(9) KBI intact, but modify it to generate SI_KERNEL si_code. Pgsignal(9) and gsignal(9) now take ksi explicitely. Add pksignal(9) that behaves like psignal but takes ksi, and ddb kill command implemented as pksignal(..., ksi = NULL) to not do allocation while in debugger. While there, remove some register specifiers and use ANSI C prototypes. Reviewed by: davidxu MFC after: 1 month Notes: svn path=/head/; revision=199355
* Initialize the DDB command list when initializing DDB so that the basicJohn Baldwin2008-09-251-3/+2
| | | | | | | | | commands are available from 'boot -d'. Suggested by: dfr Notes: svn path=/head/; revision=183360
* Make ddb command registration dynamic so modules can extendSam Leffler2008-09-151-53/+86
| | | | | | | | | | | | | | | | | | | | | | | | | the command set (only so long as the module is present): o add db_command_register and db_command_unregister to add and remove commands, respectively o replace linker sets with SYSINIT's (and SYSUINIT's) that register commands o expose 3 list heads: db_cmd_table, db_show_table, and db_show_all_table for registering top-level commands, show operands, and show all operands, respectively While here also: o sort command lists o add DB_ALIAS, DB_SHOW_ALIAS, and DB_SHOW_ALL_ALIAS to add aliases for existing commands o add "show all trace" as an alias for "show alltrace" o add "show all locks" as an alias for "show alllocks" Submitted by: Guillaume Ballet <gballet@gmail.com> (original version) Reviewed by: jhb MFC after: 1 month Notes: svn path=/head/; revision=183054
* enable dynamic addition of "show all" commandsSam Leffler2008-03-251-2/+4
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=177615
* When killing a user process from DDB, check that the requested signal isRobert Watson2008-03-071-1/+1
| | | | | | | | | | | > 0 rather than >= 0, or we will panic when trying to deliver the signal. MFC after: 3 days PR: 100802 Submitted by: Valerio Daelli <valerio.daelli at gmail.com> Notes: svn path=/head/; revision=176897
* Add textdump(4) facility, which provides an alternative form of kernelRobert Watson2007-12-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dump using mechanically generated/extracted debugging output rather than a simple memory dump. Current sources of debugging output are: - DDB output capture buffer, if there is captured output to save - Kernel message buffer - Kernel configuration, if included in kernel - Kernel version string - Panic message Textdumps are stored in swap/dump partitions as with regular dumps, but are laid out as ustar files in order to allow multiple parts to be stored as a stream of sequentially written blocks. Blocks are written out in reverse order, as the size of a textdump isn't known a priori. As with regular dumps, they will be extracted using savecore(8). One new DDB(4) command is added, "textdump", which accepts "set", "unset", and "status" arguments. By default, normal kernel dumps are generated unless "textdump set" is run in order to schedule a textdump. It can be canceled using "textdump unset" to restore generation of a normal kernel dump. Several sysctls exist to configure aspects of textdumps; debug.ddb.textdump.pending can be set to check whether a textdump is pending, or set/unset in order to control whether the next kernel dump will be a textdump from userspace. While textdumps don't have to be generated as a result of a DDB script run automatically as part of a kernel panic, this is a particular useful way to use them, as instead of generating a complete memory dump, a simple transcript of an automated DDB session can be captured using the DDB output capture and textdump facilities. This can be used to generate quite brief kernel bug reports rich in debugging information but not dependent on kernel symbol tables or precisely synchronized source code. Most textdumps I generate are less than 100k including the full message buffer. Using textdumps with an interactive debugging session is also useful, with capture being enabled/disabled in order to record some but not all of the DDB session. MFC after: 3 months Notes: svn path=/head/; revision=174921
* Add a simple scripting facility to DDB(4), allowing the user toRobert Watson2007-12-261-5/+31
| | | | | | | | | | | | | | | | | | | | | | | | | define a set of named scripts. Each script consists of a list of DDB commands separated by ";"s that will be executed verbatim. No higher level language constructs, such as branching, are provided for: scripts are executed by sequentially injecting commands into the DDB input buffer. Four new commands are present in DDB: "run" to run a specific script, "script" to define or print a script, "scripts" to list currently defined scripts, and "unscript" to delete a script, modeled on shell alias commands. Scripts may also be manipulated using sysctls in the debug.ddb.scripting MIB space, although users will prefer to use the soon-to-be-added ddb(8) tool for usability reasons. Scripts with certain names are automatically executed on various DDB events, such as entering the debugger via a panic, a witness error, watchdog, breakpoint, sysctl, serial break, etc, allowing customized handling. MFC after: 3 months Notes: svn path=/head/; revision=174914
* Add a new DDB(4) facility, output capture. Input and output from DDB may beRobert Watson2007-12-251-0/+1
| | | | | | | | | | | | | | | | captured to a memory buffer for later inspection using sysctl(8), or in the future, to a textdump. A new DDB command, "capture", is added, which accepts arguments "on", "off", "reset", and "status". A new DDB sysctl tree, debug.ddb.capture, is added, which can be used to resize the capture buffer and extract buffer contents. MFC after: 3 months Notes: svn path=/head/; revision=174910
* Use FOREACH_PROC_IN_SYSTEM instead of using its unrolled form.Xin LI2007-01-171-2/+2
| | | | Notes: svn path=/head/; revision=166074
* On trap while inside ddb, the trap handler calls kdb_reenter(), thatKonstantin Belousov2006-11-021-6/+14
| | | | | | | | | | | | | | | longjmp to the default context. As result, "alltrace" command may be prematurely terminated (without error message). This is happens, for instance, when system is low on memory and referenced page in kernel-mode thread stack is swapped out. Protect "alltrace" against termination on trap by setting temporary kdb_jmpbuf context. Submitted by: Peter Holm Notes: svn path=/head/; revision=163909
* The powerpc and sparc64 MD `reboot' commands should never have existedBruce Evans2006-10-101-1/+10
| | | | | | | | | | | | | | | | | | | | since they just duplicated the MI `reset' command. Instead of removing them, make `reboot' an MI alias for `reboot' since this gives a better way of killing the `r' alias for `reset'. Remove the `registers' command that was used to kill the alias. Turn the powerpc and sparc64 MD `halt' command into an MI command. A copy of sparc64/db_interface.c grew in sun4v just after I found the extra reboot commands. It has not been changed, and is now not identical. Duplicated commands come out duplicated in ddb's online help, but cause large problems when used (e.g., on i386's with 2 halt's and an hwatch, typing h doesn' give the expected message about an ambiguous command, but hangs like the halt command or a looping parseri would). Notes: svn path=/head/; revision=163192
* Added some aliases:Bruce Evans2006-10-081-0/+3
| | | | | | | | | | | | | | | | - `b' is now an official alias for `break'. It used to be an unofficial alias, but this was broken by adding the `bt' alias for `trace'. - `t' is now an official alias for `trace'. It used to be an unofficial alias, but this was broken by adding the `thread' command. - `registers' is now an alias for `show registers'. This is a hack to break the unofficial `r' alias for `reset'. `r' really means `registers' in some debuggers, so I sometimes type it accidentally and am annoyed when it resets the system. A short command shouldn't have such a large effect. Now at least `res' must be typed to disambiguate `reset'. Notes: svn path=/head/; revision=163135
* Fixed formatting of printing of command tables. WIth the default maxBruce Evans2006-10-081-2/+2
| | | | | | | | | | | | | | | | | | output width of 79, only 6 columns of width 12 each fit, but 7 columns were printed. The fix is to pass the width of the next output to db_end_line() and not assume there that this width is always 1. Related unfixed bugs: - 1 character is wasted for a space after the last column - suppression of trailing spaces used to limit the misformatting, but seems to have been lost - in db_examine(), the width of the next output is not know and is still assumed to be 1. Notes: svn path=/head/; revision=163134
* Disable the pager for 'panic' and 'call' to be paranoid.John Baldwin2006-07-191-0/+2
| | | | Notes: svn path=/head/; revision=160505
* Simplify the pager support in DDB. Allowing different db commands toJohn Baldwin2006-07-121-5/+3
| | | | | | | | | | | | | | | | | | | install custom pager functions didn't actually happen in practice (they all just used the simple pager and passed in a local quit pointer). So, just hardcode the simple pager as the only pager and make it set a global db_pager_quit flag that db commands can check when the user hits 'q' (or a suitable variant) at the pager prompt. Also, now that it's easy to do so, enable paging by default for all ddb commands. Any command that wishes to honor the quit flag can do so by checking db_pager_quit. Note that the pager can also be effectively disabled by setting $lines to 0. Other fixes: - 'show idt' on i386 and pc98 now actually checks the quit flag and terminates early. - 'show intr' now actually checks the quit flag and terminates early. Notes: svn path=/head/; revision=160312
* Use LIST_FOREACH().John Baldwin2006-04-211-1/+1
| | | | Notes: svn path=/head/; revision=157951
* Clean up the way we handle auxiliary commands for a given ddb commandJohn Baldwin2006-03-071-96/+86
| | | | | | | | | | | | | | | | | | | table. Previously, the ddb code knew of each linker set of auxiliary commands and which explicit command list they were tied to. These changes add a simple command_table struct that contains both the static list of commands and the pointers for any auxiliary linker set of additional commands. This also makes it possible for other arbitrary command tables to be defined in other parts of the kernel w/o having to edit ddb itself. The DB_SET macro has also been trimmed down to just creating an entry in a linker set. A new DB_FUNC macro does what the old DB_SET did which is to not only add an entry to the linker set but also to include a function prototype for the function being added. With these changes, it's now also possible to create aliases for ddb functions using DB_SET() directly if desired. Notes: svn path=/head/; revision=156412
* - Rename 'traceall' to 'alltrace' so that the 'tr' shortcut for 'trace'John Baldwin2005-10-241-1/+2
| | | | | | | | | | | | | | still works. Also, this is consistent with 'show pcpu' vs 'show allpcpu'. (And 'show allstacks' on OS X for that matter.) - Add 'bt' as an alias for 'trace'. We already have a 'where' alias as well, so this makes it easier for gdb-wired hands to work in ddb. Ok'd by: rwatson (1) Requested by: scottl (2) MFC after: 1 day Notes: svn path=/head/; revision=151622
* - Call db_setup_paging() for traceall.Olivier Houchard2005-10-021-0/+5
| | | | | | | | | | | | | | - Make it so one can't call db_setup_paging() if it has already been called before. traceall needs this, or else the db_setup_paging() call from db_trace_thread() will reset the printed line number, and override its argument. This is not perfect for traceall, because even if one presses 'q' while in the middle of printing a backtrace it will finish printing the backtrace before exiting, as db_trace_thread() won't be notified it should stop, but it is hard to do better without reworking the pager interface a lot more. Notes: svn path=/head/; revision=150842
* Add a DDB "traceall" function, which stack traces all known processRobert Watson2005-10-021-0/+18
| | | | | | | | | | | | | threads. This is quite useful if generating a debug log for post-mortem by another developer, in which case the person at the console may not know which threads are of interest. The output of this can be quite long. Discussed with: kris MFC after: 3 days Notes: svn path=/head/; revision=150819
* Remove the need to forward declare statics by moving them around.David E. O'Brien2005-08-101-57/+54
| | | | Notes: svn path=/head/; revision=148919
* Implement functions calls from within DDB on ia64. On ia64 a functionMarcel Moolenaar2005-07-021-16/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | pointer doesn't point to the first instruction of that function, but rather to a descriptor. The descriptor has the address of the first instruction, as well as the value of the global pointer. The symbol table doesn't know anything about descriptors, so if you lookup the name of a function you get the address of the first instruction. The cast from the address, which is the result of the symbol lookup, to a function pointer as is done in db_fncall is therefore invalid. Abstract this detail behind the DB_CALL macro. By default DB_CALL is defined as db_fncall_generic, which yields the old behaviour. On ia64 the macro is defined as db_fncall_ia64, in which a descriptor is constructed to yield a valid function pointer. While here, introduce DB_MAXARGS. DB_MAXARGS replaces the existing (local) MAXARGS. The DB_MAXARGS macro can be defined by platforms to create a convenient maximum. By default this will be the legacy 10. On ia64 we define this macro to be 8, for 8 is the maximum number of arguments that can be passed in registers. This avoids having to implement spilling of arguments on the memory stack. Approved by: re (dwhite) Notes: svn path=/head/; revision=147745
* Start each of the license/copyright comments with /*-Warner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139747
* When printing a stack trace for a thread, also print the pid and tid.Robert Watson2004-11-231-0/+6
| | | | | | | | | When a series of traces is included in a bug report, this will make it easier to tie the trace information back to ps or threads output, each of which will show the pid or the tid, but usually not both. Notes: svn path=/head/; revision=138038