Debug
Linux Loadable-Modules and Device Drivers with JTAG and Debugger
This section contains
information to help you debug
Linux-loadable modules with Debugger.
General
Principles
Debugging Linux-loadable
modules requires
that the debug
environment is aware of the MMU translation scheme used by the Linux
kernel. The JTAG and Debugger are fully aware
of
Linux MMU translation. For debug of loadable modules, load
symbols
for the Linux kernel and for any modules you wish to debug. Using this
technique, any calls to Linux can be debugged at the source level as
well. To
debug the Linux kernel:
- Make sure MMU translation
is turned on in your initialization (.DEF) file.
- Build the Linux kernel
and any modules you wish to debug with debug symbols enabled. (Use the
“-g”
switch in your make file)
- Build the Linux kernel
and any modules you wish to debug with pipelining disabled (Use the
“-fno-schedule-insns
-fno-schedule-insns2” switch in your make file)
- Load your installable
module using the “insmod
–m” command. This provides the start
address of the module in the format shown below. Output of a typical
“insmod
–m filename.o” command:
bash# insmod -m my_mod.o
Sections:
Size
Address Align
.this
00000060 cf030000 2**2
.text
000002f4 cf030060 2**2
.rodata
00000134 cf030354 2**2
.data
00000000 cf030488 2**0
.sdata
0000000c cf030488 2**2
.kstrtab
00000085 cf030494 2**0
.bss
00000000 cf030519 2**0
Steps to Follow
Once you have verified
these changes, you are ready to begin debugging. At this
point use a boot loader (U-BOOT is
used in this example) to load the kernel to your target and start it
running. Then load any installable
module you wish to debug with the “insmod”
command. Here are the typical steps you should follow:
1.
Start
a Minicom session or Windows Hyper Terminal (serial link to your
target)
2.
Start
Debugger
3.
Load
an Debugger configuration that:
a.
loads
kernel symbols only (example: vmlinux.elf).
b.
connects
to your target and
lets you load symbols manually via the Load
command in the File
menu (from vmlinux.elf
for
example)
4.
Verify
you have symbol information in the Agile Function Browser window by
selecting a kernel module and after pressing the right mouse button
select:
Show this function (“start_kernel”
is a good example to use).
5.
From
the File
menu, click Addsymbols
to add the symbols for the
module you want to debug to the Debugger symbol manager. (Use
the address for the text
section from the "insmod
–m” command for the module you want
to debug)
6.
Use
the right mouse menu to set a hardware break point in this module
7.
Reset and
start your target running from within
Agile
8.
Verify
that your target monitor is up and running
9.
Load
the Linux kernel from your monitor
10.
From
the shell, use the “insmod”
command to load the module.
11.
Run
any Linux commands
needed to cause you installable module to execute.
12.
Once
your module is up and
running, you should hit the break point and stop.
13.
You
should now see source
code for module you want to debug.
|