Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > cf93d8a8acdcc6fe2225039da0502495 > files > 2249

kernel-doc-2.6.32-131.17.1.el6.centos.plus.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" 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=ANSI_X3.4-1968" /><title>Chapter&#160;6.&#160;KGDB Internals</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Using kgdb and the kgdb Internals" /><link rel="up" href="index.html" title="Using kgdb and the kgdb Internals" /><link rel="prev" href="ch05.html" title="Chapter&#160;5.&#160;kgdb Test Suite" /><link rel="next" href="re01.html" title="kgdb_skipexception" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;6.&#160;KGDB Internals</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="re01.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter&#160;6.&#160;KGDB Internals"><div class="titlepage"><div><div><h2 class="title"><a id="CommonBackEndReq"></a>Chapter&#160;6.&#160;KGDB Internals</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch06.html#kgdbArchitecture">Architecture Specifics</a></span></dt><dt><span class="sect1"><a href="ch06s02.html">kgdboc internals</a></span></dt></dl></div><div class="sect1" title="Architecture Specifics"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="kgdbArchitecture"></a>Architecture Specifics</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="re01.html"><span>kgdb_skipexception</span></a></span><span class="refpurpose"> &#8212; 
  (optional) exit kgdb_handle_exception early
 </span></dt><dt><span class="refentrytitle"><a href="re02.html"><span>kgdb_post_primary_code</span></a></span><span class="refpurpose"> &#8212; 
     (optional) Save error vector/code numbers.
 </span></dt><dt><span class="refentrytitle"><a href="re03.html"><span>kgdb_disable_hw_debug</span></a></span><span class="refpurpose"> &#8212; 
     (optional) Disable hardware debugging hook
 </span></dt><dt><span class="refentrytitle"><a href="re04.html"><span>kgdb_breakpoint</span></a></span><span class="refpurpose"> &#8212; 
     compiled in breakpoint
 </span></dt><dt><span class="refentrytitle"><a href="re05.html"><span>kgdb_arch_init</span></a></span><span class="refpurpose"> &#8212; 
     Perform any architecture specific initalization.
 </span></dt><dt><span class="refentrytitle"><a href="re06.html"><span>kgdb_arch_exit</span></a></span><span class="refpurpose"> &#8212; 
     Perform any architecture specific uninitalization.
 </span></dt><dt><span class="refentrytitle"><a href="re07.html"><span>pt_regs_to_gdb_regs</span></a></span><span class="refpurpose"> &#8212; 
     Convert ptrace regs to GDB regs
 </span></dt><dt><span class="refentrytitle"><a href="re08.html"><span>sleeping_thread_to_gdb_regs</span></a></span><span class="refpurpose"> &#8212; 
     Convert ptrace regs to GDB regs
 </span></dt><dt><span class="refentrytitle"><a href="re09.html"><span>gdb_regs_to_pt_regs</span></a></span><span class="refpurpose"> &#8212; 
     Convert GDB regs to ptrace regs.
 </span></dt><dt><span class="refentrytitle"><a href="re10.html"><span>kgdb_arch_handle_exception</span></a></span><span class="refpurpose"> &#8212; 
     Handle architecture specific GDB packets.
 </span></dt><dt><span class="refentrytitle"><a href="re11.html"><span>kgdb_roundup_cpus</span></a></span><span class="refpurpose"> &#8212; 
     Get other CPUs into a holding pattern
 </span></dt><dt><span class="refentrytitle"><a href="re12.html"><span>struct kgdb_arch</span></a></span><span class="refpurpose"> &#8212; 
     Describe architecture specific values.
 </span></dt><dt><span class="refentrytitle"><a href="re13.html"><span>struct kgdb_io</span></a></span><span class="refpurpose"> &#8212; 
     Describe the interface for an I/O driver to talk with KGDB.
 </span></dt></dl></div><p>
      Kgdb is organized into three basic components:
      </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>kgdb core</p><p>
      The kgdb core is found in kernel/kgdb.c.  It contains:
      </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>All the logic to implement the gdb serial protocol</p></li><li class="listitem"><p>A generic OS exception handler which includes sync'ing the processors into a stopped state on an multi cpu system.</p></li><li class="listitem"><p>The API to talk to the kgdb I/O drivers</p></li><li class="listitem"><p>The API to make calls to the arch specific kgdb implementation</p></li><li class="listitem"><p>The logic to perform safe memory reads and writes to memory while using the debugger</p></li><li class="listitem"><p>A full implementation for software breakpoints unless overridden by the arch</p></li></ul></div><p>
      </p></li><li class="listitem"><p>kgdb arch specific implementation</p><p>
      This implementation is generally found in arch/*/kernel/kgdb.c.
      As an example, arch/x86/kernel/kgdb.c contains the specifics to
      implement HW breakpoint as well as the initialization to
      dynamically register and unregister for the trap handlers on
      this architecture.  The arch specific portion implements:
      </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>contains an arch specific trap catcher which
      invokes kgdb_handle_exception() to start kgdb about doing its
      work</p></li><li class="listitem"><p>translation to and from gdb specific packet format to pt_regs</p></li><li class="listitem"><p>Registration and unregistration of architecture specific trap hooks</p></li><li class="listitem"><p>Any special exception handling and cleanup</p></li><li class="listitem"><p>NMI exception handling and cleanup</p></li><li class="listitem"><p>(optional)HW breakpoints</p></li></ul></div><p>
      </p></li><li class="listitem"><p>kgdb I/O driver</p><p>
      Each kgdb I/O driver has to provide an implemenation for the following:
      </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>configuration via builtin or module</p></li><li class="listitem"><p>dynamic configuration and kgdb hook registration calls</p></li><li class="listitem"><p>read and write character interface</p></li><li class="listitem"><p>A cleanup handler for unconfiguring from the kgdb core</p></li><li class="listitem"><p>(optional) Early debug methodology</p></li></ul></div><p>
      Any given kgdb I/O driver has to operate very closely with the
      hardware and must do it in such a way that does not enable
      interrupts or change other parts of the system context without
      completely restoring them. The kgdb core will repeatedly "poll"
      a kgdb I/O driver for characters when it needs input.  The I/O
      driver is expected to return immediately if there is no data
      available.  Doing so allows for the future possibility to touch
      watch dog hardware in such a way as to have a target system not
      reset when these are enabled.
      </p></li></ol></div><p>
      </p><p>
      If you are intent on adding kgdb architecture specific support
      for a new architecture, the architecture should define
      <code class="constant">HAVE_ARCH_KGDB</code> in the architecture specific
      Kconfig file.  This will enable kgdb for the architecture, and
      at that point you must create an architecture specific kgdb
      implementation.
      </p><p>
      There are a few flags which must be set on every architecture in
      their &lt;asm/kgdb.h&gt; file.  These are:
      </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
	  NUMREGBYTES: The size in bytes of all of the registers, so
	  that we can ensure they will all fit into a packet.
	  </p><p>
	  BUFMAX: The size in bytes of the buffer GDB will read into.
	  This must be larger than NUMREGBYTES.
	  </p><p>
	  CACHE_FLUSH_IS_SAFE: Set to 1 if it is always safe to call
	  flush_cache_range or flush_icache_range.  On some architectures,
	  these functions may not be safe to call on SMP since we keep other
	  CPUs in a holding pattern.
	  </p></li></ul></div><p>
      </p><p>
      There are also the following functions for the common backend,
      found in kernel/kgdb.c, that must be supplied by the
      architecture-specific backend unless marked as (optional), in
      which case a default function maybe used if the architecture
      does not need to provide a specific implementation.
      </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="re01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;5.&#160;kgdb Test Suite&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span>kgdb_skipexception</span></td></tr></table></div></body></html>