© Daniela Mangiuca, 123RF.com

© Daniela Mangiuca, 123RF.com

Debugging the Linux kernel with the Qemu emulator

Debugger

Article from ADMIN 07/2012
By , By
Debugging the kernel of a running operating system has always been tricky, but now the Qemu emulator supports cross-platform kernel and module debugging at the programming language level.

Some of the basic operations that a debugger supports include freezing code sequences and subsequently analyzing memory content. If the code sequences belong to an application, debugging is comparatively unproblematic, but if you freeze the kernel itself, you don't have a run-time environment that accepts keyboard input, outputs data to the monitor, accesses memory content, or continues running the kernel later on. You could almost compare kernel debugging with trying to operate on yourself.

From a technical point of view, this problem is solved by offloading complex functions to a second system, which will typically have working memory and file management and help you search the source code for variables, data structures, functions, and lines of code. This means you only need a debug server for the kernel that you want to debug; the server can execute simple commands, such as reading or writing memory cells or setting breakpoints, on the system under investigation.

The Qemu emulator has a built-in debug server (see the "Kernel Debugging Variants" boxout). If you also use the Buildroot [1] system generator, kernel debugging is comparatively simple to implement. The precondition for doing so is having a kernel with symbol information. This isn't an issue thanks to Buildroot: Within a short time, the tool can give you a clear-cut userspace and a lean kernel that you can quickly reconfigure and modify.

Kernel Debugging Variants

Linux gives developers three approaches to debugging kernel and module code in the form of Qemu, kgdb, and kdb (Figure 1). Although Qemu doesn't need any special support in the kernel, Linus Torvalds grudgingly accepted the in-kernel debug server kgdb three years ago. Just as with the Qemu

...
Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=