Skip to content

RFC ONLY - kdb for kgdb

Jason Wessel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13RFC ONLY - kdb: core for kgdb back endMakefile arch/arm/include/asm/kmap_types.h arch/mips/include/asm/kmap_types.h +23 more+8045 -82 replies
2/13RFC ONLY - kgdb: core changes to support kdbarch/arm/kernel/kgdb.c arch/mips/kernel/kgdb.c arch/powerpc/kernel/kgdb.c +4 more+233 -60 replies
3/13RFC ONLY - kgdb,8250,pl011: Return immediately from console polldrivers/serial/8250.c drivers/serial/amba-pl011.c include/linux/kgdb.h +2 more+50 -110 replies
4/13RFC ONLY - kgdb: gdb "monitor" -> kdb passthroughinclude/linux/kgdb.h kdb/kdb_io.c kernel/kgdb.c+36 -80 replies
5/13RFC ONLY - kgdboc,keyboard: Keyboard driver for kdb with kgdbdrivers/char/Makefile drivers/char/kdb_keyboard.c drivers/char/kdb_keyboard.h +4 more+425 -70 replies
6/13kgdb: remove post_primary_code referencesarch/x86/kernel/kgdb.c include/linux/kgdb.h kernel/kgdb.c+0 -510 replies
7/13RFC ONLY - x86,kgdb: Add low level debug hookarch/x86/include/asm/kgdb.h arch/x86/kernel/kgdb.c arch/x86/kernel/traps.c +3 more+41 -20 replies
8/13RFC ONLY - arm,kgdb: Add hook to catch an oops with debuggerarch/arm/include/asm/kgdb.h arch/arm/kernel/kgdb.c arch/arm/kernel/traps.c+15 -00 replies
9/13RFC ONLY - powerpc,kgdb: Introduce low level trap catchingarch/powerpc/kernel/kgdb.c arch/powerpc/kernel/traps.c lib/Kconfig.kgdb+13 -30 replies
10/13RFC ONLY - mips,kgdb: kdb low level trap catch and stack tracearch/mips/include/asm/kgdb.h arch/mips/kernel/kgdb.c arch/mips/kernel/traps.c +1 more+38 -20 replies
11/13kgdb: Add the ability to schedule a breakpoint via a taskletinclude/linux/kgdb.h kernel/kgdb.c+27 -00 replies
12/13RFC ONLY - kgdb,kdb: use async breakpoint for sysrq for usbkernel/kgdb.c+11 -10 replies
13/13RFC ONLY - usb,keyboard: uchi, echi, and ochi polling keyboard urbsdrivers/char/kdb_keyboard.c drivers/hid/usbhid/hid-core.c drivers/hid/usbhid/usbkbd.c +14 more+771 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/13] RFC ONLY - kdb for kgdb

This patch series is a request for comments on several levels.

1) Do people find kdb useful? (See * and **)
2) Would kdb folks be willing to use it if it was a front end to kgdb?
3) Does kdb have a future in the mainline kernel?
4) Is this a reasonable approach to have some level of unification to end up with a more robust kernel debugger?

* This is not meant to be a religious war

** This will never replace printk :-)

What follows is a series of patches to the development kernel which enable kdb as a front end to kgdb for arm, mips, powerpc, and x86. This is a very raw prototype, but enough of it it works such that folks can try it out.

To get the most basic functionality, you only need the first 2 patches in the series. The remainder of the patches go on to incrementally add back some of the functionality that was removed from kdb. I made an attempt to try to make the first part just the generic set of changes required to get kdb working on 1 or more archs.

The kdb front end works a little differently than if you were to take the original kdb patch set from:

ftp://oss.sgi.com/projects/kdb/download/v4.4/

In the kernel .config you should enable the following options:

CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_KGDB_LOW_LEVEL_TRAP=y
CONFIG_KGDB_KDB=y
CONFIG_KGDB_KDB_PRIMARY=y
CONFIG_KDB_KEYBOARD=y
CONFIG_KDB_USB=y

If you were using the serial port with kdb before, now you just use the kgdboc mechanism with no differences at all. IE use you kernel command line with:

console=ttyS0,115200 kgdboc=ttyS0 kgdbwait

That will get you access to kdb just after the console has been registered. If you want to use the keyboard, you could use:

console=tty0 kgdboc=kdb kgdbwait

You can also use the keyboard and or serial console:

console=ttyS0,115200 console=tty0 kgdboc=kdb,ttyS0

In terms of breaking into the debugger after the system is up, you must use the sysrq-g sequence. That means you could run:
echo g > /proc/sysrq-trigger

Or you can use the SysRq key on your key board. On a typical laptop you might have to do the following:

press and hold ALT -- You will be holding this the whole time
press and hold FN
press and release the key with the SysRq label
release FN
press and release g
release ALT

I have also found on some PS/2 keyboards you have press alt again after resuming the system because the key up event got lost somewhere.

Once you are in kdb you can run help to see a limited list of commands.

You can also still connect gdb or re-enter kdb without leaving the exception state. To get out of kgdb mode you can type "$3#33", or to get into kgdb mode from kdb, you can type "kgdb". Also from gdb you can issue commands to the kdb front end, via gdb's montior command. For instance you could issue "monitor lsmod". Allowing the gdb monitor extension was certainly another motivation behind the prototype.

Quoted 1 line

From here it is a matter of deciding if it is worth continuing down

this route.

The evaulation of this project will definitely cause some further cleanup and improvement to kgdb, regardless of if this effort is carried forward. Two of the patches in this series are patches likely to get integrated into kgdb's code base and do not bear the "RFC ONLY" indication.

Thanks,
Jason.

You can find the development branch for this here:

http://git.kernel.org/?p=linux/kernel/git/jwessel/linux-2.6-kgdb.git;a=shortlog;h=kdb_prototype

or grab a static version of the patches here:

http://kernel.org/pub/linux/kernel/people/jwessel/branches/kdb_prototype.tar.bz2

short log info follows:

Jason Wessel (13):
RFC ONLY - kdb: core for kgdb backend
RFC ONLY - kgdb: core changes to support kdb
RFC ONLY - kgdb,8250,pl011: Return immediately from console poll RFC ONLY - kgdb: gdb "monitor" -> kdb passthrough
RFC ONLY - kgdboc,keyboard: Keyboard driver for kdb with kgdb
kgdb: remove post_primary_code references
RFC ONLY - x86,kgdb: Add low level debug hook
RFC ONLY - arm,kgdb: Add hook to catch an oops with debugger RFC ONLY - powerpc,kgdb: Introduce low level trap catching RFC ONLY - mips,kgdb: kdb low level trap catch and stack trace
kgdb: Add the ability to schedule a breakpoint via a tasklet RFC ONLY - kgdb,kdb: use async breakpoint for sysrq for usb RFC ONLY - usb,keyboard: uchi, echi, and ochi polling keyboard urbs

 Makefile                              |    1 +
 arch/arm/include/asm/kgdb.h           |    2 +
 arch/arm/include/asm/kmap_types.h     |    1 +
 arch/arm/kernel/kgdb.c                |   13 +
 arch/arm/kernel/traps.c               |    5 +
 arch/mips/include/asm/kgdb.h          |    2 +
 arch/mips/include/asm/kmap_types.h    |    3 +-
 arch/mips/kernel/kgdb.c               |   27 +-
 arch/mips/kernel/traps.c              |   14 +
 arch/powerpc/include/asm/kmap_types.h |    1 +
 arch/powerpc/kernel/kgdb.c            |   12 +-
 arch/powerpc/kernel/traps.c           |    7 +
 arch/x86/include/asm/kgdb.h           |    3 +
 arch/x86/include/asm/kmap_types.h     |    3 +-
 arch/x86/kernel/kgdb.c                |   56 +-
 arch/x86/kernel/traps.c               |    6 +
 drivers/char/Makefile                 |    1 +
 drivers/char/kdb_keyboard.c           |  407 ++++
 drivers/char/kdb_keyboard.h           |  143 ++
 drivers/hid/usbhid/hid-core.c         |   26 +
 drivers/hid/usbhid/usbkbd.c           |   13 +
 drivers/serial/8250.c                 |    4 +-
 drivers/serial/amba-pl011.c           |    6 +-
 drivers/serial/kgdboc.c               |   80 +-
 drivers/usb/core/hcd.c                |   14 +
 drivers/usb/core/hcd.h                |    4 +
 drivers/usb/host/ehci-hcd.c           |   42 +
 drivers/usb/host/ehci-pci.c           |    6 +
 drivers/usb/host/ehci-q.c             |  225 ++
 drivers/usb/host/ohci-hcd.c           |   66 +
 drivers/usb/host/ohci-pci.c           |    6 +-
 drivers/usb/host/ohci-q.c             |   63 +
 drivers/usb/host/uhci-hcd.c           |   36 +
 drivers/usb/host/uhci-q.c             |   51 +
 fs/proc/meminfo.c                     |  145 ++
 fs/proc/mmu.c                         |   16 +-
 include/linux/kdb.h                   |  172 ++
 include/linux/kdbprivate.h            |  611 ++++++
 include/linux/keyboard.h              |    2 +
 include/linux/kgdb.h                  |   25 +-
 include/linux/serial_core.h           |    1 +
 init/main.c                           |   26 +
 kdb/.gitignore                        |    1 +
 kdb/Makefile                          |   48 +
 kdb/kdb_bp.c                          |  863 ++++++++
 kdb/kdb_bt.c                          |  209 ++
 kdb/kdb_cmds                          |   32 +
 kdb/kdb_io.c                          |  895 ++++++++
 kdb/kdbmain.c                         | 3669 +++++++++++++++++++++++++++++++++
 kdb/kdbsupport.c                      | 1120 ++++++++++
 kernel/kallsyms.c                     |   22 +
 kernel/kgdb.c                         |  321 +++-
 kernel/module.c                       |   19 +-
 kernel/panic.c                        |    6 +
 kernel/printk.c                       |   14 +
 kernel/sched.c                        |   93 +-
 kernel/signal.c                       |   49 +
 lib/Kconfig.kgdb                      |   37 +
 mm/hugetlb.c                          |   22 +
 mm/swapfile.c                         |   22 +
 60 files changed, 9697 insertions(+), 92 deletions(-)
 create mode 100644 drivers/char/kdb_keyboard.c
 create mode 100644 drivers/char/kdb_keyboard.h
 create mode 100644 include/linux/kdb.h
 create mode 100644 include/linux/kdbprivate.h
 create mode 100644 kdb/.gitignore
 create mode 100644 kdb/Makefile
 create mode 100644 kdb/kdb_bp.c
 create mode 100644 kdb/kdb_bt.c
 create mode 100644 kdb/kdb_cmds
 create mode 100644 kdb/kdb_io.c
 create mode 100644 kdb/kdbmain.c
 create mode 100644 kdb/kdbsupport.c