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

📄 c-wtx3.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<td colspan=1 rowspan=1><div class="CellBody"><a name="84938"> </a> message(s)</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84940"> </a></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84942"> </a></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84944"> </a></div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84947"> </a><b class="symbol_UC">UNKNOWN</b> </div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84949"> </a></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84951"> </a></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84953"> </a></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84955"> </a></div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"><p class="FootnoteNumberMarker">1:&nbsp;<span class="TableFootnote"><a name="89379"> </a>The values can be either hexadecimal values (h) or strings (s).</span></p></td></tr></table></p></p><dd><p class="Body"><a name="84956"> </a>When it registers for an event, a tool gives the target server a regular expression that matches the event string of the event the tool wants to receive. Tools can also send event strings; this allows tools attached to the same target to coordinate their activities and to exchange information or Tcl programs.</p><dd><p class="Body"><a name="84959"> </a>A tool can also choose not to receive any events or a subset of events. This is done by sending <b class="symbol_UC">WTX_UNREGISTER_FOR_EVENTS</b>. The parameter given to this command is a regular expression. Events matching this regular expression are not sent to the tool.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84960">Event-String Examples</a></i></h4></font><dl class="margin"><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84962"> </a>For a breakpoint occurring at address 0x4002344 in task 0x4030090, when <b class="symbol_UC">WTX_CONTEXT_TASK</b> is defined as 0x3 in <i class="textVariable">installDir</i>/<b class="file">host/include/wtxtypes.h</b>, the event string is:</li></ul></p><dl class="margin"><dl class="margin"><dd><pre class="Code3"><b><a name="84963">TEXT_ACCESS 0x3 0x4030090 0x4002344 0x4008008 0x4008608</a></b></pre></dl></dl><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84964"> </a>For a watchpoint occurring at address 0x4040000 in task 0x4030090 with pc equal 0x4002344, the event string is:</li></ul></p><dl class="margin"><dl class="margin"><dd><pre class="Code3"><b><a name="84965">DATA_ACCESS 0x4030090 0x3 0x4002344 0x4008008 0x4008608 0x4040000</a></b></pre></dl></dl><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84966"> </a>For a symbol <b class="symbol_lc">newSymbol</b> of type text, added with value 0x4002344, the event string is:</li></ul></p><dl class="margin"><dl class="margin"><dd><pre class="Code3"><b><a name="84967">SYM_ADD newSymbol 0x4002344 text</a></b></pre></dl></dl><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84968"> </a>For a divide-by-zero exception in task context 0x4002344, with exception stack frame at address 0x212900 (assuming that 0x10 is the exception vector associated with zero divide), the event string is:</li></ul></p><dl class="margin"><dl class="margin"><dd><pre class="Code3"><b><a name="84970">EXCEPTION 0x3 0x4002344 0x10 0x212900</a></b></pre></dl></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84971">Asynchronous notification (C API only)</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84972"> </a>The default method of handling events is for tools to poll the target server. Alternatively, your tool can register an event handler with the target server. In this case the target server calls the event handler when it receives an event. The following example shows the pieces of the event handler which are required to use the asynchronous event notification feature:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="84974">#include "wtx.h" ... /* handle events */  LOCAL void eventHandler      (     WTX_EVENT_DESC *                    event     )     {     /* print the received event */      if (event-&gt;event != NULL)         printf ("Receeived the event : %s\n", event-&gt;event);     } ...     /* register to receive events */      if (wtxAsyncNotifyEnable (wtxh, (FUNCPTR) eventHandler) != WTX_OK)         {         /* handle error here */ ...     } ...</a></b></pre></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84997">4.3.11  &nbsp;&nbsp;Gopher Support</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84999"> </a>A unique facility of WTX is its support for a compact interpreted language called Gopher. Any tool can use small Gopher scripts to request that target data structures of arbitrary complexity be retrieved from the target. The Gopher interpreter resides in the target agent. The target does not need to store dedicated routines to perform each unique request. This greatly reduces the amount of target memory required while giving users a powerful tool to access target data. Because of its power and efficiency, Gopher forms the basis of all Tornado show routines for system objects.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85001">How the Gopher Language Works</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85002"> </a>The Gopher execution environment is an abstract machine consisting of two objects, the pointer and the tape. The pointer is an address in the target's address space, and the tape is a one-way write-only area where Gopher results are accumulated. When the Gopher script terminates, the contents of the tape are returned to the host tool.</p><dd><p class="Body"><a name="85006"> </a><a href="c-wtx3.html#85013">Table&nbsp;4-2</a> shows the elements of the Gopher language and how they affect the pointer and the tape.<p class="table"><h4 class="EntityTitle"><a name="85013"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 4-2:&nbsp;&nbsp;Gopher Programming Language Elements&nbsp;</font></a></h4><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="CellHeading"><b><a name="85017"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Item</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85019"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Action</font></b></div></th><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85021"> </a><i class="textVariable">integer</i></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85023"> </a>Sets the pointer to the value <i class="textVariable">integer</i>.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85025"> </a>[<b class="symbol_lc">+-</b>] <i class="textVariable">integer</i></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85027"> </a>Increments or decrements the pointer by <i class="textVariable">integer</i>.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85029"> </a><b class="operator">!</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85031"> </a>Writes the pointer to the tape.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85033"> </a><b class="operator">*</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85035"> </a>Replaces the pointer with the value pointed to by the pointer.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85037"> </a><b class="operator">@</b>[<b class="operator">bwl</b>]</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85039"> </a>Writes the value pointed to by the pointer on the tape, and advances the pointer. An optional flag may be specified to indicate the bit-size that should be written. <b class="operator">b</b> designates an 8-bit value, <b class="operator">w</b> a 16-bit value, and <b class="operator">l</b> a 32 bit value. The pointer is advanced by the size of the element written. If no flag is given, <b class="operator">l</b> (32-bits) is assumed.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85041"> </a><b class="operator">$</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85043"> </a>Writes the string pointed to by the pointer on the tape.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85045"> </a><b class="symbol_lc">{</b><i class="textVariable">script</i><b class="symbol_lc">}</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85047"> </a>Executes the Gopher script inside the braces repeatedly while the pointer is not <b class="symbol_UC">NULL</b>. The string inside the braces works with a local copy of the pointer, maintaining the original, external pointer value.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85049"> </a><b class="symbol_lc">&lt;</b><i class="textVariable">script</i><b class="symbol_lc">&gt;</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85051"> </a>Executes the Gopher script inside the angle brackets once using a local copy of the pointer.</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85053"> </a><b class="symbol_lc">(</b><i class="textVariable">n script</i><b class="symbol_lc">)</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="85055"> </a>Executes the Gopher script inside the parentheses <i class="textVariable">n</i> times, using a local copy of the pointer.</div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85056">A Gopher Script for Sample Data Structures</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85057"> </a>This section describes a Gopher script that traverses and collects information from the following two sample data structures:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="85058">typedef struct _node &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;UINT32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;number;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* number of node */ &nbsp;&nbsp;&nbsp;&nbsp;struct _node *&nbsp;&nbsp;&nbsp;&nbsp;pNext;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* single linked list */ &nbsp;&nbsp;&nbsp;&nbsp;struct _other *&nbsp;&nbsp; pOther;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* pointer to an OTHER */ &nbsp;&nbsp;&nbsp;&nbsp;char *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* name of node */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* value of node */ &nbsp;&nbsp;&nbsp;&nbsp;} NODE;  typedef struct _other &nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;UINT32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* X Factor One */ &nbsp;&nbsp;&nbsp;&nbsp;UINT32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* X Factor Two */ &nbsp;&nbsp;&nbsp;&nbsp;} OTHER;</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="85072"> </a>Suppose you want a list of the numbers and names of each node in a list anchored at <b class="symbol_lc">nodeList</b>, whose elements are defined by <b class="symbol_lc">struct _node</b>. Initialize the Gopher pointer to the value of <b class="symbol_lc">nodeList</b>, <i class="textVariable">nodeAddr</i>,<b class="symbol_lc"> </b>and dereference the pointer. Then, while the pointer is not <b class="symbol_UC">NULL</b>, reach into the <b class="symbol_UC">NODE</b><b class="symbol_lc"> </b>structure and write the number and name elements to the tape. </p><dd><p class="Body"><a name="85073"> </a>Referring to the table of Gopher elements, create the following script:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85074"><i class="textVariable">nodeAddr</i> * { @ &lt; +8 *$ &gt; * }</a></b></pre></dl><dd><p class="Body"><a name="85075"> </a>First, initialize the pointer to the value of the symbol <b class="symbol_lc">nodeList</b> and then dereference it (<b class="symbol_lc">*</b>). You now have a pointer to the first element. While the pointer is not <b class="symbol_UC">NULL</b> (<b class="symbol_lc">{</b>), write the <b class="symbol_lc">number</b> field to the tape and advance the pointer (<b class="symbol_lc">@</b>). Saving the pointer position, enter the subroutine (<b class="symbol_lc">&lt;</b>). Add eight to the value of the pointer (<b class="symbol_lc">+8</b>), skipping over the <b class="symbol_lc">pNext</b> and <b class="symbol_lc">pOther</b> fields. Now the pointer points to the <b class="symbol_lc">name</b> field. Dereference the pointer at the first character of the <b class="symbol_lc">name</b> string (<b class="symbol_lc">*</b>) and write the string to the tape (<b class="symbol_lc">$</b>). Exit the subroutine (<b class="symbol_lc">&gt;</b>), which restores the previous value of the pointer (pointing to <b class="symbol_lc">pNext</b>). Dereference the pointer (<b>*</b>) at the next element in the list, or at <b class="symbol_UC">NULL</b>. If the field is not <b class="symbol_UC">NULL</b>, the subprogram <b class="symbol_lc">{...}</b> repeats. At the end, the Gopher tape contains two entries for each node in the list, one numeric value and one string value.</p><dd><p class="Body"><a name="85076"> </a>There are many ways to write a Gopher script. Each of the following is equivalent to the one described above:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85077"><i class="textVariable">nodeAddr</i> * { @ +8 &lt;*$&gt; -8 * }</a></b><dd> <b><a name="85079"><i class="textVariable">nodeAddr</i> * { &lt;@&gt; &lt;+12 *$&gt; +4 * }</a></b></pre></dl><dd><p class="Body"><a name="85080"> </a>Suppose you also want to find the values of <b class="symbol_lc">x1</b> and <b class="symbol_lc">x2</b> for a particular node. If the pointer points to the <b class="symbol_lc">pOther</b> member of a node and <b class="symbol_lc">pOther</b> is not <b class="symbol_UC">NULL</b>, this Gopher fragment writes the values of <b class="symbol_lc">x1</b> and <b class="symbol_lc">x2</b> to the tape:</p><dl class="margin">

⌨️ 快捷键说明

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