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

📄 c_when.htm

📁 mips架构的bootloader,99左右的版本 但源代码现在没人更新了
💻 HTM
字号:
<title>The when Command</title><h1>when</h1><!--INDEX "when command" "complex breakpoints" "pseudo registers" -->The when command sets complex breakpoints <p></dl><h2>Format</h2><dl><dd>The format for the when command is: <p><pre>when <var>condition</var> <var>action</var></pre> <p>where: <p><table><tr><td valign=top><var>condition</var>  </td><td>Specifies the conditions under which the 		     breakpoint will occur.</td></tr><tr><td valign=top>	<var>action</var>    </td><td> Specifies the action to be taken when the 		     breakpoint occurs.</td></tr></table><p></dl><h2>Functional Description</h2><dl><dd>The <samp>when</samp> command provides a very flexible way to set <ahref="brkpts.htm">breakpoints</a> and to specify the action thatshould be taken when they are encountered.<p>Each <samp>when</samp> command takes two arguments, a condition, and anaction.  The condition can be something as simple as @pc==main (whenthe program counter is equal to value of the symbol main), or it can bea complex expression that might include specifying the contents ofmemory locations.<p>Actions can be any <a href="mondef.htm">Monitor</a> command string.But it can also include the pseudo command stop. For example, thecommand, "<samp>when @pc==main stop</samp>" specifies that when theprogram counter has the value of the symbol main, execution shouldstop. <p>Conditional expressions can be combined in any arbitrarymanner to provide extremely complex breakpoint conditions. Forexample,<p><pre>	PMON> when @pc==main2&&(^tcbchn==task1||^tcbchn==task2) stop</pre><p>which will stop execution when the pc is equal to main2, andeither tcbchn is equal to task1 or task2. <p>In the preceeding examples we have chosen to stop execution whenthe condition is met. However, it is possible to specify a listof commands. For example,<p><pre>	PMON> when @pc==sort "r;d -w dat3 1"</pre><p>	specifes that when the pc is equal to 'sort', the commands	'r' and 'd -w dat3 1' will be executed. The ';' is used to	separate commands, and the double quotes are necessary because	the argument contains spaces.  <p>The <a href="mondef.htm">Monitor</a> is responsible for deciding whento use hardware breakpoint registers (if present). In general, the <ahref="mondef.htm">Monitor</a> uses software breakpoints unless thereis a specific reason that a hardware breakpoint is required.<p>If you issue a command that requires a hardware breakpoint register.But that the <a href="mondef.htm">Monitor</a> finds that there is notone available. The <a href="mondef.htm">Monitor</a> will automaticallyuse trace mode when you issue the c command to continue execution.Because trace mode is not real-time, the <ahref="mondef.htm">Monitor</a> will warn you at the time that you setthe breakpoint that this will require non real-time execution.<p></dl><h2>Examples</h2><dl><dd><ul><li>Stop when a memory location changes.<p>	You can specify data locations by using the dereferencing	operator '^'. For example,<p><pre>		PMON> when '^tcbchn!=0' stop</pre><p>	means that execution should stop when the contents	of the memory location specified by the symbol tcbchn is not	equal to zero. Note that expressions that include the character	'!' must be enclosed within single- or double-quotes to 	supress the normal history substitution mechanism. Single- or	double-quotes must also be used if the expression contains	spaces.  <p><li>Break on the 20th time around a loop.<p><pre>	when @pc==0x80021234 "r a @a+1"	when @a==0t20 stop</pre>These commands specify that execution should pause each time the pc hasthe value 0x80021234. Each execution pauses, the command "<samp>r a@a+1</samp>" will be executed. This command increments the value ofpseudo register 'a'.  See the <a href="c_r.htm"><samp>r</samp></a>command for more information on the pseudo registers.<p>If during one of these pauses in execution pseudo register 'a' hasthe value 20 (decimal), execution will stop.<p><li>Break when fred() is executed after jim(), but not after mike().<pre>	when @pc==jim "r a 1"	when @pc==mike "r a 0"	when "@pc==fred && @a==1" stop</pre><li>Stop if dat1 ever gets set back to zero.<pre>	when "^dat1 != 0" "r a 1"	when "^dat1 == 0 && @a == 1" stop</pre>This requires a hardware data breakpoint register in order to executethis in real-time. In this mode a brief pause will occur each timea write to dat1 occurs.<p>If you don't have a hardware data breakpoint register, you canmaintain real-time performance by only checking the value at specificpoints in the program.<p><pre>	when "@pc == fred && ^jim != 0" "r a 1"	when "@pc == fred && ^jim == 0 && @a == 1" stop</pre><li>Find the maximum value written to a specified memory location.<pre>	when "^dat1 > @a" "r a ^dat1"</pre>Use the command "<samp>r a</samp>" to examine the value when theprogram stops.<p><li>Stop if jim() is ever called with a 2nd argument of zero.<pre>	when "@pc == jim && @a1 == 0" stop</pre><li>Count how many times jim() is executed.<pre>	when "@pc == jim" "r a @a+1"</pre>Use the command "<samp>r a</samp>" to examine the value when theprogram stops.<p></ul></dl><h2>See Also </h2><dl><dd><a href="c_b.htm">b</a>, <a href="c_db.htm">db</a>,and <a href="c_load.htm">load</a> commands.</dl><p><hr><b>Navigation:</b> <a href="index.htm">Document Home</a> | <a href="doctoc.htm">Document Contents</a> | <a href="docindex.htm">Document Index</a> <p>

⌨️ 快捷键说明

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