Use kgdb for Linux kernel debugging (unfinished !)

Source: Internet
Author: User
Tags gz file

Linux kernel debugging


This article describes how to debug the Linux kernel. Our environment is as follows:

HOST: Ubuntu 11.04

Virtual Machine: ubuntu11.04 of virtualbox


First, make the following preparations:

1.

To share files between the host and the virtual machine, I use samba, see http://blog.csdn.net/htttw/article/details/7216149

2.

Host and virtual machine can communicate through serial port, see: http://blog.csdn.net/htttw/article/details/7221510



This experiment is equivalent to a small summary of the previous experiment ~~



After preparation, you can start:



1.

First, we need to prepare the initrd.gz file system, such as bzimageand busybox. for details about how to create the file, refer:

Http://blog.csdn.net/htttw/article/details/7215858


Here we in order to speed up the compilation of bzimage, so the Linux kernel is streamlined, specific reference: http://blog.csdn.net/htttw/article/details/7262239



2.

Enable minicon on the host:

Minicon



3.

After the two files in step 1 are ready, you can start the VM. The GRUB menu appears. In the previous experiment, press "c" to enter the grub command mode, and then enter "Linux ", "initrd" is used to specify the kernel image and file system. This is not enough for this experiment. We also need to send the output information of the virtual machine to our host through the serial port, however, I have been exploring for a long time and still have not found how to set the serial port command in grub command mode. So, let's change to another method:

Select a menu item from the GRUB menu, press "E" to edit the menu item, delete all the original commands, and enter the following statement:

linux /boot/bzImage console=tty0 console=ttyS0, 115200initrd /boot/initrd.gz

Then press F10.



4.

In this way, the VM output information from the serial port will appear in our minicom host ~~

In addition, after the VM enters busybox, you can directly operate the VM by entering commands in the minicom of the VM ,~~


All the above operations are completed in the minicom of the host.


5





Because my notebook does not have a serial port, an error occurs when you execute target remote/dev/ttys0 in GDB! Error message:/dev/ttys0 input/output error, so we can redirect the named pipe/tmp/vbox to a port. Then we can use the socat command:

Sudo apt-Get install socat
Socat tcp4-listen: 8888/tmp/vbox

Redirects the output of the named pipe/tmp/vbox to port 8888 of TCP.

Then input the following in GDB:

Set remotebaud 115200

Target remote TCP: localhost: 8888

You can.

Next?


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.