c-debugger6.html

来自「vxworks相关论文」· HTML 代码 · 共 401 行 · 第 1/2 页

HTML
401
字号
</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="92111"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION:  </font></b></a>The thread ID of the system thread is not constant. To identify the system thread at each suspension, you must use <b class="command">info threads</b> whenever the debugger regains control, in order to see whether the system thread is present and, if so, its current ID.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="85393"> </a>The remainder of each line in the <b class="command">info threads</b> output shows a summary of each thread's current stack frame: the program counter value and the corresponding routine name.</p><dd><p class="Body"><a name="85394"> </a>The thread ID is required to specify a particular thread with commands such as <b class="command">break</b> and <b class="command">thread</b>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85396">Switching Threads Explicitly</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85398"> </a><b class="command"></b>To switch to a different thread (making that thread the current one for debugging, but without affecting kernel task scheduling), use the <b class="command">thread</b> command. For example: </p><dl class="margin"><dd><pre class="Code2"><b><a name="85399"></b><tt class="output">(gdb) </tt><b>thread 2 </b><tt class="output">[Switching to task 0x3a4bd8   tShell    ] #0  0x66454 in semBTake () (gdb) </tt><b>bt </b><tt class="output">#0  0x66454 in semBTake () #1  0x66980 in semTake () #2  0x63a50 in tyRead () #3  0x5b07c in iosRead () #4  0x5a050 in read () #5  0x997a8 in ledRead () #6  0x4a144 in execShell () #7  0x49fe4 in shell () (gdb) </tt><b>thread 3 </b><tt class="output">[Switching to task 0x3aa9d8   tFtpdTask ] #0  0x66454 in semBTake () (gdb) </tt><b>print/x $i0 </b><tt class="output">$3 = 0x3bdb50</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85400"> </a>As in the display shown above, each time you switch threads the debugger exhibits the newly current thread's task ID and task name.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85401">Thread-Specific Breakpoints</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85403"> </a><b class="command"></b>In system mode, unqualified breakpoints (set with graphical controls on the editor window, or in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debugger</font></b> window with the <b class="command">break</b> command and a single argument) apply globally: any thread stops when it reaches such a breakpoint. You can also set thread-specific breakpoints, so that only one thread stops there.</p><dd><p class="Body"><a name="85404"> </a>To set a thread-specific breakpoint, append the word <b class="command">thread</b> followed by a thread ID to the <b class="command">break</b> command. For example:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85405"></b><tt class="output">(gdb) </tt><b>break printf thread 2 </b><tt class="output">Breakpoint 1 at 0x568b8 (gdb) </tt><b>cont </b><tt class="output">Continuing. [Switching to task 0x3a4bd8 + tShell    ]  Breakpoint 1, 0x568b8 in printf ()</tt><b></a></b><dd> <b><a name="85406"></b><tt class="output">(gdb) </tt><b>i th </b><tt class="output">&nbsp;&nbsp;8 task 0x3b8ef0   tExcTask    0x9bfd0 in qJobGet () &nbsp;&nbsp;7 task 0x3b6580   tLogTask    0x9bfd0 in qJobGet () &nbsp;&nbsp;6 task 0x3b15b8   tNetTask    0x66454 in semBTake () &nbsp;&nbsp;5 task 0x3ade80   tRlogind    0x66454 in semBTake () &nbsp;&nbsp;4 task 0x3abf60   tTelnetd    0x66454 in semBTake () &nbsp;&nbsp;3 task 0x3aa9d8   tFtpdTask   0x66454 in semBTake () * 2 task 0x3a4bd8 + tShell      0x568b8 in printf () &nbsp;&nbsp;1 task 0x398688   tWdbTask    0x66454 in semBTake () (gdb) </tt><b>bt </b><tt class="output">#0  0x568b8 in printf () #1  0x4a108 in execShell () #2  0x49fe4 in shell ()</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85407"> </a>Internally, the debugger still gets control every time any thread encounters the breakpoint; but if the thread ID is not the one you specified with the <b class="command">break</b> command, the debugger silently continues program execution without prompting you.</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="92129"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION:  </font></b></a>Because the thread ID for the system context is not constant, it is not possible to set a breakpoint specific to system context. The only way to stop when a breakpoint is encountered in system context is to use a non-task-specific breakpoint.<b class="command"> </b></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="H4"><i><a name="85411">Switching Threads Implicitly</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85413"> </a>Your program may not always suspend in the thread you expect. If any breakpoint or other event (such as an exception) occurs while in system mode, in any thread, the debugger gets control. Whenever the target system is stopped, the debugger switches to the thread that was executing. If the new current thread is different from the previous value, a message beginning with "Switching to" shows which thread is suspended:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85414"></b><tt class="output">(gdb) </tt><b>thread 2 </b><tt class="output">(gdb) </tt><b>cont </b><tt class="output">Continuing. Interrupt... Program received signal SIGINT, Interrupt. [Switching to system +]  0x5b58 in wdbSuspendSystemHere ()</tt><b> </a></b></pre></dl><dd><p class="Body"><a name="85415"> </a>Whenever the debugger does not have control, you can interrupt the target system by clicking <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Interrupt Debugger</font></b> in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Debug</font></b> menu, or by keying <kbd>CTRL+BREAK</kbd>. This usually suspends the target in the system thread rather than in any task.</p><dd><p class="Body"><a name="85416"> </a>When you step program execution (with any of the commands <b class="command">step</b>, <b class="command">stepi, next</b>, or <b class="command">nexti</b>, or the equivalent buttons <img class="figure" border="0" src="images/c-debugger51.gif"> or <img class="figure" border="0" src="images/c-debugger52.gif">), the target resumes execution where it left off, which is in the thread marked <b class="operator">+</b> in the <b class="command">info threads</b> display. However, in the course of stepping that thread, other threads may begin executing. The debugger may stop in another thread before the stepping command completes, due to an event in that other thread.</p></dl></dl><a name="foot"><hr></a><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></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

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