summaryrefslogtreecommitdiffstats
path: root/sys/ddb
Commit message (Collapse)AuthorAgeFilesLines
* Merge bde improvements for ddb on x86, mostly for single-stepping andkib2016-11-075-27/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vm86 mode. MFC r304085 (by bde): Fix the variables $esp, $ds, $es, $fs, $gs and $ss in vm86 mode. Fix PC_REGS() so that printing of instructions works in some useful cases. MFC r304962 (by bde): Expand error messages: print symbol names, parentheses and shift tokens, and negative shift counts. Fix error messages. MFC r305612 (by bde): Fix single-stepping of instructions emulated by vm86. MFC r305661 (by bde): Give the full syntax of the 'count' arg for all commmands that support it. Give the full syntax of the 'addr' arg for these commands and some others. Rename it from 'address' for the generic command. Fix description of how 'count' is supposed to work for the 'break' command. Don't (mis)describe the syntax of the comma for the 'step' command. Expand the description for the generic command. Give the full syntax for the 'examine' command. It was also missing the possible values for the modifier. MFC r305663 (by bde): Fix stopping when the specified breakpoint count is reached. MFC r305665 (by bde): Pass the trap type and code down from db_trap() to db_stop_at_pc() so that the latter can easily determine what the trap type actually is after callers are fixed to encode the type unambigously. MFC r305807 (by bde): Use the MI macro TRAPF_USERMODE() instead of open-coded checks for SEL_UPL and sometimes PSL_VM. Fix logic errors in treating vm86 bioscall mode as kernel mode. The main place checked all the necessary flags, but put the necessary parentheses for the PSL_VM and PCB_VM86CALL checks in the wrong place. MFC r305811 (by bz): Try to fix LINT builds after r305807. MFC r305840 (by bde): Abort single stepping in ddb if the trap is not for single-stepping. MFC r305862 (by bde): Ifdef the new dr6 variable for KDB. MFC r305864 (by bde): Statically initialize the run mode to the one that will become current on first entry. Don't reset to the run mode to STEP_NONE when stopping, and remove STEP_NONE. MFC r305865 (by bde): Fix decoding of tf_rsp on amd64, and move TF_HAS_STACKREGS() to the i386-only section, and fix a comment about the amd64 kernel trapframe not having stackregs. MFC r305897 (by bde): Silently ignore unexpected single-step traps. MFC r306311 (by bde): Determine the operand/address size of %cs in a new function db_segsize(). Use db_segsize() to set the default operand/address size for disassembling. Fix db_print_loc_and_inst() to ask for the normal format and not the alternate in normal operation. Use db_segsize() to avoid trying to print a garbage stack trace if %cs is 16 bits.
* MFC r303426:kib2016-08-271-2/+7
| | | | | Rewrite subr_sleepqueue.c use of callouts to not depend on the specifics of callout KPI.
* Add a small set of logical operators to DDB command language.pfg2016-05-164-27/+216
| | | | | | | | | | | This are based on Mach3. Documentation is pending but has been promised. Submitted by: Dan Partelly Reviewed by: adrian, jhb (older version) Differential Revision: https://reviews.freebsd.org/D4230 RelNotes: yes
* Revert r298938: Change x/a to work similar to gdb.pfg2016-05-061-13/+10
| | | | | This badly breaks x/ia: ddb and gdb syntax are quite different and it is unclear if they can be reconciled.
* Enhance the ddb examine (x) command.pfg2016-05-021-10/+13
| | | | | | | | | | | | | | | | | * Change x/a to work similar to gdb. The content of the memory is treated as an address, printed symbolically and the address is advanced. This way you can x/a <stack_address> and then just hit return a bunch of times to locate useful data on the stack. * Add x/p. The content of the memory is treated as an address and printed as hex. This is based on the similar commit from DragonFlyBSD without the cosmetic changes. Relnotes: yes Obtained from: DragonflyBSD (Matthew Dillon) Reference: 0624d20e86affcd708609cbf9014207537537a72
* sys: Make use of our rounddown() macro when sys/param.h is available.pfg2016-04-301-2/+1
| | | | No functional change.
* sys/ddb: spelling fixes in comments.pfg2016-04-291-1/+1
| | | | No functional change.
* ddb: Make use of our roundup() macro when available.pfg2016-04-261-1/+1
|
* Indentation issues.pfg2016-04-201-2/+1
| | | | | | Contract some lines leftover from r298310. Mea culpa.
* kernel: use our nitems() macro when it is available through param.h.pfg2016-04-191-1/+1
| | | | | | No functional change, only trivial cases are done in this sweep, Discussed in: freebsd-current
* ddb: for pointers replace 0 with NULL.pfg2016-04-152-5/+5
| | | | | | Mostly cosmetical, no functional change. Found with devel/coccinelle.
* Avoid NULL pointer dereference, for a process which is not (yet) akib2016-04-151-1/+2
| | | | | | | member of a process group, e.g. during the system bootstrap. Submitted by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> MFC after: 1 week
* Add td_swinvoltick to track last involuntary context switchcem2016-03-251-0/+12
| | | | | | | Expose in DDB via "show thread." Reviewed by: markj Sponsored by: EMC / Isilon Storage Division
* Add helper to catch single step debug event and distinguish it from bkptzbb2015-11-271-7/+17
| | | | | | | | | | | | | | | Some architectures (including ARMv6/v7) do not have separate single step events and cannot see difference between breakpoint and single step. Add db_pc_is_singlestep() to avoid skipping instruction we stepped on to trigger debug event. This commit does not change the existing functionality but adds possibility to implement custom db_pc_is_singlestep(). Reviewed by: imp Submitted by: Zbigniew Bodek <zbb@semihalf.com> Obtained from: Semihalf Sponsored by: Juniper Networks Inc. Differential Revision: https://reviews.freebsd.org/D4036
* Make kstack_pages a tunable on arm, x86, and powepc. On i386, thekib2015-08-101-1/+1
| | | | | | | | | | | | | | | | | | | initial thread stack is not adjusted by the tunable, the stack is allocated too early to get access to the kernel environment. See TD0_KSTACK_PAGES for the thread0 stack sizing on i386. The tunable was tested on x86 only. From the visual inspection, it seems that it might work on arm and powerpc. The arm USPACE_SVC_STACK_TOP and powerpc USPACE macros seems to be already incorrect for the threads with non-default kstack size. I only changed the macros to use variable instead of constant, since I cannot test. On arm64, mips and sparc64, some static data structures are sized by KSTACK_PAGES, so the tunable is disabled. Sponsored by: The FreeBSD Foundation MFC after: 2 week
* Various changes to the registers displayed in DDB for x86.jhb2015-07-221-1/+2
| | | | | | | | | | | | | | | | - Fix segment registers to only display the low 16 bits. - Remove unused handlers and entries for the debug registers. - Display xcr0 (if valid) in 'show sysregs'. - Add '0x' prefix to MSR values to match other values in 'show sysregs'. - MFamd64: Display various MSRs in 'show sysregs'. - Add a 'show dbregs' to display the value of debug registers. - Dynamically size the column width for register values to properly align columns on 64-bit platforms. - Display %gs for i386 in 'show registers'. Differential Revision: https://reviews.freebsd.org/D2784 Reviewed by: kib, markj MFC after: 2 weeks
* Don't return undefined symbols to a DDB symbol lookup.markj2015-07-212-3/+7
| | | | | | | | | | | | | | | | Undefined symbols have a value of zero, so it makes no sense to return such a symbol when performing a lookup by value. This occurs for example when unwinding the stack after calling a NULL function pointer, and we confusingly report the faulting function as uart_sab82532_class() on amd64. Convert db_print_loc_and_inst() to only attempt disassembly if we managed to find a symbol corresponding to the IP. Otherwise we may fault and re-enter the debugger. Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D2858
* Fix KSTACK_PAGES issue when the default value was changed in KERNCONFzbb2015-07-162-0/+4
| | | | | | | | | | | | | | | | | | If KSTACK_PAGES was changed to anything alse than the default, the value from param.h was taken instead in some places and the value from KENRCONF in some others. This resulted in inconsistency which caused corruption in SMP envorinment. Ensure all places where KSTACK_PAGES are used the opt_kstack_pages.h is included. The file opt_kstack_pages.h could not be included in param.h because was breaking the toolchain compilation. Reviewed by: kib Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3094
* Correct the function name in catch-all error handling case.bz2015-06-171-1/+1
| | | | MFC after: 1 week
* ddb: de-registerpfg2015-05-235-18/+16
|
* ddb: Use NULL for pointerspfg2015-05-221-49/+49
| | | | Hinted by: DragonflyBSD
* ddb: finish converting boolean values.pfg2015-05-2120-117/+104
| | | | | | | | | 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
* ddb: stop boolean screaming.pfg2015-05-1812-101/+101
| | | | | | | TRUE --> true FALSE--> false Hinted by: NetBSD
* ddb: ANSI-fy function declarations.pfg2014-10-1211-227/+89
| | | | MFC after: 5 days
* ddb: space/tab fixes.pfg2014-10-1111-19/+19
| | | | | | No functional change. MFC after: 3 days
* ddb: allow specifying the exact address of the symtab and strtabroyger2014-09-252-14/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the FreeBSD kernel is loaded from Xen the symtab and strtab are not loaded the same way as the native boot loader. This patch adds three new global variables to ddb that can be used to specify the exact position and size of those tables, so they can be directly used as parameters to db_add_symbol_table. A new helper is introduced, so callers that used to set ksym_start and ksym_end can use this helper to set the new variables. It also adds support for loading them from the Xen PVH port, that was previously missing those tables. Sponsored by: Citrix Systems R&D Reviewed by: kib ddb/db_main.c: - Add three new global variables: ksymtab, kstrtab, ksymtab_size that can be used to specify the position and size of the symtab and strtab. - Use those new variables in db_init in order to call db_add_symbol_table. - Move the logic in db_init to db_fetch_symtab in order to set ksymtab, kstrtab, ksymtab_size from ksym_start and ksym_end. ddb/ddb.h: - Add prototype for db_fetch_ksymtab. - Declate the extern variables ksymtab, kstrtab and ksymtab_size. x86/xen/pv.c: - Add support for finding the symtab and strtab when booted as a Xen PVH guest. Since Xen loads the symtab and strtab as NetBSD expects to find them we have to adapt and use the same method. amd64/amd64/machdep.c: arm/arm/machdep.c: i386/i386/machdep.c: mips/mips/machdep.c: pc98/pc98/machdep.c: powerpc/aim/machdep.c: powerpc/booke/machdep.c: sparc64/sparc64/machdep.c: - Use the newly introduced db_fetch_ksymtab in order to set ksymtab, kstrtab and ksymtab_size.
* ins is only set and unused, but only when we're not doing softwareimp2014-08-141-4/+4
| | | | | single stepping. Only set it when we're doing that by bending style(9) rules a little to avoid even worse #ifdef soup.
* handle longer commands so that lines don't overflow... people who addedjmg2014-06-021-2/+2
| | | | commands forgot to check this...
* ddb: Minor style cleanups.pfg2014-03-314-16/+16
| | | | | | #define should be followed by tab. MFC after: 1 week
* Small textdump enhancements.alfred2012-11-012-6/+28
| | | | | | | | | | | | | | 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
* Update the ddb and gdb backends for the new 'trace_thread' hook.jhb2012-04-121-1/+15
| | | | | | | | | It is implemented via db_trace_thread() for DDB and not implemented for GDB. This should have been part of r234190. Pointy hat to: jhb Reported by: jkim MFC after: 1 week
* Use strchr() and strrchr().ed2012-01-021-1/+1
| | | | | | | | It seems strchr() and strrchr() are used more often than index() and rindex(). Therefore, simply migrate all kernel code to use it. For the XFS code, remove an empty line to make the code identical to the code in the Linux kernel.
* Use FOREACH_PROC_IN_SYSTEM instead of using its unrolled form.pluknet2011-12-181-1/+1
| | | | Reviewed by: kib
* Add 'findstack' ddb command to search either the thread kernel stackkib2011-12-163-0/+39
| | | | | | | or cached stack containing the specified kernel virtual address. Discussed with: pho MFC after: 1 week
* Show the thread kernel stack base address for 'show threads'.kib2011-12-161-1/+2
| | | | | Discussed with: pho MFC after: 1 week
* Typo.kib2011-12-091-1/+1
| | | | MFC after: 3 days
* Follow up to r225203 refining break-to-debugger run-time configurationrwatson2011-08-271-2/+0
| | | | | | | | | | | | improvements: (1) Implement new model in previously missed at91 UART driver (2) Move BREAK_TO_DEBUGGER and ALT_BREAK_TO_DEBUGGER from opt_comconsole.h to opt_kdb.h (spotted by np) (3) Garbage collect now-unused opt_comconsole.h MFC after: 3 weeks Approved by: re (bz)
* Fix making kernel dumps from the debugger by creating a commandmarcel2011-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.
* Trim some additional unnecessary <linker_set.h> includes.jhb2011-04-281-1/+0
| | | | MFC after: 1 week
* - Add the possibility to reuse the already last used timeout when pattingattilio2011-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
* Extend the DDB command "watchdog" with the ability to specify a timeoutattilio2011-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
* Modify kdb_trap() so that it re-calls the dbbe_trap function as long asmdf2011-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
* sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.mdf2011-01-121-1/+1
| | | | Commit the kernel changes.
* One more use for _SIG_VALID.kib2010-07-121-1/+1
| | | | | Submitted by: Garrett Cooper <yanegomi gmail com> MFC after: 1 week
* MFp4 @178364:bz2010-05-243-34/+67
| | | | | | | | | | | | | | | | | | 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
* There is not a good reason to have a different prototype for db_printf()attilio2010-05-112-3/+5
| | | | | | | | when compared to printf(). Unify it by returning the number of characters displayed for db_printf() as well. MFC after: 7 days
* Move two copies of the same definition to a common include file.julian2010-04-141-6/+0
| | | | MFC after: 3 weeks
* Add a space before printing 'thread pid ...' to match the space beforerpaulo2010-02-121-1/+1
| | | | ']'.
* Replace several instances of 'if (!a & b)' with 'if (!(a &b))' in ordertrasz2010-01-081-2/+2
| | | | to silence newer GCC versions.
* Among signal generation syscalls, only sigqueue(2) is allowed by POSIXkib2009-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
OpenPOWER on IntegriCloud