📄 c-debugger6.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-debugger5.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-debugger7.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="85341">8.6 System-Mode Debugging</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85343"> </a>By default, in Tornado you debug only one task at a time. The task is selected either by using the <b class="command">run</b> dialog box to create a new task, or by using the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Attach</font></b><b class="command"> </b>dialog box (<a href="c-debugger3.html#84608"><i class="title">8.3.8 Attaching to a Running Task</i></a>) to debug an existing task. When the debugger is attached to a task, debugger commands affect only that particular task. For example, breakpoints apply only to that task. When the task reaches a breakpoint, only that task stops, not the entire system. This form of debugging is called <i class="term">task mode</i>.</p><dd><p class="Body"><a name="85348"> </a>Tornado also supports an alternate form of debugging, where you can switch among multiple tasks (also called <i class="term">threads</i>) and even examine execution in system routines such as ISRs. This alternative mode is called <i class="term">system mode</i> debugging; it is also sometimes called <i class="term">external mode</i>. </p><dd><p class="Body"><a name="85350"> </a>Most of the debugger features described elsewhere in this manual, and the debugging commands described in <i class="title">Debugging with GDB</i>, are available regardless of which debugging mode you select. However, certain debugging commands (discussed below in <a href="c-debugger6.html#85374"><i class="title">8.6.2 Thread Facilities in System Mode</i></a>) are useful only in system mode.</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/caution.gif"></td><td><hr><div class="CalloutCell"><a name="92068"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION: </font></b></a>The <b class="command">run</b> command is not available in system mode, because its use of a new subordinate task is more intrusive in that mode. In system mode, use the shell to start new tasks as discussed in <a href="c-shell2.html#91110"><i class="title">6.2.6 Using the Shell for System Mode Debugging</i></a>, then attach to them with the <b class="command">thread</b> command.</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="85360">8.6.1 Entering System Mode</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85361"> </a>To debug in system mode, click on the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">System</font></b> entry displayed in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Attach</font></b> dialog box (use the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Attach</font></b> command in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debug</font></b> menu to display the dialog box).</p><dd><p class="Body"><a name="85362"> </a>You can also switch to system mode from the debugger window or an initialization file, but first make sure your debugger session is not attached to any task (type <b class="command">detach</b>). Then issue the following command:</p></dl><dl class="margin"><dd><div class="Item"><a name="85364"> </a><b class="command">attach system</b> </div><dl class="margin"><dd><div class="Indent"><a name="86130"> </a>Switches the target connection into system mode (if supported by the target agent) and stops the entire target system. </div><br></dl></dl><dl class="margin"><dd><p class="Body"><a name="85365"> </a>The response to a successful <b class="command">attach system</b> is output similar to the following:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85366"></b><tt class="output">(gdb) </tt><b>attach system </b><tt class="output">Attaching to system. 0x5b58 in wdbSuspendSystemHere ()</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85367"> </a>Once in system mode, the entire target system stops. In the example above, the system stopped in <b class="routine"><i class="routine">wdbSuspendSystemHere</i></b><b>( )</b>, the normal suspension point after <b class="command">attach system</b>.</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="92090"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">WARNING: </font></b></a>Not all targets support system mode, because the BSP must include a special driver for that purpose (see <a href="c-builder6.html#99096"><i class="title">4.6 Configuring the Target-Host Communication Interface</i></a>). If your target does not support system mode, attempting to use <b class="command">attach system</b> produces an error.</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="85374">8.6.2 Thread Facilities in System Mode</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85376"> </a>In system mode, the GDB thread-debugging facilities become useful. <i class="term">Thread</i> is the general term for processes with some independent context, but a shared address space. In VxWorks, each task is a thread. The system context (including ISRs and drivers) is also a thread. GDB identifies each thread with a <i class="term">thread ID</i>, a single arbitrary number internal to the debugger. </p><dd><p class="Body"><a name="85378"> </a>You can use the following GDB commands to manage threads: </p></dl><dl class="margin"><dd><div class="Item"><a name="85380"> </a><b class="command">info threads</b> </div><dl class="margin"><dd><div class="Indent"><a name="86132"> </a>Displays summary information (including thread ID) for every thread in the target system.</div><br></dl><dd><div class="Item"><a name="85382"> </a><b class="command">thread</b> <i class="textVariable">idNo</i> </div><dl class="margin"><dd><div class="Indent"><a name="86134"> </a>Selects the specified thread as the current thread.</div><br></dl><dd><div class="Item"><a name="85384"> </a><b class="command">break </b><i class="textVariable">linespec</i><b class="command"> thread </b><i class="textVariable">idNo</i> </div><dl class="margin"><dd><div class="Indent"><a name="85385"> </a>Sets a breakpoint affecting only the specified thread.</div><br></dl></dl><dl class="margin"><dd><p class="Body"><a name="85386"> </a>For a general description of these commands, see <i class="title">Debugging with GDB: Debugging Programs with Multiple Threads</i>. The sections below discuss the thread commands in the context of debugging a VxWorks target in system mode.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85387">Displaying Summary Thread Information</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85388"> </a><b class="command"></b>The command <b class="command">info threads</b> shows what thread ID corresponds to which VxWorks task. For example, immediately after attaching to the system, the <b class="command">info threads</b> display resembles the following:</p><dl class="margin"><dd><pre class="Code2"><b><a name="92875"></b><tt class="output">(gdb) </tt><b>info threads </b><tt class="output"> 4 task 0x4fc868 tExcTask 0x444f58 in ?? () 3 task 0x4f9f40 tLogTask 0x444f58 in ?? () 2 task 0x4c7380 + tNetTask 0x4151e0 in ?? () 1 task 0x4b0a24 tWdbTask 0x4184fe in ?? () (gdb)</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85390"> </a>In the <b class="command">info threads</b> output, the left-most number on each line is the debugger's thread ID. The single asterisk (<b>*</b>) at the left margin indicates which thread is the <i class="term">current thread</i>. The current thread identifies the "most local" perspective: debugger commands that report task-specific information, such as <b class="command">bt</b> and <b class="command">info regs</b> (as well as the corresponding debugger displays) apply only to the current thread.</p><dd><p class="Body"><a name="85391"> </a>The next two columns in the thread list show the VxWorks task ID and the task name. If the system context is shown, the single word <b class="keyword">system</b> replaces both of these columns. The thread (either a task, or the system context) currently scheduled by the kernel is marked with a <b class="operator">+</b> to the right of the task identification. </p></dl>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -