Linux kernel Tracing (trace) (QEMU+GDB)

Source: Internet
Author: User

1. Introduction

Linux kernel is a very large module, if you just look at the source code sometimes difficult to understand some of the Linux kernel design situation, if you can combine the Linux kernel to run the same time to read the source, this article is about the Linux kernel tracking method, The tools are used for the QEMU emulator and GDB tools.

2. Prerequisites

(1) Tools : Need to use the QEMU emulator and GDB, in the default Linux distribution basically have GDB tools, and for the QEMU simulator you need to download the installation, you can use the QEMU source installation, more trouble, not recommended to use, You can use the Package Manager in the Linux distribution to download and install, use the Apt-get Install command for Ubuntu and Debian, and install the Yum Package Manager for CentOS and Federa, install the QEMU emulator under Ubuntu, The name of the corresponding package can be searched in http://packages.ubuntu.com/

(2) Linux kernel Source: in order to trace the Linux kernel, you need to compile a new Linux kernel yourself, linux kernel download website https://www.kernel.org/, The kernel of the specific compilation method in the Linux kernel source code compression package Readme file is introduced

(3) image file: download an ubuntu ISO file (or another Linux distribution ISO file), use QEMU to create an Ubuntu image, create a process for

A) qemu-img create-f qcow2 ubuntu.img 10G (Details of the various parameters are shown in Qemu-img's manual)

b) Qemu-i386-hda Ubuntu.img-cdrom ~/documents/ubuntu-14.10-desktop-i386.iso

3. Start QEMU Trace kernel

(1) start the QEMU emulator:qemu-system-i386-kernel linux-build/arch/i386/boot/bzimage-hda ubuntu.img-append "Root=/dev /SDA1 "-S

(2) start Gdbserver: switch to QEMU emulator, alt+ctrl+2, start Gdbserver, listen port 1234 (Gdbserver tcp::1234)

(3) Start gdb: gdb./vmlinux, then link on gdbserver under gdb command condition, target remote localhost:1234

4. Start tracing the kernel

Use GDB's basic common commands, step, break, etc. (other specific commands can refer to the GDB manual). At this point you can view the system running some kernel parameters and system status information, combined with the source code, to view the system's operational status

Linux kernel Tracing (trace) (QEMU+GDB)

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.