Setup Guide for Kernel Debugging Using Eclipse IDE
Done By: Koustubha D and Rishabh S
Done By: Koustubha D and Rishabh S
Arizona State University.
A)Software Setup:
1. Eclipse IDE Setup:
- In Fedora, Go to Application-> Add Remove Software Menu. OR In some latest versions of Fedora, the same option could be found out in System¬>Administration->Add Remove Software menu.
- Now in the Browse tab, select the Development from the left side panel and check the
- Eclipse in the right side list.
- Apply the settings.
- Eclipse along with its dependencies will be installed.
2. CDT setup in Eclipse:
- Now open the Eclipse IDE by selecting Application->Programming->Eclipse menu.
- First time, it might ask you to select/create a workspace. Do the needful.
- Now in the menu bar, select Help-> Software Update->Find and install.
- Now select the “Search for new features to install” radio button and click next.
- Now in the install screen, select New Remote Site.
- Give Name – CDT and URL =http://download.eclipse.org/tools/cdt/releases/callisto
- See the screenshot below:
3. Qemu Setup:
- Open a terminal
- su -
- eneter password
- yum install qemu
- type y after qemu installation in terminal type qemu to check installtion after that install kqemu.
- Download Kqemu kqemu-1.3.0pre11.tar.gz [same version that of qemu] either from the website: http://www.nongnu.org/qemu/download.html
- Now go to the Kquemu directory.
- Run following commands in sequence:
- ./configure
- make
- make install
- To make sure that kqemu is setup properly give the command “/sbin/modprobe kqemu”.
- If it doesn't give any output, your kqemu is installed properly.
B)Kernel Setup and Configuration:
1. Kernel Setup:
- Get the latest kernel source code version 2.6.30 from the CVS repository or from the URL http://www.kernel.org
- Unzip and untar the source code in your local directory. Give the following command: tar xvf linux-2.6.30.tar
- Now create an output directory:
- mkdir -p /mnt/build/linux-2.6
2. Setting up the Kernel Configuration
- Now change to your Kernel Source code directory where you have extracted it. For example, if you have downloaded it at /home/user/Desktop directory, then give the following command:
- cd /home/user/Desktop/linux-2.6.30
- Next, we'll configure the kernel. Issue the following command:
- create a directory as following
- su -
- mkdir -p /mnt/build/linux-2.6
- make oldconfig O=/mnt/build/linux-2.6
- Just keep pressing enter to use the default answers to all the questions that the kernel configuration program will ask you.
- Next , we enable the debugging options in the kernel configuration:
- make menuconfig O=/mnt/build/linux-2.6
- Now in the “Kernel Hacking” menu, enable both “Compile the kernel with debug info” and “Compile the kernel with frame pointers.”. After that issue the following command.
- make mrproper
C)Eclipse Kernel Project Setup:
- Now open the eclipse IDE.
- Start a new project, by using File->New->Project. Then select "C Project", "Makefile project", "Empty Project". (You might get this option as Standard Make C Project.)
- Now enter a project name and specify a specific directory for the project sourcecode. To do this, first uncheck the "Use default location" checkbox.
- Click finish.
- If you hadn't disabled indexing, Eclipse will now start indexing the Linux kernel sourcecode. This might take a long time.
- Once Eclipse finishes indexing the kernel sourcecode. We are ready to configure our debugger. Right-click on the project-name in the left pane (Project explorer) and select "Properties".
- Select the “C C++ Make Project” from the panel on the left side of the screen.
- Now Uncheck "Use default build command" and enter make O=/mnt/build/linux-2.6
- Modify the build location by clicking the "File system..." button and browsing to /mnt/build/linux-2.6
- Below this, you'll notice a frame named "Debugger Options"; click the "Connection" tab in this frame and modify the "Type" to "TCP" and the "Port number" to 1234. Continue by clicking the "Debug" button.
- Eclipse might compile and link a bit, but will finally launch the debugger and ask if you want to switch to the debugging perspective. Say yes.
- The next screenshot shows the debugging perspective. Just like with normal applications, you'll see that the line it is about the execute is highlighted.
- In your Eclipse, the control will be in start_kernel function. By using "Run->Step over" or pressing the "F6" key, you can execute the kernel code line by line and examine what's happening.
- If you want to see the assembly instructions which are being executed, you can add a view which displays this by selecting "Windows->Show View->Disassembly".