📄 c-wtx4.html
字号:
wtxtcl> </tt><b>wtxEventpointAdd cexit [symbol tickGet] task $ctxId \ notify 0 0 0</b><tt class="output"> 0x2</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85497"> </a>Before resuming the task, register to receive all events and flush the event queue. The following example creates a procedure, <b class="tclProc">listEvents</b>, which flushes the queue and writes all events:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90315"></b><tt class="output">wtxtcl> </tt><b>wtxRegisterForEvent .* </b><tt class="output">0 wtxtcl> </tt><b>proc listEvents {} {while {[set event [wtxEventGet]] != ""}\ {puts $event}} </b><tt class="output">wtxtcl> </tt><b>listEvents </b><tt class="output">TOOL_DETACH windsh 0x44ce50 TOOL_ATTACH windsh 0x44ff90 CALL_RETURN 0x4ae2720 0x4 0xd0003 ...</tt><b></a></b></pre></dl><dd><p class="Body"><a name="90316"> </a>Now start the task and check for events:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85506"></b><tt class="output">wtxtcl> </tt><b>wtxContextResume task $ctxId </b><tt class="output">0 wtxtcl> </tt><b>listEvents </b><tt class="output">CALL_RETURN 0x4ae2720 0x5 0xd0003 TOOL_ATTACH browser 0x450f90 ... TEXT_ACCESS 0x4aeec90 0x3 0x426d5c 0x4aeec4c 0x4aeec20</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85515"> </a>When you see the <b class="symbol_UC">TEXT_ACCESS</b> line of output, the breakpoint event has arrived. The following message appears in WindSh:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85516"></b><tt class="output">-> </tt><b>Break at 0x00426d5c: _tickGet Task: 0x4aeec90 (tick)</a></b></pre></dl><dd><p class="Body"><a name="85518"> </a>The task remains stopped at the breakpoint until you continue it:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85519"></b><tt class="output">wtxtcl> </tt><b>wtxContextCont task $ctxId </b><tt class="output">0</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85521"> </a>The task now completes, generating another event, which you can retrieve:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85522"></b><tt class="output">wtxtcl> </tt><b>listEvents </b><tt class="output">... CTX_EXIT 0x3 0x4aeec90 0x3ce474 0xd0003</tt><b></a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85529">4.4.11 Working with Virtual I/O</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85531"> </a>Virtual input and output is comprised of strings that are placed into memory blocks by <b class="command">wtxtcl.</b> WTX provides commands for manipulating the memory blocks. WTX uses an event to notify the tool that virtual output is available. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85532">Virtual Output</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85533"> </a>This example assumes a Tornado shell for configuring the virtual I/O and a target whose configuration includes virtual I/O (as is the case with the target images supplied with Tornado). For more information on configuring Tornado and the target, see the <i class="title">Tornado User's Guide</i>.</p><dd><p class="Body"><a name="85534"> </a>Be sure to launch the target server without any target redirection option (for more details, see <i class="title">Tornado User's Guide: Target Server</i>), otherwise the example may not work properly.</p><dd><p class="Body"><a name="85535"> </a>First, open a virtual I/O channel and redirect the target's standard input, output, and error streams to this channel. To start WindSh on the target server, click the WindSh button in the Tornado window or start the shell from the Windows command prompt or a UNIX shell prompt: </p><dl class="margin"><dd><pre class="Code2"><b><a name="85536"></b><tt class="output">% </tt><b>windsh vxsim7@aven </b><tt class="output">...</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85538"> </a>In WindSh, unset the <b class="symbol_UC">SH_GET_TASK_IO</b> configuration parameter to avoid any conflict with the WindSh local redirection (see <i class="title">Tornado User's Guide: Shell </i>for more details), Open a virtual I/O device and reroute standard input, output, and error to it. Then, using the shell, print a string to standard output. The string is sent to the attached tools in the form of an event which you can examine in <b class="command">wtxtcl</b>. The commands and output are shown in the following example:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85539"></b><tt class="output">-> </tt><b>?shConfig</b><tt class="output"> </tt><b>SH_GET_TASK_IO</b><tt class="output"> </tt><b>off </b><tt class="output">-> </tt><b>vioFd = open ("/vio/1", 2) </b><tt class="output">new symbol "vioFd" added to symbol table. vioFd = 0x39d1a0: value = 7 = 0x7 -> </tt><b>ioGlobalStdSet (0, vioFd) </b><tt class="output">value = 0 = 0x0 -> </tt><b>ioGlobalStdSet (1, vioFd) </b><tt class="output">value = 1 = 0x1 -> </tt><b>ioGlobalStdSet (2, vioFd) </b><tt class="output">value = 2 = 0x2 -> </tt><b>printf "hello\n" </b><tt class="output">value = 6 = 0x6</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85551"> </a>The string prints in the virtual console if it is enabled. It also goes to <b class="symbol_lc">vioFd</b>. Now you can return to your <b class="command">wtxtcl</b> session and call the procedure <b class="tclProc">listEvents</b> (or repeatedly run <b class="tclProc">wtxEventGet</b>) to see what events have arrived:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85553"></b><tt class="output">wtxtcl> </tt><b>listEvents </b><tt class="output">SYM_ADDED vioFd 0x490efec CALL_RETURN 0x4ae2720 0x4 0xd0003 CALL_RETURN 0x4ae2720 0x4 0xd0003 CALL_RETURN 0x4ae2720 0x4 0xd0003 VIO_WRITE 0 mblk0</tt><b></a></b></pre></dl><dd><p class="Body"><a name="89730"> </a>Depending on your exact environment, you may see additional events. You should see at least the five events shown above, indicating that the symbol <b class="symbol_lc">vioFd</b> has been added to the symbol table, that the three calls to <b class="tclProc">ioGlobalStdSet</b> have returned, and that virtual I/O is available. The event of interest is the one that indicates that virtual I/O has been received and stored in the memory block <b class="symbol_lc">mblk0</b>. The easiest way to see the data is to use the <b class="tclProc">memBlockGetString</b> command:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85560"></b><tt class="output">wtxtcl> </tt><b>memBlockGetString mblk0 </b><tt class="output">hello</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85562"> </a>Another useful command for dealing with memory blocks that contain VIO data is <b class="tclProc">memBlockWriteFile</b>, which can be used to dump the contents of a block to <b class="symbol_lc">stdout</b> directly:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85564"></b><tt class="output">wtxtcl> </tt><b>memBlockWriteFile mblk0 - </b><tt class="output">hello</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85566"> </a>The <b class="operator">-</b> character indicates that the block should be written to <b class="symbol_lc">stdout</b>. Before continuing, free the memory block holding the VIO data:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85567"></b><tt class="output">wtxtcl> </tt><b>memBlockDelete mblk0</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85568">Virtual Input</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85569"> </a>For an example of virtual input, return to the shell and run a task that reads input. Create a new variable and initialize it to 0, then run a <b class="routine"><i class="routine">scanf</i></b><b>( )</b> task that blocks waiting for input. Since you redirected standard input to the virtual I/O channel, a virtual I/O write will satisfy the <b class="routine"><i class="routine">scanf</i></b><b>( )</b> call.</p><dd><p class="Body"><a name="85570"> </a>First, be sure that IO redirection is still turned off, or turn it off. Then create the variable and issue the <b class="routine"><i class="routine">scanf</i></b><b>( )</b> in WindSh:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90386"></b><tt class="output">-> </tt><b>?shConfig </b><tt class="output">SH_GET_TASK_IO = off ... -> </tt><b>myVioData = 0 </b><tt class="output">new symbol "myVioData" added to symbol table. myVioData = 0x39d188: value = 0 = 0x0 -> </tt><b>scanf ("%d", &myVioData) </a></b></pre></dl><dd><p class="Body"><a name="85575"> </a>At this point the shell prompt does not return, because <b class="routine"><i class="routine">scanf</i></b><b>( )</b> is waiting for input. To send the data for <b class="routine"><i class="routine">scanf</i></b><b>( )</b> to convert, return to <b class="command">wtxtcl</b> and issue this command:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85576"></b><tt class="output">wtxtcl> </tt><b>wtxVioWrite 1 -string "99\n" </b><tt class="output">0x3</tt><b></a></b></pre></dl><dd><p class="Body"><a name="85578"> </a>In the shell, you should see the routine return, and you can inspect the value of the variable that <b class="routine"><i class="routine">scanf</i></b><b>( )</b> filled in:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90426"></b><tt class="output">value = 1 = 0x1 -> </tt><b>myVioData </b><tt class="output">myVioData = 0x39d188: value = 99 = 0x63 = 'c'</tt><b> </a></b></pre></dl></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/note.gif"></td><td><hr><div class="CalloutCell"><a name="90687"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>The target server can perform redirections like the one described in this example. For more information on this feature, see <i class="title">tgtsvr</i> in the online reference material under <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Tornado Reference>Tornado Tools </font></b>and<i class="title"> Tornado User's Guide: Target Server</i>.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><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/note.gif"></td><td><hr><div class="CalloutCell"><a name="90702"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>WindSh can also redirect the I/O of all the spawned tasks in its own window. For more informations on this feature, please see <i class="title">Tornado User's Guide: Shell.</i><b></b><i class="title"></i></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="85601">4.4.12 Calling Target Routines</a></i></h4></font><dl class="margin">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -