Article title: kdb compilation, installation, and full manual. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
At present, there are too few articles about kdb on the Internet that are most resentful, which are misleading, even if most of them are difficult to follow the steps.
I am willing to write down the detailed steps through a large number of practices and experience in using kdb.
Compile kdb.
Step 1:
Kdb is not a standard configuration for Linux kernel. you need to download one version and two files from this website.
Ftp://oss.sgi.com/projects/kdb/download/v4.4/
Kdb-v4.4-2.6.15-common-1(kdb-v4.4-2.6.15-common-1.bz2)
Kdb-v4.4-2.6.15-i386-1(kdb-v4.4-2.6.15-i386-1.bz2)
Step 2:
Download a pure Linux kernel source code file.
Remember, it must be a pure Linux kernel source code. it cannot be a redhat or another company version. Otherwise, an error occurs during pacth.
For example, once I typed the patch in/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686, an error occurred, this directory is the source code modified by redhat, it is not a pure source code, so an error occurs.
The downloaded source code must be the same as the minor version in step 1. For example, my Linux kernel version is 2.6.15-1 ***.
Name the linux pure kernel source code file as linux and put it in/usr/src.
Step 3:
Put the unzipped 2 file kdb-v4.4-2.6.15-common-1 from step 1 in the/usr/src/linux directory.
At this time, the patch will be successful smoothly, as long as there is no reject prompt such as success.
Once a reject is found, there are only two possibilities:
First, your kernel is not the real kernel, but the improved kernel of the company. Second, the kdb version is inconsistent with the source code version.
Step 4:
In this linux configuration, do not use the make menuconfig command here. you may be wondering why? My experience shows that the kdb options from menuconfig of different linux/kdb versions are very different and cannot be accurately described in languages, I used to refer to a lot of online materials based on menuconfig, which resulted in conflicting descriptions and was difficult to understand. Here, we directly rewrite the file to be the most reliable.
Run the make menuconfig command without changing any options. press enter and select yes to generate a hidden file. config.
Use vi/vim to open this file,
Rewrite as follows:
CONFIG_KDB = y
CONFIG_KDB_MODULES = n
CONFIG_KDB_OFF = n
CONFIG_KALLSYMS = y
CONFIG_FRAME_POINTER = y
Save. Remember, this is much safer and clearer than choosing the menuconfig menu option.
Open the kdb/kdb_cmds file and comment out all of them. for example:
# Initial commands for kdb, alter to suit your needs.
# These commands are executed in kdb_init () context, no SMP, no
# Processes. Commands that require process data (including stack or
# Registers) are not reliable this early. set and bp commands shold
# Be safe. Global breakpoint commands affect each cpu as it is booted.
# Standard debugging information for first level support, just type archkdb
# Or archkdbcpu or archkdbshort at the kdb prompt.
Defcmd archkdb "First line arch debugging"
# Set BTSYMARG 1
# Set BTARGS 5
#-Archkdbcommon
#-Bta
Endefcmd
Defcmd archkdbcpu "" archkdb with only tasks on cpus"
# Set BTSYMARG 1
# Set BTARGS 5
#-Archkdbcommon
#-Btc
Endefcmd
Defcmd archkdbshort "" archkdb with less detailed backtrace"
# Set BTSYMARG 0
# Set BTARGS 0
#-Archkdbcommon
#-Bta
Endefcmd
Why, because we were very unfamiliar with kdb when we first started to contact kdb. if we comment out all the options, kdb will become easier to operate. otherwise, after the system is restarted, you thought the installation was wrong. if you don't believe it, try it. After the level is high, you can recompile the system.
Step 5:
Rewrite the EXTRAVERSION in the Makefile file. just give it a name.
Make all
Make bzImage
Make modules
Make modules_install
Make install
There are articles about what lilo files to rewrite.
You don't need to rewrite any lilo files. if your system only supports grub, you can't find lilo in the system !!!
Step 6:
Restart and select the new system in the system options.
When the system starts to boot, you will see 3-5 lines of kdb information on the screen, which is actually the configuration in kdb_cmds. we have commented it out, so the light is displayed, it will not run (this is the safest way, otherwise, if you are not familiar with kdb, you will get an error in changing kdb_cmds and what kernel panic information will appear at startup, this is why the startup is always unsuccessful ).
We can see that the other commands are the same as when kdb is not installed. if you enter the user name and password to enter the system, it indicates that your kdb has been installed successfully.
Start kdb.
Enter the system with the root permission.
# Echo "1" type = "codeph" text = "/proc/sys/kernel/kdb"> The startup is successful.
After running this command, a colleague reported that the kdb file could not be found. when I debugged it for him, I found that kdb was not installed successfully. Finally, I installed it for him and it was okay.
Press the "Pause Break" key to display the kdb interface. If you want to exit, enter go and press enter. I later found that after entering the system through f1, enter go + press enter
Why can't I leave it? after f2 enters the system, it exits smoothly after entering go + press Enter. this is a strange phenomenon. I guess it may be related to linux itself.
Use kdb.
Who said that kdb could not be used for source code-level debugging? at that time, he did not actually use kdb.
In fact, kdb can be debugged at the source code level. the premise here is the definition of the source code level debugging, if you use kdb for one-step tracking, you can see that the source code is automatically followed by one line.
It is very convenient for you to check bugs.
It is useless for anyone who uses kdb. for the key, read the document. remember not to read any other third-party documents (which may be misleading). check the slides and other documents in your Documentation/kdb, this is the most pollution-free and authentic document.
Author: wang zh