|
Requirements and Preparations on
development and test machines
GDB on development machine
Install on the development machine, a GDB containing module
debugging features. It's sources are available from the kgdb downloads page. The GDB is different for kgdb
version 1.9 and for development version of KGDB. This gdb is derived
from GDB version 6.0. It contains all features of GDB 6.0 plus ability
to automatically detect module loading and unloading. You can either
download the sources, build them and install the GDB at /usr/local/bin/gdbmod.
Please go to gdb website
for information on building GDB sources. Prebuilt version of GDB are
also available from the downloads page.
Module debugging doesn't work in KGDB versions 2.0-2.1.0 Use
development version of KGDB to debug modules in 2.6 kernels.
No special setup is needed on test machines. Modules can be present
in a test machine root filesystem or a ramdisk.
Compiling and installing modules
Object files in a module need to be compiled with -g option. -g option
tells gcc to generate debugging information while compiling.
Modules in the kernel sources should be compiled and installed on a
test machine or a ram disk as usual. KGDB stub adds -g to kernel
compilation flags. These are used for compiling the kernel as well as
modules. You may face problems accommodating modules in a ram disk since
-g flag may increase size of each module around10 times.
Since a kernel source is compiled on a development machine, you may
find it easier to install modules on the same machine and then copy the
modules directory to the test machine.
Module debugging setup with KGDB versions <= 1.8
Module debugging capabilities were built into KGDB stub and GDB from
kgdb version 1.9. Versions prior to that need external support in form
of scripts for debugging modules. The setup for those versions is
described below. Following information applies to kgdb versions 1.8 and
earlier _only_.
modutils
modutils version 2.3.19 or later is required to be installed on the
test machine. modutils-2.3.19 onwards insmod command generates module
map file before initializing a module in the kernel. With this
feature, even module initialization functions can be debugged. modutils
can be downloaded from (http://www.kernel.org/pub/linux/utils/kernel/modutils/
or its mirrors). Since RH 7.0 and RH 7.1 contain required version of
modutils, nothing needs to be done if a test machine contains either of
the two versions.
gdb
gdb had a bug that caused incorrect calculation addresses of symbols
loaded via add-symbol-file command. It has been fixed in
development versions of gdb. Unfortunately this fix is not present in
gdb-5.0 Please use a development version of gdb for debugging kernel
modules. You may use a gdb built for
RH9 from gdb development
sources. This is a development version of gdb and may contain
bugs. It is recommended that you use it for DEBUGGING KERNEL MODULES
ONLY.
This gdb bug was fixed in gdb-6.0. If your linux installation has
gdb-6.0 or a later version, use that instead.
I have placed my GDB in /usr/local/bin/gdbmod on my
machine. I changed the name of the GDB so that I use that only for
kernel debugging and use the default gdb that comes with redhat
installation for other debugging. Please go to GDB home page on GNU for
information on gdb. This GDB needs to be downloaded into the
development machine.
Loading modules
For debugging kernel modules, you can load module object files in
gdb using the gdb command add-symbol-file. This command needs
addresses of sections in the module file. module loading script loadmodule.sh can be used to
automate the process of loading a module into the kenel and generate a
gdb script that will load the module file into gdb.
The script needs to be downloaded on a development machine. Name of
the test machine needs to be hardcoded in the script. Following line in
the script sets the
test machine name:
TESTMACHINE=old-pc
The script generates gdb scripts. These scripts when sourced into
gdb load object files into gdb. The directory where the script
generates these scripts also needs to be set in the script itself:
GDBSCRIPTS=/home/akale/mnt/work/gdbscripts
rsh permissions
rsh permissions to root of the test machine should be available from
a developer's account on the development machine.
rsh permissions can be given by creating a file .rhosts in the root
directory on the test machine and writing names of the development
machine and the developer's account in the file. .rhosts file should
not be readable by group and others.
[root@old-pc /root]# ls -l .rhosts
-rw------- 1 root
root 28
Jan 1 1996 .rhosts
[root@old-pc /root]# cat .rhosts
askii-pc amit
[root@old-pc /root]#
|