⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdb_snippets.html

📁 ADI 公司blackfin系列的用户使用文挡。
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>  <title></title>  <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />  <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />  <link rel="stylesheet" media="print" type="text/css" href="./print.css" />  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="level1"><div class="li"><span class="li"><a href="#gdb_debug_snippets" class="toc">GDB Debug Snippets</a></span></div><ul class="toc"><li class="clear"><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#dump_peripheral_registers" class="toc">Dump Peripheral Registers</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#dump_kernel_log_buffer" class="toc">Dump Kernel Log Buffer</a></span></div></li></ul></li></ul></li></ul></div></div><h1><a name="gdb_debug_snippets" id="gdb_debug_snippets">GDB Debug Snippets</a></h1><div class="level1"><p> Debugging with gdb can be augmented greatly via the user of gdb scripts.  The <a href="http://sources.redhat.com/gdb/current/onlinedocs/gdb_toc.html" class="urlextern" title="http://sources.redhat.com/gdb/current/onlinedocs/gdb_toc.html"  rel="nofollow">GDB manual</a> covers all of this in depth, so this document will contain a bunch of useful snippets.</p><p>To load a script at runtime, you can name it <code>.gdbinit</code> and place it in the directory you execute gdb.  Another way is to use the <code>-x</code> option and specify the script to load automatically.</p><p>Note that some of these may make sense only when running with <a href="kgdb.html" class="wikilink1" title="kgdb.html">kgdb</a>.</p></div><!-- SECTION [1-543] --><h3><a name="dump_peripheral_registers" id="dump_peripheral_registers">Dump Peripheral Registers</a></h3><div class="level3"><pre class="code">define info-uart    # only show read-destructive registers if user requests them ...    set $UART_DESTROY = ($argc &gt; 1)    set $UART_BASE = $arg0    set $UART_RBR = $UART_BASE + 0x0000    set $UART_DLL = $UART_BASE + 0x0000    set $UART_IER = $UART_BASE + 0x0004    set $UART_DLH = $UART_BASE + 0x0004    set $UART_IIR = $UART_BASE + 0x0008    set $UART_LCR = $UART_BASE + 0x000C    set $UART_MCR = $UART_BASE + 0x0010    set $UART_LSR = $UART_BASE + 0x0014    set $UART_SCR = $UART_BASE + 0x001C    set $UART_GCTL = $UART_BASE + 0x0024    set $UART_LCR_VAL = *(unsigned short*)$UART_LCR    set $UART_LCR_DLAB_0 = 0xF7    set $UART_LCR_DLAB_1 = 0xFF    printf &quot;Showing UART Registers at 0x%X\n&quot;, $UART_BASE    set *(unsigned short*)$UART_LCR = $UART_LCR_VAL &amp; $UART_LCR_DLAB_0    printf &quot; RBR: &quot;    x/1th $UART_RBR    printf &quot; IER: &quot;    x/1th $UART_IER    set *(unsigned short*)$UART_LCR = $UART_LCR_VAL &amp; $UART_LCR_DLAB_1    printf &quot; DLL: &quot;    x/1th $UART_DLL    printf &quot; DLH: &quot;    x/1th $UART_DLH    set *(unsigned short*)$UART_LCR = $UART_LCR_VAL    if $UART_DESTROY        printf &quot; IIR: &quot;        x/1th $UART_IIR    else        printf &quot; IIR: &lt;skipped destructive read&gt;&quot;    end    printf &quot; LCR: &quot;    x/1th $UART_LCR    printf &quot; MCR: &quot;    x/1th $UART_MCR    if $UART_DESTROY        printf &quot; LSR: &quot;        x/1th $UART_LSR    else        printf &quot; LSR: &lt;skipped destructive read&gt;&quot;    end    printf &quot; SCR: &quot;    x/1th $UART_SCR    printf &quot; GCTL: &quot;    x/1th $UART_GCTLenddefine info-uart0    set $UART0_BASE = 0xFFC00400    info-uart $UART0_BASE ($argc &gt; 0)enddefine info-uart1    set $UART1_BASE = 0xFFC02000    info-uart $UART1_BASE ($argc &gt; 0)end</pre></div><!-- SECTION [544-2305] --><h3><a name="dump_kernel_log_buffer" id="dump_kernel_log_buffer">Dump Kernel Log Buffer</a></h3><div class="level3"><p> The kernel stores all of its printk() output in a circular buffer, so displaying this buffer properly requires a bit more work than just writing it as a string from the start.</p><pre class="code">define dump-dmesg    set $start = log_start    set $end = log_end    set $buf = log_buf    set $mask = log_buf_len - 1    while ($start != $end)        set $c = $buf[$start &amp; $mask]        set $start = $start + 1        printf &quot;%c&quot;, $c    end    printf &quot;\n&quot;end</pre></div><!-- SECTION [2306-] --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -