1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter 2. Compiling a kernel</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Using kgdb, kdb and the kernel debugger internals"><link rel="up" href="index.html" title="Using kgdb, kdb and the kernel debugger internals"><link rel="prev" href="Introduction.html" title="Chapter 1. Introduction"><link rel="next" href="CompileKDB.html" title="Kernel config options for kdb"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2. Compiling a kernel</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="Introduction.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="CompileKDB.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="CompilingAKernel"></a>Chapter 2. Compiling a kernel</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="CompilingAKernel.html#CompileKGDB">Kernel config options for kgdb</a></span></dt><dt><span class="sect1"><a href="CompileKDB.html">Kernel config options for kdb</a></span></dt></dl></div><p> 2 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>In order to enable compilation of kdb, you must first enable kgdb.</p></li><li class="listitem"><p>The kgdb test compile options are described in the kgdb test suite chapter.</p></li></ul></div><p> 3 </p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="CompileKGDB"></a>Kernel config options for kgdb</h2></div></div></div><p> 4 To enable <span class="symbol">CONFIG_KGDB</span> you should look under 5 "Kernel hacking" / "Kernel debugging" and select "KGDB: kernel debugger". 6 </p><p> 7 While it is not a hard requirement that you have symbols in your 8 vmlinux file, gdb tends not to be very useful without the symbolic 9 data, so you will want to turn 10 on <span class="symbol">CONFIG_DEBUG_INFO</span> which is called "Compile the 11 kernel with debug info" in the config menu. 12 </p><p> 13 It is advised, but not required, that you turn on the 14 <span class="symbol">CONFIG_FRAME_POINTER</span> kernel option which is called "Compile the 15 kernel with frame pointers" in the config menu. This option 16 inserts code to into the compiled executable which saves the frame 17 information in registers or on the stack at different points which 18 allows a debugger such as gdb to more accurately construct 19 stack back traces while debugging the kernel. 20 </p><p> 21 If the architecture that you are using supports the kernel option 22 CONFIG_DEBUG_RODATA, you should consider turning it off. This 23 option will prevent the use of software breakpoints because it 24 marks certain regions of the kernel's memory space as read-only. 25 If kgdb supports it for the architecture you are using, you can 26 use hardware breakpoints if you desire to run with the 27 CONFIG_DEBUG_RODATA option turned on, else you need to turn off 28 this option. 29 </p><p> 30 Next you should choose one of more I/O drivers to interconnect 31 debugging host and debugged target. Early boot debugging requires 32 a KGDB I/O driver that supports early debugging and the driver 33 must be built into the kernel directly. Kgdb I/O driver 34 configuration takes place via kernel or module parameters which 35 you can learn more about in the in the section that describes the 36 parameter "kgdboc". 37 </p><p>Here is an example set of .config symbols to enable or 38 disable for kgdb: 39 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p># CONFIG_DEBUG_RODATA is not set</p></li><li class="listitem"><p>CONFIG_FRAME_POINTER=y</p></li><li class="listitem"><p>CONFIG_KGDB=y</p></li><li class="listitem"><p>CONFIG_KGDB_SERIAL_CONSOLE=y</p></li></ul></div><p> 40 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="Introduction.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="CompileKDB.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 1. Introduction </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Kernel config options for kdb</td></tr></table></div></body></html> 41