Single-Step Debugging kernel instructions
Well, the goal of this document is to single-step the kernel, from the version number of each tool software to each command, there is a description
Ubuntu1204,32 bit
Http://www.ubuntu.org.cn/download/desktop
Install the system with a VMware virtual machine.
GDB has a bug when using a 64-bit system. The error message is: XXX is too long. So it is recommended to use 32-bit system
Compiling kernel 3.5.4
Download the address of the kernel, Beijing Jiaotong University image address: http://mirror.bjtu.edu.cn/kernel/linux/kernel/v3.x/
I downloaded the kernel source version number 3.5.4
To prevent some components of the system from having a lower version number, consider the following two commands to update the system:
sudo apt-get updatesudo apt-get upgradesudo apt-get Install build-essential
Compile step: After entering the root directory of kernel, the command is as follows:
Make Menuconfig
Hint not found ncurses install: sudo apt-get install libncurses//Jardee hint: libncurses* The//kernel wit can be found with hacking–> compile Kernel H Debug Info "and" Compile the kernel with frame pointers "These two options must be selected. Other, do not change the settings, according to the default on the line, press ESC directly, select Save and exit
Make
QEMU 1.4.0
Http://wiki.qemu.org/Download
Installation
According to the website's instructions, compile, install: http://qemu.weilnetz.de/qemu-doc.html#compilation
Compile QEMU Error
Missing glib, workaround: sudo apt-get install Libglib2.0-dev
Missing autoconf, workaround: sudo apt-get install autoconf automake libtool
Single-step debugging fails when using older versions of QEMU, or when using QEMU directly from Ubuntu source.
Use: Verify that the compiled kernel is ready to run through QEMU
Qemu-system-i386-kernel (kernel root directory)/arch/x86/boot/bzimage-initrd/boot/initrd.img-3.5.0-25-generic
Note: After the kernel parameters for their own compiled kernel, the INITRD parameter for the system comes with the file, different system may be different version number start running, it will prompt in the VNC 102.0.0.1:5900 started.
Then, under Ubuntu Desktop interface, press the Windows key in the keyboard (Mac command key), enter remote, find "Remmina remote Desktop Client" software, open, create a new remote connection, note protocol with VNC, Server Fill 127.0.0.1:5900
650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-07-1.png "alt=" Pic1 "/>
After entering the system, enter uname-a or uname-r to verify that the system is running its own compiled kernel, see 3.5.4.
650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-07-2.png "alt=" Pic1 "/>
JDK (Java environment required for running eclipse)
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html version number, 7U15. In general, use the latest version number.
Files Downloaded: jdk-7u9-linux-i586.gz
Unzip:
Tar-xzf jdk-7u15-linux-i586.gz
Move the extracted folder to the target location
sudo mkdir/usr/lib/jvm; MV jdk1.7.0_15//USR/LIB/JVM
Set Symbolic Link: (Note change to your version number, the install parameter is preceded by two short horizontal)
sudo update-alternatives–install/usr/bin/javac Javac/usr/lib/jvm/jdk1.7.0_09/bin/javac 1
sudo update-alternatives–install/usr/bin/java Java/usr/lib/jvm/jdk1.7.0_09/bin/java 1
sudo update-alternatives–install/usr/bin/jar Jar/usr/lib/jvm/jdk1.7.0_09/bin/jar 1
sudo update-alternatives–install/usr/bin/javadoc javadoc/usr/lib/jvm/jdk1.7.0_09/bin/javadoc 1
Eclipse JUNO
HTTP://WWW.ECLIPSE.ORG/DOWNLOADS/PACKAGES/ECLIPSE-IDE-CC-DEVELOPERS/JUNOSR2 download to unzip.
Eclipse Plugin: CDT
http://download.eclipse.org/tools/cdt/builds/
I downloaded the version number: cdt-master-7.0.1-i201009241320
Download the zip archive to the package. No decompression, installation mode: Open Eclipse,
Help button –> Install New software–> Add button in the Pop-up dialog box, name just fill in a line, location, point to the right of the archive button, select the zip file that was downloaded. Installation can be done.
Qemu+eclipse+gdb Debug Kernel
Start QEMU with the following command:
Qemu-system-i386-s-s-kernel ~/desktop/linux-3.5.4/arch/x86/boot/bzimage-initrd/boot/initrd.img-3.5.0-25-generic
-S is the default remote debugging, port number 1234
-S for start debugging, stop, wait for GDB
-kernel for their own compiled bzimage, usually placed in the kernel root directory arch/x86/boot/
-INITRD behind an image of yourself Ubuntu.
Window–>preferences–> general–> Workspace, remove "build automatically" 650) this.width=650; "src="/HTTP// Yyq.github.io/images/2013-03-06-1.png "alt=" Pic1 "/>
Window–> preferences–> c/c++–> Indexer, will enable indexer cancel 650) this.width=650; src= http://yyq.github.io/ Images/2013-03-06-2.png "alt=" Pic2 "/>
File->new->project...–>c/c++–> C Project
Location: Select your own kernel root directory folder
Project type selection Makefile Project,emptyproject
Tool chain selection, LINUXGCC
650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-06-3.png "alt=" pic3 "/>
In Project Explorer, right-click your own project, select Debug as–> Debug Configurations, and in the Pop-up dialog box, double-clicking "GDB Hardware Debugging" will let you set debug parameters and so on. Feel free to write a name, this name should be the name of the Debug configuration file. 650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-06-4.png "alt=" Pic4 "/>
Configure debug parameters: In the Main tab, c/c++application box, choose your own compiled Vmlinux file, the file location should be in the root directory of the source code. Check Disable Auto build. 650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-06-5.png "alt=" Pic5 "/>
In the Debugger tab, gdb command fills in GDB, tick the use remote Target,port number to fill 1234, because the QEMU emulator default remote port is 1234.650) this.width =650; "src=" Http://yyq.github.io/images/2013-03-06-6.png "alt=" pic6 "/>"
In the Startup tab, remove the three tick. 650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-06-7.png "alt=" Pic7 "/>
Click Debugto start debugging.
Verifying debugging I set a breakpoint on line No. 486 of INIT/MAIN.C.
Window–> Show view–> Expressions, open, enter the name of the variable I want to observe, early_boot_irqs_disabled, and so on when running to the breakpoint, see its value from false to True, Verified that the basic debugging function is normal. 650) this.width=650; "src=" Http://yyq.github.io/images/2013-03-06-8.png "alt=" Pic8 "/>
This article is from "Chen Yu blog" blog, please be sure to keep this source http://chenpiaoping.blog.51cto.com/5631143/1530057