Attaching to a running kernel

The JTAG kernel debugger can also attach to a kernel that is already running, or has crashed, provided that an ST Micro Connect is plugged into the board and is not already in use.

The steps to do this are as follows:

host% sh4-linux-gdb vmlinux
GNU gdb STMicroelectronics/Linux Base 6.4-20 [build Mar 29 2007]
Copyright 2005 Free Software Foundation, Inc.
<snip>
Enabling Linux kernel awareness layer [Build Mar 29 2007].
(gdb) sh4tp my_stmc:mb519:st40,no_reset=1,no_pokes=1
The target is assumed to be little endian
The target architecture is assumed to be sh4
0x84003064 in default_idle () at arch/sh/kernel/process.c:61
61              if (!hlt_counter)
(gdb) set linux-awareness loaded on

The first command is the normal TargetPack connection command, but with two extra parameters, no_reset=1 and no_pokes=1.

(gdb) sh4tp my_stmc:mb519:st40,no_reset=1,no_pokes=1

The second command,

(gdb) set linux-awareness loaded on

tells GDB that the kernel is already loaded and running on the board.

You can then debug the kernel as normal.

To detach the debugger and leave GDB, while leaving the system running, use the following three commands:

(gdb) ondisconnect restart
(gdb) disconnect
(gdb) quit

The st40load_gdb loader script has an option, -r to automatically disconnect GDB from the kernel after it has booted, allowing you to attach the debugger again later if you wish.