1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>4.3.�Running Applications from GDB</title><link rel="stylesheet" type="text/css" href="cs.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.0"><link rel="home" href="index.html" title="Sourcery CodeBench Lite"><link rel="up" href="chap-building.html" title="Chapter�4.�Using Sourcery CodeBench from the Command Line"><link rel="prev" href="ch04s02.html" title="4.2.�Running Applications on the Target System"><link rel="next" href="sec-cs.html" title="4.4.�Using the Compiler Cache"></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">4.3.�Running Applications from GDB</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s02.html">Prev</a>�</td><th width="60%" align="center">Chapter�4.�Using Sourcery CodeBench from the Command Line</th><td width="20%" align="right">�<a accesskey="n" href="sec-cs.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-remote-debugging"></a>4.3.�Running Applications from GDB</h2></div></div></div><p> 2 You can run GDB, the GNU Debugger, on your host system 3 to debug programs running remotely on a target board or system. 4 5 6 </p><p> 7 When starting GDB, give it the pathname to the program you want to 8 debug as a command-line argument. 9 For example, if you have built the factorial program as described in 10 <a class="xref" href="chap-building.html#sec-factorial-build" title="4.1.�Building an Application">Section�4.1, “Building an Application”</a>, enter: 11 </p><pre class="screen">> arm-none-eabi-gdb factorial</pre><p> 12 13 </p><p> 14 While this section explains the alternatives for using GDB to run 15 and debug application programs, explaining the use of the GDB 16 command-line interface is beyond the scope of this document. Please 17 refer to the GDB manual for further instructions. 18 </p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="connecting-to-gdbserver"></a>4.3.1.�Connecting to an External GDB Server</h3></div></div></div><p> 19 From within GDB, you can connect to a running <code class="command">gdbserver</code> 20 or other debugging stub that uses the GDB remote protocol using: 21 </p><pre class="screen">(gdb) target remote <em class="replaceable"><code>host</code></em>:<em class="replaceable"><code>port</code></em></pre><p> 22 where <em class="replaceable"><code>host</code></em> is the host name or IP address of the 23 machine the stub is running on, and <em class="replaceable"><code>port</code></em> is the 24 port number it is listening on for TCP connections. 25 </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="idm46915333664464"></a>4.3.2.�Loading and Running Applications</h3></div></div></div><p> 26 Connecting to a bare-metal target or simulator from GDB does not 27 cause your program to be loaded into target memory. 28 You must do this explicitly from GDB after you connect: 29 </p><pre class="screen">(gdb) load</pre><p> 30 31 Alternatively, you can use third-party tools to load your application 32 into flash memory before starting GDB. 33 </p><p> 34 To begin execution of your application, you should generally use the 35 <code class="command">continue</code> command: 36 </p><pre class="screen">(gdb) continue</pre><p> 37 38 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s02.html">Prev</a>�</td><td width="20%" align="center"><a accesskey="u" href="chap-building.html">Up</a></td><td width="40%" align="right">�<a accesskey="n" href="sec-cs.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.2.�Running Applications on the Target System�</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">�4.4.�Using the Compiler Cache</td></tr></table></div></body></html> 39