Device Drivers Part 10
Device Drivers Part 10
Device Drivers Part 10
Device Drivers, Part 10: Kernel-Space Debuggers in Linux - LINUX For You
Subscribe to Print Edition Search
HOME
REVIEWS
HOW-TOS
CODING
INTERVIEWS
FEATURES
OVERVIEW
BLOGS
SERIES
IT ADMIN
Search for:
Search
This article, which is part of the series on Linux device drivers, talks about kernel-space debugging in Linux.
Shweta, back from hospital, was relaxing in the library, reading various books. Ever since she learned of the i o c t lway of debugging, she was impatient to find out more about debugging in kernel-space. She was curious about how and where to run the kernel-space debugger, if there was any. This was in contrast with application/user-space debugging, where we have the OS running underneath, and a shell or a GUI over it to run the debugger (like g d b , and the data display debugger, d d d ). Then she came across this interesting kernel-space debugging mechanism using k g d b , provided as part of the kernel itself, since kernel 2.6.26.
Follow
+2,489
www.linuxforu.com/2011/09/kernel-space-debuggers-in-linux/
1/4
8/13/13
Device Drivers, Part 10: Kernel-Space Debuggers in Linux - LINUX For You
Find us on Facebook
meaningful. C O N F I G _ F R A M E _ P O I N T E R = yenables frame pointers in the kernel, allowing g d bto construct more accurate stack back-traces. All these options are available under Kernel hacking in the menu obtained in the kernel source directory (preferably as root, or using s u d o ), by issuing the following command:
$m a k em r p r o p e r $m a k eo l d c o n f i g $m a k em e n u c o n f i g #T oc l e a nu pp r o p e r l y #C o n f i g u r et h ek e r n e ls a m ea st h ec u r r e n tr u n n i n go n e #S t a r tt h en c u r s e sb a s e dm e n uf o rf u r t h e rc o n f i g u r a t i o n
Popular
Comments
Tag cloud
See the highlighted selections in Figure 1, for how and where these options would be: KGDB: kernel debugging with remote gdb > C O N F I G _ K G D B KGDB: use kgdb over the serial console > C O N F I G _ K G D B _ S E R I A L _ C O N S O L E Compile the kernel with debug info > C O N F I G _ D E B U G _ I N F O Compile the kernel with frame pointers > C O N F I G _ F R A M E _ P O I N T E R Once configuration is saved, build the kernel (run m a k e ), and then a m a k ei n s t a l lto install it, along with adding an entry for the installed kernel in the GRUB configuration file. Depending on the distribution, the GRUB configuration file may be / b o o t / g r u b / m e n u . l s t ,/ e t c / g r u b . c f g , or something similar. Once installed, the k g d b r e l a t e dkernel boot parameters need to be added to this new entry, as shown in the highlighted text in Figure 2.
k g d b o cis for g d bconnecting over the console, and the basic format is k g d b o c = < s e r i a l _ d e v i c e > ,< b a u d r a t e >where: < s e r i a l _ d e v i c e >is the serial device file (port) on the system running the kernel to be
debugged
< b a u d r a t e >is the baud rate of this serial port k g d b w a i ttells the kernel to delay booting till a g d bclient connects to it; this parameter should
be given only after k g d b o c . With this, were ready to begin. Make a copy of the v m l i n u xkernel image for use on the g d b
www.linuxforu.com/2011/09/kernel-space-debuggers-in-linux/
2/4
8/13/13
g d bto connect over the serial port.
Device Drivers, Part 10: Kernel-Space Debuggers in Linux - LINUX For You
client system. Reboot, and at the GRUB menu, choose the new kernel, and then it will wait for
All the above snapshots are with kernel version 2.6.33.14. The same should work for any 2.6.3x release of the kernel source. Also, the snapshots for k g d bare captured over the serial device file / d e v / t t y S 0 , i.e., the first serial port.
In the above commands, v m l i n u xis the kernel image copied from the system to be debugged.
Summing up
By now, Shweta was excited about wanting to try out k g d b . Since she needed two systems to try it out, she went to the Linux device drivers lab. There, she set up the systems and ran g d bas described above.
Related Posts:
KGDB with VirtualBox: Debug a Live Kernel Kernel Tracing with ftrace, Part 1 Kernel Development & Debugging Using the Eclipse IDE Install Linux from USB on System without BIOS Support for USB Boot Device Drivers, Part 3: Kernel C Extras in a Linux Driver
Tags: boot screen, configuration file, debug, Debugging, Ethernet, GDB, GUI, kdb, kernel, kernel debugger, kernel source, kernel space, kgdb project, LFY September 2011, Linux, linux device drivers, Linux Device Drivers Series, Linux kernel, network interface, patches, serial interface, serial port, shell, source code
Previous Post
Next Post
www.linuxforu.com/2011/09/kernel-space-debuggers-in-linux/
3/4
8/13/13
Reviews How-Tos Coding
Device Drivers, Part 10: Kernel-Space Debuggers in Linux - LINUX For You
Interviews Features Overview Blogs
Search
Popular tags
Linux , ubuntu, Java, MySQL, Google, python, Fedora, Android, PHP, C, html, w eb applications , India, Microsoft, unix , Window s , Red Hat, Oracle, Security , Apache, xml, LFY April 2012, FOSS, GNOME, http, JavaScript, LFY June 2011, open source, RAM, operating systems
All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherw ise noted. LINUX For You is pow ered by WordPress, w hich gladly sits on top of a CentOS-based LEMP stack.
www.linuxforu.com/2011/09/kernel-space-debuggers-in-linux/
4/4