aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/frv/gdbstub.txt
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@kernel.org>2008-02-03 08:54:28 -0500
committerAdrian Bunk <bunk@kernel.org>2008-02-03 08:54:28 -0500
commit0868ff7a4215f9244037b63a2952761cbe196a07 (patch)
treeb98be929b6972a03c550166eea0ea17afc926058 /Documentation/frv/gdbstub.txt
parent03502faa259bce35317a32afe79b7c69f507e14a (diff)
move frv docs one level up
My first guess for "fujitsu" was it might be related to the fujitsu-laptop.c driver... Move the frv directory one level up since frv is the name of the architecture in the Linux kernel. Signed-off-by: Adrian Bunk <bunk@kernel.org>
Diffstat (limited to 'Documentation/frv/gdbstub.txt')
-rw-r--r--Documentation/frv/gdbstub.txt130
1 files changed, 130 insertions, 0 deletions
diff --git a/Documentation/frv/gdbstub.txt b/Documentation/frv/gdbstub.txt
new file mode 100644
index 000000000000..b92bfd902a4e
--- /dev/null
+++ b/Documentation/frv/gdbstub.txt
@@ -0,0 +1,130 @@
1 ====================
2 DEBUGGING FR-V LINUX
3 ====================
4
5
6The kernel contains a GDB stub that talks GDB remote protocol across a serial
7port. This permits GDB to single step through the kernel, set breakpoints and
8trap exceptions that happen in kernel space and interrupt execution. It also
9permits the NMI interrupt button or serial port events to jump the kernel into
10the debugger.
11
12On the CPUs that have on-chip UARTs (FR400, FR403, FR405, FR555), the
13GDB stub hijacks a serial port for its own purposes, and makes it
14generate level 15 interrupts (NMI). The kernel proper cannot see the serial
15port in question under these conditions.
16
17On the MB93091-VDK CPU boards, the GDB stub uses UART1, which would otherwise
18be /dev/ttyS1. On the MB93093-PDK, the GDB stub uses UART0. Therefore, on the
19PDK there is no externally accessible serial port and the serial port to
20which the touch screen is attached becomes /dev/ttyS0.
21
22Note that the GDB stub runs entirely within CPU debug mode, and so should not
23incur any exceptions or interrupts whilst it is active. In particular, note
24that the clock will lose time since it is implemented in software.
25
26
27==================
28KERNEL PREPARATION
29==================
30
31Firstly, a debuggable kernel must be built. To do this, unpack the kernel tree
32and copy the configuration that you wish to use to .config. Then reconfigure
33the following things on the "Kernel Hacking" tab:
34
35 (*) "Include debugging information"
36
37 Set this to "Y". This causes all C and Assembly files to be compiled
38 to include debugging information.
39
40 (*) "In-kernel GDB stub"
41
42 Set this to "Y". This causes the GDB stub to be compiled into the
43 kernel.
44
45 (*) "Immediate activation"
46
47 Set this to "Y" if you want the GDB stub to activate as soon as possible
48 and wait for GDB to connect. This allows you to start tracing right from
49 the beginning of start_kernel() in init/main.c.
50
51 (*) "Console through GDB stub"
52
53 Set this to "Y" if you wish to be able to use "console=gdb0" on the
54 command line. That tells the kernel to pass system console messages to
55 GDB (which then prints them on its standard output). This is useful when
56 debugging the serial drivers that'd otherwise be used to pass console
57 messages to the outside world.
58
59Then build as usual, download to the board and execute. Note that if
60"Immediate activation" was selected, then the kernel will wait for GDB to
61attach. If not, then the kernel will boot immediately and GDB will have to
62interrupt it or wait for an exception to occur before doing anything with
63the kernel.
64
65
66=========================
67KERNEL DEBUGGING WITH GDB
68=========================
69
70Set the serial port on the computer that's going to run GDB to the appropriate
71baud rate. Assuming the board's debug port is connected to ttyS0/COM1 on the
72computer doing the debugging:
73
74 stty -F /dev/ttyS0 115200
75
76Then start GDB in the base of the kernel tree:
77
78 frv-uclinux-gdb linux [uClinux]
79
80Or:
81
82 frv-uclinux-gdb vmlinux [MMU linux]
83
84When the prompt appears:
85
86 GNU gdb frv-031024
87 Copyright 2003 Free Software Foundation, Inc.
88 GDB is free software, covered by the GNU General Public License, and you are
89 welcome to change it and/or distribute copies of it under certain conditions.
90 Type "show copying" to see the conditions.
91 There is absolutely no warranty for GDB. Type "show warranty" for details.
92 This GDB was configured as "--host=i686-pc-linux-gnu --target=frv-uclinux"...
93 (gdb)
94
95Attach to the board like this:
96
97 (gdb) target remote /dev/ttyS0
98 Remote debugging using /dev/ttyS0
99 start_kernel () at init/main.c:395
100 (gdb)
101
102This should show the appropriate lines from the source too. The kernel can
103then be debugged almost as if it's any other program.
104
105
106===============================
107INTERRUPTING THE RUNNING KERNEL
108===============================
109
110The kernel can be interrupted whilst it is running, causing a jump back to the
111GDB stub and the debugger:
112
113 (*) Pressing Ctrl-C in GDB. This will cause GDB to try and interrupt the
114 kernel by sending an RS232 BREAK over the serial line to the GDB
115 stub. This will (mostly) immediately interrupt the kernel and return it
116 to the debugger.
117
118 (*) Pressing the NMI button on the board will also cause a jump into the
119 debugger.
120
121 (*) Setting a software breakpoint. This sets a break instruction at the
122 desired location which the GDB stub then traps the exception for.
123
124 (*) Setting a hardware breakpoint. The GDB stub is capable of using the IBAR
125 and DBAR registers to assist debugging.
126
127Furthermore, the GDB stub will intercept a number of exceptions automatically
128if they are caused by kernel execution. It will also intercept BUG() macro
129invocation.
130