ECLISPE+QEMU+GDB Debugging Linux Kernel

Source: Internet
Author: User

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:

    1. 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

    2. 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

    1. Missing glib, workaround: sudo apt-get install Libglib2.0-dev

    2. 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.

    1. Files Downloaded: jdk-7u9-linux-i586.gz

    2. Unzip:

      Tar-xzf jdk-7u15-linux-i586.gz
    3. Move the extracted folder to the target location

      sudo mkdir/usr/lib/jvm; MV jdk1.7.0_15//USR/LIB/JVM
    4. 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
  1. 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.

  2. Window–>preferences–> general–> Workspace, remove "build automatically" 650) this.width=650; "src="/HTTP// Yyq.github.io/images/2013-03-06-1.png "alt=" Pic1 "/>

  3. 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 "/>

  4. 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 "/>

  5. 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 "/>

  6. 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.

  7. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.