summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_kdb.c
Commit message (Collapse)AuthorAgeFilesLines
* * Completely Remove the option STOP_NMI from the kernel. This optionattilio2009-08-131-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | has proven to have a good effect when entering KDB by using a NMI, but it completely violates all the good rules about interrupts disabled while holding a spinlock in other occasions. This can be the cause of deadlocks on events where a normal IPI_STOP is expected. * Adds an new IPI called IPI_STOP_HARD on all the supported architectures. This IPI is responsible for sending a stop message among CPUs using a privileged channel when disponible. In other cases it just does match a normal IPI_STOP. Right now the IPI_STOP_HARD functionality uses a NMI on ia32 and amd64 architectures, while on the other has a normal IPI_STOP effect. It is responsibility of maintainers to eventually implement an hard stop when necessary and possible. * Use the new IPI facility in order to implement a new userend SMP kernel function called stop_cpus_hard(). That is specular to stop_cpu() but it does use the privileged channel for the stopping facility. * Let KDB use the newly introduced function stop_cpus_hard() and leave stop_cpus() for all the other cases * Disable interrupts on CPU0 when starting the process of APs suspension. * Style cleanup and comments adding This patch should fix the reboot/shutdown deadlocks many users are constantly reporting on mailing lists. Please don't forget to update your config file with the STOP_NMI option removal Reviewed by: jhb Tested by: pho, bz, rink Approved by: re (kib)
* Spell NULL properly, use (void) rather than () for functions with noimp2009-05-091-12/+12
| | | | parameters. Mark two items as static that aren't used elsewhere...
* Expand kdb_alt_break a little, most commonly used with the optionpeter2008-05-041-11/+35
| | | | | | | | | | | | | | | | | | | 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.
* Add a new 'why' argument to kdb_enter(), and a set of constants to userwatson2007-12-251-4/+12
| | | | | | | | | 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.
* - Move all of the PS_ flags into either p_flag or td_flags.jeff2007-09-171-3/+3
| | | | | | | | | | | | | | - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith)
* Add a funny sysctl: debug.kdb.trap_code .yar2006-06-181-1/+22
| | | | | | | | | It is similar to debug.kdb.trap, except for it tries to cause a page fault via a call to an invalid pointer. This can highlight differences between a fault on data access vs. a fault on code call some CPUs might have. This appeared as a test for a work \ Sponsored by: RiNet (Cronyx Plus LLC)
* Add a description for sysctl -d.emaste2006-06-171-1/+1
|
* Increment kdb_active after we stopped the other CPUs and decrementmarcel2006-04-041-4/+4
| | | | | | kdb_active before we restart them. This avoids false positives on restarted CPUs when they test for kdb_active while kdb_trap() is still finishing up.
* Eliminate HAVE_STOPPEDPCBS. On ia64 the PCPU holds a pointer to themarcel2006-04-031-10/+5
| | | | | | | | PCB in which the context of stopped CPUs is stored. To access this PCB from KDB, we introduce a new define, called KDB_STOPPEDPCB. The definition, when present, lives in <machine/kdb.h> and abstracts where MD code saves the context. Define KDB_STOPPEDPCB on i386, amd64, alpha and sparc64 in accordance to previous code.
* In kdb_trap(), change the type of the local variable 'intr' from intmarcel2006-04-031-1/+2
| | | | | | | to register_t, as intr_disable() returns the latter and register_t may be wider than int. Pointed out by: marius@
* Replace critical_enter() and critical_exit() in kdb_trap() withmarcel2006-04-031-3/+3
| | | | | | | | | | intr_disable() and intr_restore() resp. Previously, critical regions would have interrupts disabled, but that was changed. Consequently, the debugger could run with interrupts enabled. This could cause problems for the low-level console code where received characters would trigger an interrupt that causes the interrupt handler to read the character instead of the cngetc() function.
* Add stoppcbs[] arrays on Alpha and sparc64 and have each CPU save itsjhb2005-11-031-1/+1
| | | | | | | | current context in the IPI_STOP handler so that we can get accurate stack traces of threads on other CPUs on these two archs like we do now on i386 and amd64. Tested on: alpha, sparc64
* Commit something we found useful at work at one point. Add sysctls forpeter2005-10-261-0/+40
| | | | | | | debug.kdb.panic and debug.kdb.trap alongside the existing debug.kdb.enter sysctl. 'panic' causes a panic, and 'trap' causes a page fault. We used these to ensure that crash dumps succeed from those two common failure modes. This avoids the need for creating a 'panic' kld module.
* Rename the KDB_STOP_NMI kernel option to STOP_NMI and make it apply to alljhb2005-10-241-35/+8
| | | | | | | | | | | | | | | | | | | | | | IPI_STOP IPIs. - Change the i386 and amd64 MD IPI code to send an NMI if STOP_NMI is enabled if an attempt is made to send an IPI_STOP IPI. If the kernel option is enabled, there is also a sysctl to change the behavior at runtime (debug.stop_cpus_with_nmi which defaults to enabled). This includes removing stop_cpus_nmi() and making ipi_nmi_selected() a private function for i386 and amd64. - Fix ipi_all(), ipi_all_but_self(), and ipi_self() on i386 and amd64 to properly handle bitmapped IPIs as well as IPI_STOP IPIs when STOP_NMI is enabled. - Fix ipi_nmi_handler() to execute the restart function on the first CPU that is restarted making use of atomic_readandclear() rather than assuming that the BSP is always included in the set of restarted CPUs. Also, the NMI handler didn't clear the function pointer meaning that subsequent stop and restarts could execute the function again. - Define a new macro HAVE_STOPPEDPCBS on i386 and amd64 to control the use of stoppedpcbs[] and always enable it for i386 and amd64 instead of being dependent on KDB_STOP_NMI. It works fine in both the NMI and non-NMI cases.
* - Various small whitespace and style nits.jhb2005-10-241-11/+10
| | | | | - Use PCPU_GET(cpumask) in preference to 1 << PCPU_GET(cpuid) in a few places.
* If KDB_STOP_NMI is compiled into the kernel, defaultrwatson2005-09-271-1/+1
| | | | | | debug.kdb.stop_cpus_with_nmi to 1 rather than 0. MFC after: 3 days
* Move the KDB_STOP_NMI option from opt_global.h to opt_kdb.hpeter2005-06-291-0/+2
| | | | Approved by: re
* Implement an alternate method to stop CPUs when entering DDB. Normally we usedwhite2005-04-301-0/+50
| | | | | | | | | | | | | | a regular IPI vector, but this vector is blocked when interrupts are disabled. With "options KDB_STOP_NMI" and debug.kdb.stop_cpus_with_nmi set, KDB will send an NMI to each CPU instead. The code also has a context-stuffing feature which helps ddb extract the state of processes running on the stopped CPUs. KDB_STOP_NMI is only useful with SMP and complains if SMP is not defined. This feature only applies to i386 and amd64 at the moment, but could be used on other architectures with the appropriate MD bits. Submitted by: ups
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Zero terminate empty sting in kdb_sysctl_available.ups2004-10-211-0/+2
| | | | | Approved by: sam (mentor) MFC after: 1 week
* Fix a bug introduced in the previous commit: kdb_cpu_trap() gets tomarcel2004-09-261-1/+2
| | | | | | | | the trapframe via kdb_frame, but kdb_frame was not initialized until after the call to kdb_cpu_trap(). Ergo: kdb_cpu_trap() was moved too far up. Pointy hat: marcel
* Move makectx() after kdb_cpu_trap(), so the PCB will have possible MDmarcel2004-09-171-4/+4
| | | | corrections made to the trapframe. This is more logical.
* Make debug.kdb.stop_cpus also a TUNABLE() so it can be set prior to bootrwatson2004-08-221-0/+1
| | | | to help debug early nasty hangs.
* Add a new sysctl, debug.kdb.stop_cpus, which controls whether or not werwatson2004-08-151-2/+19
| | | | | | | | | | | attempt to IPI other cpus when entering the debugger in order to stop them while in the debugger. The default remains to issue the stop; however, that can result in a hang if another cpu has interrupts disabled and is spinning, since the IPI won't be received and the KDB will wait indefinitely. We probably need to add a timeout, but this is a useful stopgap in the mean time. Reviewed by: marcel
* Add kdb_thr_from_pid(), which given a PID returns the first threadmarcel2004-07-211-1/+15
| | | | in the process. This is useful when working from or with a process.
* Make kdb_dbbe_select() available as an interface function. This allowsmarcel2004-07-121-9/+20
| | | | | | 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.
* Fix braino: Make sure there is a current backend before we return itsmarcel2004-07-111-2/+5
| | | | | | | name in the debug.kdb.current sysctl. All other dereferences are properly guarded, but this one was overlooked. Reported by: Morten Rodal (morten at rodal dot no)
* Introduce the KDB debugger frontend. The frontend provides a frameworkmarcel2004-07-101-0/+384
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.
OpenPOWER on IntegriCloud