From ada64e4c98eb5f04a9ca223c5ff9e7ac22ce6404 Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Thu, 20 May 2010 21:04:24 -0500 Subject: kgdboc,keyboard: Keyboard driver for kdb with kgdb This patch adds in the kdb PS/2 keyboard driver. This was mostly a direct port from the original kdb where I cleaned up the code against checkpatch.pl and added the glue to stitch it into kgdb. This patch also enables early kdb debug via kgdbwait and the keyboard. All the access to configure kdb using either a serial console or the keyboard is done via kgdboc. If you want to use only the keyboard and want to break in early you would add to your kernel command arguments: kgdboc=kbd kgdbwait If you wanted serial and or the keyboard access you could use: kgdboc=kbd,ttyS0 You can also configure kgdboc as a kernel module or at run time with the sysfs where you can activate and deactivate kgdb. Turn it on: echo kbd,ttyS0 > /sys/module/kgdboc/parameters/kgdboc Turn it off: echo "" > /sys/module/kgdboc/parameters/kgdboc Signed-off-by: Jason Wessel Reviewed-by: Dmitry Torokhov --- Documentation/kernel-parameters.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Documentation') diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index b12bacd252fc..3845e3a84a52 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1121,9 +1121,11 @@ and is between 256 and 4096 characters. It is defined in the file zone if it does not. kgdboc= [HW] kgdb over consoles. - Requires a tty driver that supports console polling. - (only serial supported for now) - Format: [,baud] + Requires a tty driver that supports console polling, + or a supported polling keyboard driver (non-usb). + Serial only format: [,baud] + keyboard only format: kbd + keyboard and serial format: kbd,[,baud] kmac= [MIPS] korina ethernet MAC address. Configure the RouterBoard 532 series on-chip -- cgit v1.2.2 From 84c08fd61e2d21702337e9fe366e97cdf09bf797 Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Thu, 20 May 2010 21:04:24 -0500 Subject: kgdb,docs: Update the kgdb docs to include kdb Update the kgdb docs to reflect the new directory structure and API. Merge in the kdb shell information. [Randy Dunlap : grammatical corrections] CC: Randy Dunlap Signed-off-by: Jason Wessel --- Documentation/DocBook/kgdb.tmpl | 692 +++++++++++++++++++++++++++--------- Documentation/kernel-parameters.txt | 6 +- 2 files changed, 521 insertions(+), 177 deletions(-) (limited to 'Documentation') diff --git a/Documentation/DocBook/kgdb.tmpl b/Documentation/DocBook/kgdb.tmpl index 5cff41a5fa7c..55f12ac37acd 100644 --- a/Documentation/DocBook/kgdb.tmpl +++ b/Documentation/DocBook/kgdb.tmpl @@ -4,7 +4,7 @@ - Using kgdb and the kgdb Internals + Using kgdb, kdb and the kernel debugger internals @@ -17,33 +17,8 @@ - - - - Tom - Rini - -
- trini@kernel.crashing.org -
-
-
-
- - - - Amit S. - Kale - -
- amitkale@linsyssoft.com -
-
-
-
- - 2008 + 2008,2010 Wind River Systems, Inc. @@ -69,41 +44,76 @@ Introduction - kgdb is a source level debugger for linux kernel. It is used along - with gdb to debug a linux kernel. The expectation is that gdb can - be used to "break in" to the kernel to inspect memory, variables - and look through call stack information similar to what an - application developer would use gdb for. It is possible to place - breakpoints in kernel code and perform some limited execution - stepping. + The kernel has two different debugger front ends (kdb and kgdb) + which interface to the debug core. It is possible to use either + of the debugger front ends and dynamically transition between them + if you configure the kernel properly at compile and runtime. + + + Kdb is simplistic shell-style interface which you can use on a + system console with a keyboard or serial console. You can use it + to inspect memory, registers, process lists, dmesg, and even set + breakpoints to stop in a certain location. Kdb is not a source + level debugger, although you can set breakpoints and execute some + basic kernel run control. Kdb is mainly aimed at doing some + analysis to aid in development or diagnosing kernel problems. You + can access some symbols by name in kernel built-ins or in kernel + modules if the code was built + with CONFIG_KALLSYMS. + + + Kgdb is intended to be used as a source level debugger for the + Linux kernel. It is used along with gdb to debug a Linux kernel. + The expectation is that gdb can be used to "break in" to the + kernel to inspect memory, variables and look through call stack + information similar to the way an application developer would use + gdb to debug an application. It is possible to place breakpoints + in kernel code and perform some limited execution stepping. - Two machines are required for using kgdb. One of these machines is a - development machine and the other is a test machine. The kernel - to be debugged runs on the test machine. The development machine - runs an instance of gdb against the vmlinux file which contains - the symbols (not boot image such as bzImage, zImage, uImage...). - In gdb the developer specifies the connection parameters and - connects to kgdb. The type of connection a developer makes with - gdb depends on the availability of kgdb I/O modules compiled as - builtin's or kernel modules in the test machine's kernel. + Two machines are required for using kgdb. One of these machines is + a development machine and the other is the target machine. The + kernel to be debugged runs on the target machine. The development + machine runs an instance of gdb against the vmlinux file which + contains the symbols (not boot image such as bzImage, zImage, + uImage...). In gdb the developer specifies the connection + parameters and connects to kgdb. The type of connection a + developer makes with gdb depends on the availability of kgdb I/O + modules compiled as built-ins or loadable kernel modules in the test + machine's kernel. - Compiling a kernel + Compiling a kernel + + + In order to enable compilation of kdb, you must first enable kgdb. + The kgdb test compile options are described in the kgdb test suite chapter. + + + + Kernel config options for kgdb To enable CONFIG_KGDB you should first turn on "Prompt for development and/or incomplete code/drivers" (CONFIG_EXPERIMENTAL) in "General setup", then under the - "Kernel debugging" select "KGDB: kernel debugging with remote gdb". + "Kernel debugging" select "KGDB: kernel debugger". + + + While it is not a hard requirement that you have symbols in your + vmlinux file, gdb tends not to be very useful without the symbolic + data, so you will want to turn + on CONFIG_DEBUG_INFO which is called "Compile the + kernel with debug info" in the config menu. It is advised, but not required that you turn on the - CONFIG_FRAME_POINTER kernel option. This option inserts code to - into the compiled executable which saves the frame information in - registers or on the stack at different points which will allow a - debugger such as gdb to more accurately construct stack back traces - while debugging the kernel. + CONFIG_FRAME_POINTER kernel option which is called "Compile the + kernel with frame pointers" in the config menu. This option + inserts code to into the compiled executable which saves the frame + information in registers or on the stack at different points which + allows a debugger such as gdb to more accurately construct + stack back traces while debugging the kernel. If the architecture that you are using supports the kernel option @@ -116,38 +126,160 @@ this option. - Next you should choose one of more I/O drivers to interconnect debugging - host and debugged target. Early boot debugging requires a KGDB - I/O driver that supports early debugging and the driver must be - built into the kernel directly. Kgdb I/O driver configuration - takes place via kernel or module parameters, see following - chapter. + Next you should choose one of more I/O drivers to interconnect + debugging host and debugged target. Early boot debugging requires + a KGDB I/O driver that supports early debugging and the driver + must be built into the kernel directly. Kgdb I/O driver + configuration takes place via kernel or module parameters which + you can learn more about in the in the section that describes the + parameter "kgdboc". - - The kgdb test compile options are described in the kgdb test suite chapter. + Here is an example set of .config symbols to enable or + disable for kgdb: + + # CONFIG_DEBUG_RODATA is not set + CONFIG_FRAME_POINTER=y + CONFIG_KGDB=y + CONFIG_KGDB_SERIAL_CONSOLE=y + - + + + Kernel config options for kdb + Kdb is quite a bit more complex than the simple gdbstub + sitting on top of the kernel's debug core. Kdb must implement a + shell, and also adds some helper functions in other parts of the + kernel, responsible for printing out interesting data such as what + you would see if you ran "lsmod", or "ps". In order to build kdb + into the kernel you follow the same steps as you would for kgdb. + + The main config option for kdb + is CONFIG_KGDB_KDB which is called "KGDB_KDB: + include kdb frontend for kgdb" in the config menu. In theory you + would have already also selected an I/O driver such as the + CONFIG_KGDB_SERIAL_CONSOLE interface if you plan on using kdb on a + serial port, when you were configuring kgdb. + + If you want to use a PS/2-style keyboard with kdb, you would + select CONFIG_KDB_KEYBOARD which is called "KGDB_KDB: keyboard as + input device" in the config menu. The CONFIG_KDB_KEYBOARD option + is not used for anything in the gdb interface to kgdb. The + CONFIG_KDB_KEYBOARD option only works with kdb. + + Here is an example set of .config symbols to enable/disable kdb: + + # CONFIG_DEBUG_RODATA is not set + CONFIG_FRAME_POINTER=y + CONFIG_KGDB=y + CONFIG_KGDB_SERIAL_CONSOLE=y + CONFIG_KGDB_KDB=y + CONFIG_KDB_KEYBOARD=y + + + - - Enable kgdb for debugging - - In order to use kgdb you must activate it by passing configuration - information to one of the kgdb I/O drivers. If you do not pass any - configuration information kgdb will not do anything at all. Kgdb - will only actively hook up to the kernel trap hooks if a kgdb I/O - driver is loaded and configured. If you unconfigure a kgdb I/O - driver, kgdb will unregister all the kernel hook points. + + Kernel Debugger Boot Arguments + This section describes the various runtime kernel + parameters that affect the configuration of the kernel debugger. + The following chapter covers using kdb and kgdb as well as + provides some examples of the configuration parameters. + + Kernel parameter: kgdboc + The kgdboc driver was originally an abbreviation meant to + stand for "kgdb over console". Today it is the primary mechanism + to configure how to communicate from gdb to kgdb as well as the + devices you want to use to interact with the kdb shell. + + For kgdb/gdb, kgdboc is designed to work with a single serial + port. It is intended to cover the circumstance where you want to + use a serial console as your primary console as well as using it to + perform kernel debugging. It is also possible to use kgdb on a + serial port which is not designated as a system console. Kgdboc + may be configured as a kernel built-in or a kernel loadable module. + You can only make use of kgdbwait and early + debugging if you build kgdboc into the kernel as a built-in. + + kgdboc arguments + Usage: kgdboc=[kbd][[,]serial_device][,baud] + + Using loadable module or built-in - All drivers can be reconfigured at run time, if - CONFIG_SYSFS and CONFIG_MODULES - are enabled, by echo'ing a new config string to - /sys/module/<driver>/parameter/<option>. - The driver can be unconfigured by passing an empty string. You cannot - change the configuration while the debugger is attached. Make sure - to detach the debugger with the detach command - prior to trying unconfigure a kgdb I/O driver. + + As a kernel built-in: + Use the kernel boot argument: kgdboc=<tty-device>,[baud] + + As a kernel loadable module: + Use the command: modprobe kgdboc kgdboc=<tty-device>,[baud] + Here are two examples of how you might formate the kgdboc + string. The first is for an x86 target using the first serial port. + The second example is for the ARM Versatile AB using the second + serial port. + + kgdboc=ttyS0,115200 + kgdboc=ttyAMA1,115200 + + + + + + Configure kgdboc at runtime with sysfs + At run time you can enable or disable kgdboc by echoing a + parameters into the sysfs. Here are two examples: + + Enable kgdboc on ttyS0 + echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc + Disable kgdboc + echo "" > /sys/module/kgdboc/parameters/kgdboc + + NOTE: You do not need to specify the baud if you are + configuring the console on tty which is already configured or + open. + + + More examples + You can configure kgdboc to use the keyboard, and or a serial device + depending on if you are using kdb and or kgdb, in one of the + following scenarios. + + kdb and kgdb over only a serial port + kgdboc=<serial_device>[,baud] + Example: kgdboc=ttyS0,115200 + + kdb and kgdb with keyboard and a serial port + kgdboc=kbd,<serial_device>[,baud] + Example: kgdboc=kbd,ttyS0,115200 + + kdb with a keyboard + kgdboc=kbd + + + + + NOTE: Kgdboc does not support interrupting the target via the + gdb remote protocol. You must manually send a sysrq-g unless you + have a proxy that splits console output to a terminal program. + A console proxy has a separate TCP port for the debugger and a separate + TCP port for the "human" console. The proxy can take care of sending + the sysrq-g for you. + + When using kgdboc with no debugger proxy, you can end up + connecting the debugger at one of two entry points. If an + exception occurs after you have loaded kgdboc, a message should + print on the console stating it is waiting for the debugger. In + this case you disconnect your terminal program and then connect the + debugger in its place. If you want to interrupt the target system + and forcibly enter a debug session you have to issue a Sysrq + sequence and then type the letter g. Then + you disconnect the terminal session and connect gdb. Your options + if you don't like this are to hack gdb to send the sysrq-g for you + as well as on the initial connect, or to use a debugger proxy that + allows an unmodified gdb to do the debugging. + + + Kernel parameter: kgdbwait @@ -162,103 +294,204 @@ The kernel will stop and wait as early as the I/O driver and - architecture will allow when you use this option. If you build the - kgdb I/O driver as a kernel module kgdbwait will not do anything. + architecture allows when you use this option. If you build the + kgdb I/O driver as a loadable kernel module kgdbwait will not do + anything. - - Kernel parameter: kgdboc - - The kgdboc driver was originally an abbreviation meant to stand for - "kgdb over console". Kgdboc is designed to work with a single - serial port. It was meant to cover the circumstance - where you wanted to use a serial console as your primary console as - well as using it to perform kernel debugging. Of course you can - also use kgdboc without assigning a console to the same port. + + Kernel parameter: kgdbcon + The kgdbcon feature allows you to see printk() messages + inside gdb while gdb is connected to the kernel. Kdb does not make + use of the kgdbcon feature. + + Kgdb supports using the gdb serial protocol to send console + messages to the debugger when the debugger is connected and running. + There are two ways to activate this feature. + + Activate with the kernel command line option: + kgdbcon + + Use sysfs before configuring an I/O driver + + echo 1 > /sys/module/kgdb/parameters/kgdb_use_con + + + NOTE: If you do this after you configure the kgdb I/O driver, the + setting will not take effect until the next point the I/O is + reconfigured. + + + + IMPORTANT NOTE: You cannot use kgdboc + kgdbcon on a tty that is an + active system console. An example incorrect usage is console=ttyS0,115200 kgdboc=ttyS0 kgdbcon + + It is possible to use this option with kgdboc on a tty that is not a system console. + - - Using kgdboc - - You can configure kgdboc via sysfs or a module or kernel boot line - parameter depending on if you build with CONFIG_KGDBOC as a module - or built-in. - - From the module load or build-in - kgdboc=<tty-device>,[baud] + + + + Using kdb - The example here would be if your console port was typically ttyS0, you would use something like kgdboc=ttyS0,115200 or on the ARM Versatile AB you would likely use kgdboc=ttyAMA0,115200 + + + Quick start for kdb on a serial port + This is a quick example of how to use kdb. + + Boot kernel with arguments: + + console=ttyS0,115200 kgdboc=ttyS0,115200 + + OR + Configure kgdboc after the kernel booted; assuming you are using a serial port console: + + echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc + - From sysfs - echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc + Enter the kernel debugger manually or by waiting for an oops or fault. There are several ways you can enter the kernel debugger manually; all involve using the sysrq-g, which means you must have enabled CONFIG_MAGIC_SYSRQ=y in your kernel config. + + When logged in as root or with a super user session you can run: + echo g > /proc/sysrq-trigger + Example using minicom 2.2 + Press: Control-a + Press: f + Press: g - - - - NOTE: Kgdboc does not support interrupting the target via the - gdb remote protocol. You must manually send a sysrq-g unless you - have a proxy that splits console output to a terminal problem and - has a separate port for the debugger to connect to that sends the - sysrq-g for you. + When you have telneted to a terminal server that supports sending a remote break + Press: Control-] + Type in:send break + Press: Enter + Press: g + + + + From the kdb prompt you can run the "help" command to see a complete list of the commands that are available. + Some useful commands in kdb include: + + lsmod -- Shows where kernel modules are loaded + ps -- Displays only the active processes + ps A -- Shows all the processes + summary -- Shows kernel version info and memory usage + bt -- Get a backtrace of the current process using dump_stack() + dmesg -- View the kernel syslog buffer + go -- Continue the system + - When using kgdboc with no debugger proxy, you can end up - connecting the debugger for one of two entry points. If an - exception occurs after you have loaded kgdboc a message should print - on the console stating it is waiting for the debugger. In case you - disconnect your terminal program and then connect the debugger in - its place. If you want to interrupt the target system and forcibly - enter a debug session you have to issue a Sysrq sequence and then - type the letter g. Then you disconnect the - terminal session and connect gdb. Your options if you don't like - this are to hack gdb to send the sysrq-g for you as well as on the - initial connect, or to use a debugger proxy that allows an - unmodified gdb to do the debugging. + + + When you are done using kdb you need to consider rebooting the + system or using the "go" command to resuming normal kernel + execution. If you have paused the kernel for a lengthy period of + time, applications that rely on timely networking or anything to do + with real wall clock time could be adversely affected, so you + should take this into consideration when using the kernel + debugger. + + + + + Quick start for kdb using a keyboard connected console + This is a quick example of how to use kdb with a keyboard. + + Boot kernel with arguments: + + kgdboc=kbd + + OR + Configure kgdboc after the kernel booted: + + echo kbd > /sys/module/kgdboc/parameters/kgdboc + - + + Enter the kernel debugger manually or by waiting for an oops or fault. There are several ways you can enter the kernel debugger manually; all involve using the sysrq-g, which means you must have enabled CONFIG_MAGIC_SYSRQ=y in your kernel config. + + When logged in as root or with a super user session you can run: + echo g > /proc/sysrq-trigger + Example using a laptop keyboard + Press and hold down: Alt + Press and hold down: Fn + Press and release the key with the label: SysRq + Release: Fn + Press and release: g + Release: Alt + + Example using a PS/2 101-key keyboard + Press and hold down: Alt + Press and release the key with the label: SysRq + Press and release: g + Release: Alt + + + + + Now type in a kdb command such as "help", "dmesg", "bt" or "go" to continue kernel execution. + + - - Kernel parameter: kgdbcon - - Kgdb supports using the gdb serial protocol to send console messages - to the debugger when the debugger is connected and running. There - are two ways to activate this feature. + + + Using kgdb / gdb + In order to use kgdb you must activate it by passing + configuration information to one of the kgdb I/O drivers. If you + do not pass any configuration information kgdb will not do anything + at all. Kgdb will only actively hook up to the kernel trap hooks + if a kgdb I/O driver is loaded and configured. If you unconfigure + a kgdb I/O driver, kgdb will unregister all the kernel hook points. + + All kgdb I/O drivers can be reconfigured at run time, if + CONFIG_SYSFS and CONFIG_MODULES + are enabled, by echo'ing a new config string to + /sys/module/<driver>/parameter/<option>. + The driver can be unconfigured by passing an empty string. You cannot + change the configuration while the debugger is attached. Make sure + to detach the debugger with the detach command + prior to trying to unconfigure a kgdb I/O driver. + + + Connecting with gdb to a serial port - Activate with the kernel command line option: - kgdbcon + Configure kgdboc + Boot kernel with arguments: + + kgdboc=ttyS0,115200 + + OR + Configure kgdboc after the kernel booted: + + echo ttyS0 > /sys/module/kgdboc/parameters/kgdboc + - Use sysfs before configuring an io driver - - echo 1 > /sys/module/kgdb/parameters/kgdb_use_con - - - NOTE: If you do this after you configure the kgdb I/O driver, the - setting will not take effect until the next point the I/O is - reconfigured. - + + Stop kernel execution (break into the debugger) + In order to connect to gdb via kgdboc, the kernel must + first be stopped. There are several ways to stop the kernel which + include using kgdbwait as a boot argument, via a sysrq-g, or running + the kernel until it takes an exception where it waits for the + debugger to attach. + + When logged in as root or with a super user session you can run: + echo g > /proc/sysrq-trigger + Example using minicom 2.2 + Press: Control-a + Press: f + Press: g - - - - IMPORTANT NOTE: Using this option with kgdb over the console - (kgdboc) is not supported. + When you have telneted to a terminal server that supports sending a remote break + Press: Control-] + Type in:send break + Press: Enter + Press: g + + - - - - Connecting gdb - - If you are using kgdboc, you need to have used kgdbwait as a boot - argument, issued a sysrq-g, or the system you are going to debug - has already taken an exception and is waiting for the debugger to - attach before you can connect gdb. - - - If you are not using different kgdb I/O driver other than kgdboc, - you should be able to connect and the target will automatically - respond. - + + + Connect from from gdb - Example (using a serial port): + Example (using a directly connected port): % gdb ./vmlinux @@ -266,7 +499,7 @@ (gdb) target remote /dev/ttyS0 - Example (kgdb to a terminal server on tcp port 2012): + Example (kgdb to a terminal server on TCP port 2012): % gdb ./vmlinux @@ -283,6 +516,83 @@ communications. You do this prior to issuing the target remote command by typing in: set debug remote 1 + + + Remember if you continue in gdb, and need to "break in" again, + you need to issue an other sysrq-g. It is easy to create a simple + entry point by putting a breakpoint at sys_sync + and then you can run "sync" from a shell or script to break into the + debugger. + + + + kgdb and kdb interoperability + It is possible to transition between kdb and kgdb dynamically. + The debug core will remember which you used the last time and + automatically start in the same mode. + + Switching between kdb and kgdb + + Switching from kgdb to kdb + + There are two ways to switch from kgdb to kdb: you can use gdb to + issue a maintenance packet, or you can blindly type the command $3#33. + Whenever kernel debugger stops in kgdb mode it will print the + message KGDB or $3#33 for KDB. It is important + to note that you have to type the sequence correctly in one pass. + You cannot type a backspace or delete because kgdb will interpret + that as part of the debug stream. + + Change from kgdb to kdb by blindly typing: + $3#33 + Change from kgdb to kdb with gdb + maintenance packet 3 + NOTE: Now you must kill gdb. Typically you press control-z and + issue the command: kill -9 % + + + + + Change from kdb to kgdb + There are two ways you can change from kdb to kgdb. You can + manually enter kgdb mode by issuing the kgdb command from the kdb + shell prompt, or you can connect gdb while the kdb shell prompt is + active. The kdb shell looks for the typical first commands that gdb + would issue with the gdb remote protocol and if it sees one of those + commands it automatically changes into kgdb mode. + + From kdb issue the command: + kgdb + Now disconnect your terminal program and connect gdb in its place + At the kdb prompt, disconnect the terminal program and connect gdb in its place. + + + + + Running kdb commands from gdb + It is possible to run a limited set of kdb commands from gdb, + using the gdb monitor command. You don't want to execute any of the + run control or breakpoint operations, because it can disrupt the + state of the kernel debugger. You should be using gdb for + breakpoints and run control operations if you have gdb connected. + The more useful commands to run are things like lsmod, dmesg, ps or + possibly some of the memory information commands. To see all the kdb + commands you can run monitor help. + Example: + +(gdb) monitor ps +1 idle process (state I) and +27 sleeping system daemon (state M) processes suppressed, +use 'ps A' to see all. +Task Addr Pid Parent [*] cpu State Thread Command + +0xc78291d0 1 0 0 0 S 0xc7829404 init +0xc7954150 942 1 0 0 S 0xc7954384 dropbear +0xc78789c0 944 1 0 0 S 0xc7878bf4 sh +(gdb) + + + kgdb Test Suite @@ -309,34 +619,36 @@ - KGDB Internals + Kernel Debugger Internals Architecture Specifics - Kgdb is organized into three basic components: + The kernel debugger is organized into a number of components: - kgdb core + The debug core - The kgdb core is found in kernel/kgdb.c. It contains: + The debug core is found in kernel/debugger/debug_core.c. It contains: - All the logic to implement the gdb serial protocol - A generic OS exception handler which includes sync'ing the processors into a stopped state on an multi cpu system. + A generic OS exception handler which includes + sync'ing the processors into a stopped state on an multi-CPU + system. The API to talk to the kgdb I/O drivers - The API to make calls to the arch specific kgdb implementation + The API to make calls to the arch-specific kgdb implementation The logic to perform safe memory reads and writes to memory while using the debugger A full implementation for software breakpoints unless overridden by the arch + The API to invoke either the kdb or kgdb frontend to the debug core. - kgdb arch specific implementation + kgdb arch-specific implementation This implementation is generally found in arch/*/kernel/kgdb.c. As an example, arch/x86/kernel/kgdb.c contains the specifics to implement HW breakpoint as well as the initialization to dynamically register and unregister for the trap handlers on - this architecture. The arch specific portion implements: + this architecture. The arch-specific portion implements: - contains an arch specific trap catcher which + contains an arch-specific trap catcher which invokes kgdb_handle_exception() to start kgdb about doing its work translation to and from gdb specific packet format to pt_regs @@ -347,11 +659,35 @@ + gdbstub frontend (aka kgdb) + The gdbstub is located in kernel/debug/gdbstub.c. It contains: + + All the logic to implement the gdb serial protocol + + + kdb frontend + The kdb debugger shell is broken down into a number of + components. The kdb core is located in kernel/debug/kdb. There + are a number of helper functions in some of the other kernel + components to make it possible for kdb to examine and report + information about the kernel without taking locks that could + cause a kernel deadlock. The kdb core contains implements the following functionality. + + A simple shell + The kdb core command set + A registration API to register additional kdb shell commands. + A good example of a self-contained kdb module is the "ftdump" command for dumping the ftrace buffer. See: kernel/trace/trace_kdb.c + The implementation for kdb_printf() which + emits messages directly to I/O drivers, bypassing the kernel + log. + SW / HW breakpoint management for the kdb shell + + kgdb I/O driver - Each kgdb I/O driver has to provide an implemenation for the following: + Each kgdb I/O driver has to provide an implementation for the following: - configuration via builtin or module + configuration via built-in or module dynamic configuration and kgdb hook registration calls read and write character interface A cleanup handler for unconfiguring from the kgdb core @@ -416,15 +752,15 @@ underlying low level to the hardware driver having "polling hooks" which the to which the tty driver is attached. In the initial implementation of kgdboc it the serial_core was changed to expose a - low level uart hook for doing polled mode reading and writing of a + low level UART hook for doing polled mode reading and writing of a single character while in an atomic context. When kgdb makes an I/O request to the debugger, kgdboc invokes a call back in the serial - core which in turn uses the call back in the uart driver. It is - certainly possible to extend kgdboc to work with non-uart based + core which in turn uses the call back in the UART driver. It is + certainly possible to extend kgdboc to work with non-UART based consoles in the future. - When using kgdboc with a uart, the uart driver must implement two callbacks in the struct uart_ops. Example from drivers/8250.c: + When using kgdboc with a UART, the UART driver must implement two callbacks in the struct uart_ops. Example from drivers/8250.c: #ifdef CONFIG_CONSOLE_POLL .poll_get_char = serial8250_get_poll_char, .poll_put_char = serial8250_put_poll_char, @@ -434,7 +770,7 @@ #ifdef CONFIG_CONSOLE_POLL, as shown above. Keep in mind that polling hooks have to be implemented in such a way that they can be called from an atomic context and have to restore - the state of the uart chip on return such that the system can return + the state of the UART chip on return such that the system can return to normal when the debugger detaches. You need to be very careful with any kind of lock you consider, because failing here is most going to mean pressing the reset button. @@ -453,6 +789,10 @@ Jason Wesseljason.wessel@windriver.com + In Jan 2010 this document was updated to include kdb. + + Jason Wesseljason.wessel@windriver.com +
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 3845e3a84a52..bdce359820bb 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -58,6 +58,7 @@ parameter is applicable: ISAPNP ISA PnP code is enabled. ISDN Appropriate ISDN support is enabled. JOY Appropriate joystick support is enabled. + KGDB Kernel debugger support is enabled. KVM Kernel Virtual Machine support is enabled. LIBATA Libata driver is enabled LP Printer support is enabled. @@ -1120,13 +1121,16 @@ and is between 256 and 4096 characters. It is defined in the file use the HighMem zone if it exists, and the Normal zone if it does not. - kgdboc= [HW] kgdb over consoles. + kgdboc= [KGDB,HW] kgdb over consoles. Requires a tty driver that supports console polling, or a supported polling keyboard driver (non-usb). Serial only format: [,baud] keyboard only format: kbd keyboard and serial format: kbd,[,baud] + kgdbwait [KGDB] Stop kernel execution and enter the + kernel debugger at the earliest opportunity. + kmac= [MIPS] korina ethernet MAC address. Configure the RouterBoard 532 series on-chip Ethernet adapter MAC address. -- cgit v1.2.2