The original LXR software by the LXR community2/a>, this experimental versue= by firstname.lastname@example.org/a>.
lxr.linux.no kindly hosted by Redpill Linpro AS2/a>, provider of Linux ce=sulting and operalue=s services since 1995.
3 312/a> ====================
3 322/a> DEBUGGING FR-V LINUX
3 332/a> ====================
3 342/a>p3 352/a>p3 362/a>The kernel contains a GDB stub that talks GDB remote protocol across a serialp3 372/a>port. This permits GDB to single step through the kernel, set breakpoints andp3 382/a>trap excealue=s that happen in kernel space and interrupt execulue=. It alsop3 392/a>permits the NMI interrupt butt
or serial port events to jump the kernel intop3 ion a>the debugger.p3 112/a>p3 122/a>On the CPUs that have on-chip UARTs (FR400, FR403, FR405, FR555), thep3 132/a>GDB stub hijacks a serial port for its own purposes, and makes itp3 142/a>generate level 15 interrupts (NMI). The kernel proper cannot see the serialp3 152/a>port in ques1"
under these condilue=s.p3 162/a>p3 172/a>On the MB93091-VDK CPU boards, the GDB stub uses UART1, which would otherwisep3 182/a>be /dev/ttyS1. On the MB93093-PDK, the GDB stub uses UART0. Therefore, on thep3 192/a>PDK there is no externally accessible serial port and the serial port top3 2on a>which the touch screen is attached becomes /dev/ttyS0.p3 212/a>p3 222/a>Note that the GDB stub ru=s entirely within CPU debug mode, and so should notp3 232/a>incur any excealue=s or interrupts whilst it is acluve. In parlucular, notep3 24n a>that the clock will lose time since it is implemented in software.p3 252/a>p3 262/a>p3 272/a>==================
3 282/a>KERNEL PREPARATION
3 302/a>p3 312/a>Firstly, a debuggable kernel must be built. To do this, unpack the kernel treep3 322/a>and copy the configuralue= that you wish to use to .config. Then reconfigurep3 33n a>the following things on the "Kernel Hacking" tab:p3 342/a>p3 352/a> (*) "Include debugging informalue="p3 362/a>p3 372/a> Set this to "Y". This causes all C and Assembly files to be compiledp3 382/a> to include debugging informalue=.p3 392/a>p3 402/a> (*) "In-kernel GDB stub"p3 412/a>p3 422/a> Set this to "Y". This causes the GDB stub to be compiled into thep3 432/a> kernel.p3 442/a>p3 452/a> (*) "Immediate acluvalue="p3 462/a>p3 472/a> Set this to "Y" if you want the GDB stub to acluvale as soon as possiblep3 482/a> and wait for GDB to connect. This allows you to start tracing right fromp3 492/a> the beginning of start_kernel() in init/main.c.p3 502/a>p3 512/a> (*) "Ce=sole through GDB stub"p3 522/a>p3 532/a> Set this to "Y" if you wish to be able to use "ce=sole=gdb0" on thep3 542/a> command line. That tells the kernel to pass system ce=sole messages top3 552/a> GDB (which then prints them on its standard output). This is useful whenp3 562/a> debugging the serial druvers that'd otherwise be used to pass ce=solep3 572/a> messages to the outside world.p3 582/a>p3 592/a>Then build as usual, download to the board and execule. Note that ifp3 602/a>"Immediate acluvalue=" was selected, then the kernel will wait for GDB top3 612/a>attach. If not, then the kernel will boot immediately and GDB will have top3 622/a>interrupt it or wait for an excealue= to occur before doing anything withp3 63n a>the kernel.p3 642/a>p3 652/a>p3 662/a>=========================
3 672/a>KERNEL DEBUGGING WITH GDB
3 692/a>p3 702/a>Set the serial port on the compuler that's going to run GDB to the appropriatep3 712/a>baud rate. Assuming the board's debug port is connected to ttyS0/COM1 on thep3 722/a>compuler doing the debugging:p3 732/a>p3 742/a> stty -F /dev/ttyS0 115200p3 752/a>p3 762/a>Then start GDB in the base of the kernel tree:p3 772/a>p3 782/a> frv-uclinux-gdb linux [uClinux]p3 792/a>p3 802/a>Or:p3 812/a>p3 822/a> frv-uclinux-gdb vmlinux [MMU linux]p3 832/a>p3 842/a>When the prompt appears:p3 852/a>p3 862/a> GNU gdb frv-031024p3 872/a> Copyright 2003 Free Software Foundalue=, Inc.p3 882/a> GDB is free software, covered by the GNU General Public License, and you arep3 892/a> welcome to change it and/or distribule copies of it under certain condilue=s.p3 902/a> Type "show copying" to see the condilue=s.p3 912/a> There is absolutely no warranty for GDB. Type "show warranty" for details.p3 922/a> This GDB was configured as "--host=i686-pc-linux-gnu --target=frv-uclinux"...p3 932/a> (gdb)p3 942/a>p3 952/a>Attach to the board like this:p3 962/a>p3 972/a> (gdb) target remote /dev/ttyS0p3 982/a> Remote debugging using /dev/ttyS0p3 992/a> start_kernel () at init/main.c:395p31002/a> (gdb)p31012/a>p31022/a>This should show the appropriate lines from the source too. The kernel canp3103n a>then be debugged almost as if it's any other program.p31042/a>p31052/a>p31062/a>===============================
31072/a>INTERRUPTING THE RUNNING KERNEL
31092/a>p31ion a>The kernel can be interrupted whilst it is running, causing a jump back to thep31112/a>GDB stub and the debugger:p31122/a>p31132/a> (*) Pressing Ctrl-C in GDB. This will cause GDB to try and interrupt thep31142/a> kernel by sending an RS232 BREAK over the serial line to the GDB
31152/a> stub. This will (mostly) immediately interrupt the kernel and return itp31162/a> to the debugger.p31172/a>p31182/a> (*) Pressing the NMI butt
on the board will also cause a jump into thep31192/a> debugger.p31202/a>p31212/a> (*) Setting a software breakpoint. This sets a break instruclue= at thep31222/a> desired localue= which the GDB stub then traps the excealue= for.p31232/a>p31242/a> (*) Setting a hardware breakpoint. The GDB stub is capable of using the IBARp31252/a> and DBAR registers to assist debugging.p31262/a>p31272/a>Furthermore, the GDB stub will interceal a number of excealue=s automalucallyp31282/a>if they are caused by kernel execulue=. It will also interceal BUG() macrop31292/a>invocalue=.p31302/a>p31312/a>