aboutsummaryrefslogtreecommitdiff
path: root/sys/ddb
Commit message (Collapse)AuthorAgeFilesLines
...
* ddb: add ability to print user registersmhorne2021-01-081-1/+23
| | | | | | | | | | | | | | | | | | | | The debugger is always entered after some kind of kernel trap, often a breakpoint in kdb_enter(). This means that the most recent trapframe will include kernel state at the time of the trap, when often it is desirable to the developer to view the contents of the previous trapframe. This trapframe often corresponds to the entry from userspace. The ddb(4) man page claims the ability to display user register state via the 'u' modifier to `show registers`, but this appears untrue. It is not obvious from a quick search of the history when this feature was added, or when it was removed. (Re)implement this feature in db_show_regs, noting that it is not necessarily populated with userspace state. Reviewed by: jhb (earlier version), markj, bcr (manpages) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27705
* ddb: Display process flags (p_flag and p_flag2) in 'show proc'.John Baldwin2021-01-011-0/+2
| | | | | | Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27872
* Use kdb_thr_* to iterate over threads consistently in DDB.John Baldwin2021-01-012-26/+22
| | | | | | | | | | The "findstack", "show all trace", and "show active trace" commands were iterating over allproc to enumerate threads. This missed threads executing in exit1() after being removed from allproc. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27829
* Use kdb_thr_from_pid() in db_lookup_thread().John Baldwin2021-01-011-5/+3
| | | | | | | | The code is identical, so this should be a no-op. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27828
* Don't check P_INMEM in kdb_thr_*().John Baldwin2021-01-012-3/+9
| | | | | | | | | | Not all debugger operations that enumerate threads require thread stacks to be resident in memory to be useful. Instead, push P_INMEM checks (if needed) into callers. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27827
* ddb ps: Use the pidhash to enumerate processes not in allproc.John Baldwin2021-01-011-8/+6
| | | | | | | | | | | | | | | Exiting processes that have been removed from allproc but are still executing are not yet marked PRS_ZOMBIE, so they were not listed (for example, if a thread panics during exit1()). To detect these processes, clear p_list.le_prev to NULL explicitly after removing a process from the allproc list and check for this sentinel rather than PRS_ZOMBIE when walking the pidhash. While here, simplify the pidhash walk to use a single outer loop. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27824
* Add a kstack_contains() helper function.John Baldwin2020-12-011-2/+1
| | | | | | | | | | | | | This is useful for stack unwinders which need to avoid out-of-bounds reads of a kernel stack which can trigger kernel faults. Reviewed by: kib, markj Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27356 Notes: svn path=/head/; revision=368240
* db_search_symbol: prevent pollution from bogus symbolsEric van Gyzen2020-10-261-1/+14
| | | | | | | | | | | | | | | | | The kernel will never map the first page, so any symbols in that range cannot refer to addresses. Some third-party assembly files define internal constants which appear in their symbol table. Avoiding the lookup for those symbols avoids replacing small offsets with those symbols during disassembly. Reported by: Anton Rang <rang%acm.org> Reviewed by: Anton Rang <rang%acm.org>, markj MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D26895 Notes: svn path=/head/; revision=367059
* ddb: clean up empty lines in .c and .h filesMateusz Guzik2020-09-016-10/+1
| | | | Notes: svn path=/head/; revision=365227
* [PowerPC] More relocation fixesBrandon Bergren2020-06-212-15/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out relocating the symbol table itself can cause issues, like fbt crashing because it applies the offsets to the kernel twice. This had been previously brought up in rS333447 when the stoffs hack was added, but I had been unaware of this and reimplemented symtab relocation. Instead of relocating the symbol table, keep track of the relocation base in ddb, so the ddb symbols behave like the kernel linker-provided symbols. This is intended to be NFC on platforms other than PowerPC, which do not use fully relocatable kernels. (The relbase will always be 0) * Remove the rest of the stoffs hack. * Remove my half-baked displace_symbol_table() function. * Extend ddb initialization to cope with having a relocation offset on the kernel symbol table. * Fix my kernel-as-initrd hack to work with booke64 by using a temporary mapping to access the data. * Fix another instance of __powerpc__ that is actually RELOCATABLE_KERNEL. * Change the behavior or X_db_symbol_values to apply the relocation base when updating valp, to match link_elf_symbol_values() behavior. Reviewed by: jhibbits Sponsored by: Tag1 Consulting, Inc. Differential Revision: https://reviews.freebsd.org/D25223 Notes: svn path=/head/; revision=362458
* kernel: provide panicky version of __unreachableKyle Evans2020-05-131-2/+3
| | | | | | | | | | | | | | | | | | | | | __builtin_unreachable doesn't raise any compile-time warnings/errors on its own, so problems with its usage can't be easily detected. While it would be nice for this situation to change and compilers to at least add a warning for trivial cases where local state means the instruction can't be reached, this isn't the case at the moment and likely will not happen. This commit adds an __assert_unreachable, whose intent is incredibly clear: it asserts that this instruction is unreachable. On INVARIANTS builds, it's a panic(), and on non-INVARIANTS it expands to __unreachable(). Existing users of __unreachable() are converted to __assert_unreachable, to improve debuggability if this assumption is violated. Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D23793 Notes: svn path=/head/; revision=361011
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-264-14/+24
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Add KERNEL_PANICKED macro for use in place of direct panicstr testsMateusz Guzik2020-01-121-1/+1
| | | | Notes: svn path=/head/; revision=356655
* sleep(9), sleepqueue(9): const'ify wchan pointersConrad Meyer2019-12-241-1/+1
| | | | | | | | | | | | | | | | | | _sleep(9), wakeup(9), sleepqueue(9), et al do not dereference or modify the channel pointers provided in any way; they are merely used as intptrs into a dictionary structure to match waiters with wakers. Correctly annotate this such that _sleep() and wakeup() may be used on const pointers without invoking ugly patterns like __DECONST(). Plumb const through all of the underlying sleepqueue bits. No functional change. Reviewed by: rlibby Discussed with: kib, markj Differential Revision: https://reviews.freebsd.org/D22914 Notes: svn path=/head/; revision=356057
* ddb(4): Add some support for lexing IPv6 addressesConrad Meyer2019-09-092-4/+25
| | | | | | | | | | | | | | | | | | | | | Allow commands to specify that (hex) numbers may start with A-F, by adding the DRT_HEX flag for db_read_token_flags(). As before, numbers containing invalid digits for the current radix are rejected. Also, lex ':' and '::' tokens as tCOLON and tCOLONCOLON respectively. There is a mild conflict here with lexed "identifiers" (tIDENT): ddb identifiers may contain arbitrary colons, and the ddb lexer is greedy. So the identifier lex will swallow any colons it finds inside identifiers, and consumers are still unable to expect the token sequence 'tIDENT tCOLON'. That limitation does not matter for IPv6 addresses, because the lexer always attempts to lex numbers before identifiers. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D21509 Notes: svn path=/head/; revision=352075
* ddb(4): Enhance lexer functionality for specialized commandsConrad Meyer2019-09-092-10/+75
| | | | | | | | | | | | | | | | | Add a db_read_token_flags() variant of db_read_token() with configurable parameters. Allow specifying an explicit radix for tNUMBER lexing. It overrides the default inference and db_radix setting. Also provide the option of yielding any lexed whitespace (tWSPACE) (instead of ignoring it). This is useful for whitespace-sensitive CS_OWN commands. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D21459 Notes: svn path=/head/; revision=352074
* ddb(4): Move an extern variable declaration to a headerConrad Meyer2019-09-092-3/+3
| | | | | | | Trivial cleanup, no functional change. Notes: svn path=/head/; revision=352053
* proc: eliminate the zombproc listMateusz Guzik2019-08-282-131/+135
| | | | | | | | | | | | It is not needed by anything in the kernel and it slightly drives up contention on both proctree and allproc locks. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21447 Notes: svn path=/head/; revision=351572
* Cache kernel stacks in UMA. This gives us NUMA support, better concurrency,Jeff Roberson2019-08-061-11/+0
| | | | | | | | | | | | and more statistics. Reviewed by: kib, markj Tested by: pho Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20931 Notes: svn path=/head/; revision=350663
* ddb show proc typoRyan Libby2019-06-221-1/+1
| | | | Notes: svn path=/head/; revision=349288
* 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
* db show thread: avoid overflow in tick conversionRyan Libby2019-05-161-7/+7
| | | | | | | | | | | | | The previous calculations for displaying the time since last switch easily overflowed, after less than 36 min for hz=1000. Now overflow takes 2000 times longer (as long as ticks takes to wrap). Reviewed by: cem, markj Sponsored by: Dell EMC Isilon Differential revision: https://reviews.freebsd.org/D20273 Notes: svn path=/head/; revision=347646
* ddb: Print the thread's pcb in 'show thread'Justin Hibbits2019-02-091-0/+1
| | | | | | | | | This can aid with debugging when a thread is running and has no backtrace. State can be estimated based on the pcb, and refined from there, for example, to get a rough idea of the stack pointer. Notes: svn path=/head/; revision=343943
* ddb: Enable 'thread <address>'Conrad Meyer2018-10-202-12/+2
| | | | | | | | | | | | | | | | | | 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
* add an option for ddb ps command to print process argumentsAndriy Gapon2018-08-091-6/+33
| | | | | | | | | | | | | | | | | | | We use ps to collect the information of all processes in textdump. But it doesn't contain process arguments which however sometimes are very useful for debugging. The new 'a' modifier adds that capability. While here, remove 'm' modifier from ddb.4. It was in the manual page from its very first revision, but I could not find any evidence of the code ever supporting it. Submitted by: Terry Hu <thu@panzura.com> Reviewed by: kib MFC after: 1 week Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D16603 Notes: svn path=/head/; revision=337528
* Extend show proc with reaper, sigparent, and vmspace informationBjoern A. Zeeb2018-05-251-0/+11
| | | | | | | | | I have regularly needed the last couple of months. Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=334209
* Fix PPC symbol resolutionJustin Hibbits2018-05-102-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There were 2 issues that were preventing correct symbol resolution on PowerPC/pseries: 1- memory corruption at chrp_attach() - this caused the inital part of the symbol table to become zeroed, which would cause the kernel linker to fail to parse it. (this was probably zeroing out other memory parts as well) 2- DDB symbol resolution wasn't working because symtab contained not relocated addresses but it was given relocated offsets. Although relocating the symbol table fixed this, it broke the linker, that already handled this case. Thus, the fix for this consists in adding a new DDB macro: DB_STOFFS(offs) that converts a (potentially) relocated offset into one that can be compared with symbol table values. PR: 227093 Submitted by: Leandro Lupori <leandro.lupori_gmail.com> Differential Revision: https://reviews.freebsd.org/D15372 Notes: svn path=/head/; revision=333447
* 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
* No need to force md code to define a macro that's the same asWarner Losh2018-04-161-8/+5
| | | | | | | _BYTE_ORDER. Use that instead. Notes: svn path=/head/; revision=332563
* db_script_exec: use a saved script name when reporting commands executedAndriy Gapon2018-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | Before executing a command in a ddb script ddb prints an information line of the form: db:1:my-script> command where 1 is the script's depth level, "my-script" is the scipt's name, and "command" is the current command in the script. db_script_exec() uses its 'scriptname' parameter to produce that string. In the case when db_script_exec() is called from db_run_cmd() the argument points to db_tok_string that is a global variable used for command parsing. So, its value changes with every command executed. This commit changes the code to use the script's name stored in ds_scriptname to print the line. MFC after: 2 weeks Notes: svn path=/head/; revision=330374
* Implement 'domainset', a cpuset based NUMA policy mechanism. This allowsJeff Roberson2018-01-121-0/+1
| | | | | | | | | | | | | | | | | | | userspace to control NUMA policy administratively and programmatically. Implement domainset based iterators in the page layer. Remove the now legacy numa_* syscalls. Cleanup some header polution created by having seq.h in proc.h. Reviewed by: markj, kib Discussed with: alc Tested by: pho Sponsored by: Netflix, Dell/EMC Isilon Differential Revision: https://reviews.freebsd.org/D13403 Notes: svn path=/head/; revision=327895
* Generalize the gzio API.Mark Johnston2018-01-081-3/+3
| | | | | | | | | | | | | | | | | | | We currently use a set of subroutines in kern_gzio.c to perform compression of user and kernel core dumps. In the interest of adding support for other compression algorithms (zstd) in this role without complicating the API consumers, add a simple compressor API which can be used to select an algorithm. Also change the (non-default) GZIO kernel option to not enable compressed user cores by default. It's not clear that such a default would be desirable with support for multiple algorithms implemented, and it's inconsistent in that it isn't applied to kernel dumps. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D13632 Notes: svn path=/head/; revision=327707
* ddb: fix validation of cpu id in 'set db_cpu=x'Andriy Gapon2017-12-051-2/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=326567
* SPDX: oops .. not from CMU.Pedro F. Giffuni2017-11-301-2/+0
| | | | Notes: svn path=/head/; revision=326405
* SPDX: Consider code from Carnegie-Mellon University.Pedro F. Giffuni2017-11-3024-0/+48
| | | | | | | Interesting cases, most likely from CMU Mach sources. Notes: svn path=/head/; revision=326403
* Make the ddb(4) "set" command list variables when called without parameters.Edward Tomasz Napierala2017-11-301-0/+11
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=326393
* 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
* sys/ddb: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-274-0/+8
| | | | | | | | | | | | | | | 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=326267
* sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-202-0/+4
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326023
* 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
* Rename mkdumpheader() and group EKCD functions in kern_shutdown.c.Mark Johnston2017-08-181-4/+3
| | | | | | | | | | | | | | This helps simplify the code in kern_shutdown.c and reduces the number of globally visible functions. No functional change intended. Reviewed by: cem, def Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11603 Notes: svn path=/head/; revision=322645
* Include opt files in the kernel with "" instead of <>.Warner Losh2017-07-101-1/+1
| | | | Notes: svn path=/head/; revision=320860
* Make ^c work in ddb(4).Edward Tomasz Napierala2017-07-061-0/+1
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=320741
* Make ^w work in ddb(4).Edward Tomasz Napierala2017-07-061-0/+13
| | | | | | | | | Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=320740
* 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
* Remove register keyword from sys/ and ANSIfy prototypesEd Maste2017-05-173-11/+10
| | | | | | | | | | | | | | | A long long time ago the register keyword told the compiler to store the corresponding variable in a CPU register, but it is not relevant for any compiler used in the FreeBSD world today. ANSIfy related prototypes while here. Reviewed by: cem, jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D10193 Notes: svn path=/head/; revision=318389
* Fix printing of negative offsets (typically from frame pointers) again.Bruce Evans2017-03-261-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I fixed this in 1997, but the fix was over-engineered and fragile and was broken in 2003 if not before. i386 parameters were copied to 8 other arches verbatim, mostly after they stopped working on i386, and mostly without the large comment saying how the values were chosen on i386. powerpc has a non-verbatim copy which just changes the uncritical parameter and seems to add a sign extension bug to it. Just treat negative offsets as offsets if they are no more negative than -db_offset_max (default -64K), and remove all the broken parameters. -64K is not very negative, but it is enough for frame and stack pointer offsets since kernel stacks are small. The over-engineering was mainly to go more negative than -64K for the negative offset format, without affecting printing for more than a single address. Addresses in the top 64K of a (full 32-bit or 64-bit) address space are now printed less well, but there aren't many interesting ones. For arches that have many interesting ones very near the top (e.g., 68k has interrupt vectors there), there would be no good limit for the negative offset format and -64K is a good as anything. Notes: svn path=/head/; revision=316001
* Fix right shifts on arches with db_expr_t larger than u_int (LP64 archesBruce Evans2017-03-181-1/+1
| | | | | | | | | | | | | | | | | in practice). db_expr_t is a signed type, but right shifts are fudged to evaluate them in an unsigned type, and the unsigned type was broken by hard- coding it as 'unsigned', so casting to it lost the top bits on arches with db_expr_t larger than u_int. The unsigned type with the same size as db_expr_t is not declared; assume that db_addr_t gives it. Fixing this properly is less important than using the correct type for db_expr_t (originally always long for C90, but always intmax_t since C99). Notes: svn path=/head/; revision=315477
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436