<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 2. Compiling a kernel</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.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><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" title="Chapter 2. Compiling a kernel"><div class="titlepage"><div><div><h2 class="title"><a id="CompilingAKernel"></a>Chapter 2. Compiling a kernel</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><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>
  </p><div class="itemizedlist"><ul class="itemizedlist" 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>
  </p><div class="sect1" title="Kernel config options for kgdb"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="CompileKGDB"></a>Kernel config options for kgdb</h2></div></div></div><p>
    To enable <span class="symbol">CONFIG_KGDB</span> you should first turn on
    "Prompt for development and/or incomplete code/drivers"
    (CONFIG_EXPERIMENTAL) in  "General setup", then under the
    "Kernel debugging" select "KGDB: kernel debugger".
    </p><p>
    While it is not a hard requirement that you have symbols in your
    vmlinux file, gdb tends not to be very useful without the symbolic
    data, so you will want to turn
    on <span class="symbol">CONFIG_DEBUG_INFO</span> which is called "Compile the
    kernel with debug info" in the config menu.
    </p><p>
    It is advised, but not required that you turn on the
    <span class="symbol">CONFIG_FRAME_POINTER</span> kernel option which is called "Compile the
    kernel with frame pointers" in the config menu.  This option
    inserts code to into the compiled executable which saves the frame
    information in registers or on the stack at different points which
    allows a debugger such as gdb to more accurately construct
    stack back traces while debugging the kernel.
    </p><p>
    If the architecture that you are using supports the kernel option
    CONFIG_DEBUG_RODATA, you should consider turning it off.  This
    option will prevent the use of software breakpoints because it
    marks certain regions of the kernel's memory space as read-only.
    If kgdb supports it for the architecture you are using, you can
    use hardware breakpoints if you desire to run with the
    CONFIG_DEBUG_RODATA option turned on, else you need to turn off
    this option.
    </p><p>
    Next you should choose one of more I/O drivers to interconnect
    debugging host and debugged target.  Early boot debugging requires
    a KGDB I/O driver that supports early debugging and the driver
    must be built into the kernel directly. Kgdb I/O driver
    configuration takes place via kernel or module parameters which
    you can learn more about in the in the section that describes the
    parameter "kgdboc".
    </p><p>Here is an example set of .config symbols to enable or
    disable for kgdb:
    </p><div class="itemizedlist"><ul class="itemizedlist" 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>
    </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>
