getting started:
- You'll need to download and apply two patches.
1) common patch
- contains the changes for the generic kernel code,
2) architecture-specific patch.
e.g., You would need,
kdb-v4.2-2.4.20-common-1.bz2 and
kdb-v4.2-2.4.20-i386-1.bz2.
++
1) copy the files into the /usr/src/linux dir,
2) extract them.
#bzip2 -d kdb-v4.2-2.4.20-common-1.bz2
#bzip2 -d kdb-v4.2-2.4.20-i386-1.bz2
3) Now apply the patches:
#patch -p1
#patch -p1
The patches should apply cleanly. Look for any files ending with
.rej. This indicates failed patches.
4) Next, the kernel needs to be built with KDB enabled.
4a) set the CONFIG_KDB option - use menuconfig,or xconfig.
Go to the "kernel hacking" section at the end and select
the "built-in kernel debugger supprot" option.
There are also a couple of other options you can select.
e.g., Selecting the "compile the kernel with frame pointer"
option sets the CONFIG_FRAME_POINTER flag. This will lead
to better stack tracebacks, as the frame pointer register
is used as a frame pointer rather that a general purpose
register.
5) save the configuration and exit. Recompile the kernel.
doing a "make clean" is recommended.
6) compile and install, and reboot on.
++
Initializing and setting the environment variables:
- You can define KDB commands that will be executed during the
initialization of KDB.
These commands need to be defined in a plain test file
called kdb_cmds, exists in the KDB directory of the linux source tree.
( post patching )
This file can also be used to define environment variables
for setting the display and print options.
The disadvantage of using this file is that the kernel needs
to be rebuilt and reinstalled you change the file.
++
Activating KDB:
- If CONFIG_KDB_OFF was not selected during compilation, KDB is active
by default. Otherwise you need,
to activate:
#echo "1" >/proc/sys/kernel/kdb
to deactivate:
#echo "0" >/proc/sys/kernel/kdb
- There is yet another flag that can be passed to the kernel during boot.
The kdb=early flag will result in control being passed to the KDB
very early in the boot process, which helps you to debug very early
during the boto proces.
- If KDB is on, it will get invoked automatically whenever there is a panic
in the kernel.
***- OR, pressing the PAUSE key on the keyboard would manually invoke KDB.
- Ofcourse, there is another way to invoke KDB is through the serial console.
- refer later. ***
KDB commands:
- KDB is a very powerful tool that allows several operations such as memory
and register.
a) MEmory display and modification:
- commands: md, mdr, mm, and mmW
md: takes an address/symbol and a line count and displays memory starting at
the address for line-count number of lines.
mdr: takes an address/symbol and a byte count.
mm: modifies memory contents. takes an address/symbol and new contents as
parameters and replaces the contents at the address with new-contents.
mmW: modifies memory contents in WORD size.
e.g.;
To display 15 lines of memory starting at 0xc000000:
[0]kdb> md 0xc000000 15
To change the contents of memory location 0xc000000 to 0x10:
[0]kdb> mm 0xc000000 0x10
b) Register display and modification:
No comments:
Post a Comment