📄 c-debugger3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Debugger </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-debugger.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-debugger2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-debugger4.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="90445">8.3 Using the Debugger</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="90447"> </a>The debugger allows you to download object modules, to start routines under debugger control, and to take over existing tasks in the target. Tasks under debugger control execute normally until they terminate, unless they encounter a breakpoint, or you interrupt them, or some other event sends them an interrupt or a signal.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/warning.gif"></td><td><hr><div class="CalloutCell"><a name="91887"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">WARNING: </font></b></a>You must compile your application using debugging symbols (the <b class="command">-g </b>GNU compiler option) to use many of the features of the debugger. The default compiler settings used by the Tornado project facility include debugging symbols.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="83930">8.3.1 Starting and Stopping the Debugger</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="83933"> </a>There are two ways to start a debugging session:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="83937"> </a>From the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Tornado Launch</font></b> toolbar: Press the <img class="figure" border="0" src="images/c-debuggera3.gif"> button. This starts a debugging session for the currently selected target server (see Tornado Launch Toolbar, p.98).</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="83941"> </a>From the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Tools</font></b> menu: Click on <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debugger</font></b>. The dialog box shown in <a href="c-debugger3.html#83950">Figure 8-3</a> appears, to allow you to select a target server from the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Targets</font></b> drop-down list.<div class="frame"><h4 class="EntityTitle"><a name="83950"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 8-3: Debugger Target-Selection Dialog Box</font></a></h4><dl class="margin"><div class="Anchor"><a name="83947"> </a><img class="figure" border="0" src="images/c-debuggera5.gif"></div></dl></div></li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="83951"> </a>When the debugger is running, you can interact with it through the editor window, through the debugger command line window, and through the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debug</font></b> menu and toolbar. (See <a href="c-debugger2.html#90684"><i class="title">8.2 Debugger GUI</i></a>.)</p><dd><p class="Body"><a name="83956"> </a>You can end the debugging session in any of the following ways:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="83961"> </a>In the debug toolbar, press the <img class="figure" border="0" src="images/c-debuggera7.gif"> button. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="83963"> </a>Click on the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Stop Debugging</font></b> command in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debug</font></b> menu.</li></ul></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84322">8.3.2 Setting the Search Path</a></i></h4></font><dl class="margin"><dl class="margin"><dd><div class="Item"><a name="94013"> </a><p class="table"><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="84299"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Button</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84301"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Shortcut</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84303"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Debug Menu Command</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="84311"> </a>n/a</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="84313"> </a><kbd>ALT+D</kbd> <kbd>h</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="84315"> </a><b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Source Search Path</font></b></div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></div></dl><dl class="margin"><dd><p class="Body"><a name="84324"> </a>The debugger maintains a list of directories where it searches for source code, and for the host-resident image of the VxWorks run-time (the debugger uses the latter to load debugging symbol information generated by the <b class="command">-g</b> compiler option). This list is called the <i class="term">source search path</i>. </p><dd><p class="Body"><a name="91125"> </a>Normally you will not need to set the source search path because the debugger can derive the path from the object file. If GDB finds the object but cannot find the source, the GUI prompts you for the source file location and remembers it. </p><dd><p class="Body"><a name="91126"> </a>If necessary, click on <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Source Search Path</font></b> to add directories to, remove directories from, or change the order of this list. <a href="c-debugger3.html#84337">Figure 8-4</a> illustrates the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debugger Source Search Path</font></b> dialog box.<div class="frame"><h4 class="EntityTitle"><a name="84337"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 8-4: Debugger Source Search Path Dialog Box</font></a></h4><dl class="margin"><div class="Anchor"><a name="84334"> </a><img class="figure" border="0" src="images/c-debugger25.gif"></div></dl></div></p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/warning.gif"></td><td><hr><div class="CalloutCell"><a name="91908"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">WARNING: </font></b></a>Do not leave more than one directory containing a run-time core image in the search path. The debugger uses the first of these it encounters; if it is not the correct core image, the results are unpredictable, and the debugging session may hang.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="94257">8.3.3 Unloading a Module</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="94259"> </a>Normally you will not need to unload a module. If you update and download a module with the same name, it replaces the module loaded earlier. In the unusual case where you need to unload a module without replacing it, use unload option from the context menu in the project <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Workspace</font></b> window (see <a href="c-builder2.html#88881"><i class="title">4.2.5 Downloading and Running an Application</i></a>).</p><dd><p class="Body"><a name="93604"> </a>You can also use the debugger command line to remove any dynamically-linked module from the target. Open the debug command-line window and use the GDB <b class="command">unload</b> command. See <a href="c-debugger5.html#85154"><i class="title">8.5 Using the Debugger Command Line</i></a> for more information about command line usage. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="93636">8.3.4 Running a Program</a></i></h4></font><dl class="margin"><dl class="margin"><dd><div class="Item"><a name="94014"> </a><p class="table"><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="93622"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Button</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="93624"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Shortcut</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="93626"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Debug Menu Command</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="93631"> </a><img class="figure" border="0" src="images/c-debuggera35.gif"></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93633"> </a><kbd>F6</kbd></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93635"> </a><b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Run</font></b></div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></div></dl><dl class="margin"><dd><p class="Body"><a name="89341"> </a>To run a subroutine under debugger control, use the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Run</font></b> command. The <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Run Task</font></b> dialog box appears; use it to specify which routine to run, with what arguments. Click <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">OK</font></b> to start the task on the target.<div class="frame"><h4 class="EntityTitle"><a name="89293"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 8-5: Run Task Dialog Box</font></a></h4><dl class="margin"><div class="Anchor"><a name="89298"> </a><img class="figure" border="0" src="images/c-debugger14.gif"></div></dl></div></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -