📄 c-datacol3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Data Collection </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="c-datacol.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-datacol.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-datacol2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-datacol4.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="85534">7.3 Selecting Additional Libraries</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85536"> </a>When you select AIL level logging, all kernel libraries except <b class="library">sigLib</b> are logged by default. You can reduce the amount of data collected by only selecting some libraries; just uncheck them in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Collection Configuration</font></b> dialog box. You can increase the breadth of data collection by selecting <b class="library">sigLib</b> or the additional library <b class="library">memLib</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84300">Kernel Libraries</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84302"> </a>Rather than wanting to see information about all objects, you might be interested in how specific tasks, semaphores, and message queues interact. You can instrument combinations of objects in <b class="library">taskLib</b>, <b class="library">semLib</b>, <b class="library">msgLib</b>, and <b class="library">wdLib</b>. You cannot specify particular signals to instrument within <b class="library">sigLib</b>: either all signals are instrumented, or none are. The same holds true for the <b class="library">memLib </b>library. </p><dd><p class="Body"><a name="84306"> </a><a href="c-datacol3.html#84313">Table 7-1</a> lists the WindView target routines that you can call to control the instrumentation of particular objects; see the reference entries in <a href="wvGuideLOP.html#333"><i class="title">C. Library and Subroutine Reference</i></a> for more details.<p class="table"><h4 class="EntityTitle"><a name="84313"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 7-1: WindView Instrumentation Routines</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="84317"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Routine</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84319"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84321"> </a><b class="routine"><i class="routine">wvObjInst</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="84323"> </a>instrument objects </div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84325"> </a><b class="routine"><i class="routine">wvSigInst</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="84327"> </a>instrument signals </div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84329"> </a><b class="routine"><i class="routine">wvObjInstModeSet</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="84331"> </a>set object instrumentation level </div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p><dd><p class="Body"><a name="84332"> </a>When you select a library by checking it in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Collection Configuration</font></b> dialog box, all objects in that library, whether they already exist or not, are instrumented. When you start data collection, events are logged for these objects.</p><dd><p class="Body"><a name="84334"> </a>To instrument individual objects and groups of objects (whether or not they already exist on the target system), call <b class="routine"><i class="routine">wvObjInst</i></b><b>( )</b> instead of selecting the library in the dialog box checklist.<sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup> Events that affect these objects are logged if and when AIL level logging begins.</p><dd><p class="Body"><a name="84338"> </a>The <b class="routine"><i class="routine">wvObjInst</i></b><b>( )</b> routine is declared as follows:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84339">STATUS wvObjInst ( int objType /* object type: OBJ_TASK, OBJ_SEM, */ /* OBJ_MSG, OBJ_WD */ void * objId /* object ID: specific ID or NULL for all */ /* objects of objType */ int mode /* turn instrumentation on/off: /* INSTRUMENT_ON, INSTRUMENT_OFF */ )</a></b></pre></dl><dd><p class="Body"><a name="84341"> </a>You cannot instrument individual signals, but you can instrument signals programmatically as well as from the GUI. If you choose, call <b class="routine"><i class="routine">wvSigInst</i></b><b>( )</b> instead of selecting the library in the dialog box checklist. </p><dd><p class="Body"><a name="84342"> </a>The <b class="routine"><i class="routine">wvSigInst</i></b><b>( )</b> routine is declared as follows:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84343">STATUS wvSigInst ( int mode /* turn instrumentation on/off: /* INSTRUMENT_ON, INSTRUMENT_OFF */ )</a></b></pre></dl><dd><p class="Body"><a name="84344"> </a>You can start event collection using the GUI, or you can start it programmatically. The following example code shows how to carry out a variety of tasks programmatically. Some of them could also be carried out from the GUI. The example creates a semaphore and then enables instrumentation for that semaphore, for signals, and for tasks. At a later point, it starts event logging at AIL level. Later still, it disables signal instrumentation, but other object instrumentation remains active; finally, it stops all event logging.</p><dl class="margin"><dd><pre class="Code2"><b><a name="84345"> sem3Id = semMCreate (SEM_Q_FIFO); ... /* enable object event instrumentation for semaphore 3 */ status = wvObjInst (OBJ_SEM, sem3Id, INSTRUMENT_ON); /* enable signal instrumentation */ status = wvSigInst (INSTRUMENT_ON); /* enable object event instrumentation for all tasks */ status = wvObjInst (OBJ_TASK, NULL, INSTRUMENT_ON); ... /* start event logging */ status = wvEvtLogEnable (OBJECT_STATUS); /* events of interest are logged in the following code */ ... /* disable signal instrumentation */ status = wvSigInst (INSTRUMENT_OFF); ... /* stop event logging */ status = wvEvtLogDisable ();</a></b></pre></dl><dd><p class="Body"><a name="84347"> </a>The <b class="routine"><i class="routine">wvObjInstModeSet</i></b><b>( )</b> routine lets you instrument a group of objects beginning from the time of their creation. This routine is declared as follows:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84348">STATUS wvObjInstModeSet ( int mode /* turn instrumentation on/off: /* INSTRUMENT_ON, INSTRUMENT_OFF */ )</a></b></pre></dl><dd><p class="Body"><a name="84349"> </a>For example, suppose you are adding a new module to an already existing piece of code. You might want to see how just those new objects affect the existing application; you do not want to instrument any other objects. Within the object initialization code of the new module, you can surround the creation calls with <b class="routine"><i class="routine">wvObjInstModeSet</i></b><b>( )</b>, as in the following example:</p><dl class="margin"><dd><pre class="Code2"><b><a name="84350">void newCode () { ... /* enable instrumentation for all objects created here */ status = wvObjInstModeSet(INSTRUMENT_ON); ... /* create message queue 1 */ mq1Id = msgQCreate (5, 20, MSG_Q_FIFO); /* create message queue 2 */ mq2Id = msgQCreate (5, 20, MSG_Q_FIFO); /* create semaphore 1 */ sem1Id = semMCreate (SEM_Q_FIFO); /* create task 1 */ t1Id = taskSpawn ("task1", TASK_1_PRI, TASK_1_OPTS, TASK_1_SIZE, task1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); ... /* disable object instrumentation */ status = wvObjInstModeSet (INSTRUMENT_OFF) ... }</a></b></pre></dl><dd><p class="Body"><a name="84351"> </a>All objects created between the two calls to <b class="routine"><i class="routine">wvObjInstModeSet</i></b><b>( )</b> are instrumented. Events that affect those objects are logged if and when AIL level logging is started--for example, with the <b class="routine"><i class="routine">wvEvtLogEnable</i></b><b>( )</b> routine, as in the following example (which occurs after the <b class="routine"><i class="routine">newCode</i></b><b>( )</b> fragment shown above):</p><dl class="margin"><dd><pre class="Code2"><b><a name="84352">void existingCode () { ... /* area of existing code where objs from newCode module used */ status = wvEvtLogEnable(OBJECT_STATUS); ... /* send a message to message queue 1 */ status = msgQSend (mq1Id, &buff, MSG_4, MSG_4_TIMEOUT, MSG_PRI_NORMAL); /* receive a message from message queue 2 */ numbytes = msgQReceive (mq2Id, &buff, BUFF_SIZE, TICKS); /* take semaphore 1 */ status = semTake (sem1Id, SEM_1_TIMEOUT); /* suspend task 1 */ status = taskSuspend (t1Id); ... /* interesting section finished; stop event logging */ status = wvEvtLogDisable(); ... }</a></b></pre></dl><dd><p class="Body"><a name="84354"> </a>To instrument all objects in the system programmatically, do the following at the beginning of your application:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84355"> </a>Call <b class="routine"><i class="routine">wvObjInst</i></b><b>( )</b> four times, each time specifying a different object type, with <i class="textVariable">objID</i> set to <b class="symbol_UC">NULL</b> to instrument all objects of the specified type, and <i class="textVariable">mode</i> set to <b class="symbol_UC">INSTRUMENT_ON</b>. This instruments all objects already created by the operating system.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84357"> </a>Call <b class="routine"><i class="routine">wvObjInstModeSet</i></b><b>( )</b> with the argument <b class="symbol_UC">INSTRUMENT_ON</b>. This instruments all objects you may create thereafter.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84358"> </a>Call <b class="routine"><i class="routine">wvSigInst</i></b><b>( )</b> with the argument <b class="symbol_UC">INSTRUMENT_ON</b>.</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="84359"> </a>These programmatic steps have the same effect as starting WindView with all five kernel libraries checked, starting WindView logging, and starting your application.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84361">Additional Libraries </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84363"> </a>The data collected by these instrumented libraries is displayed in the usual way: with icons in the main view graph window. For statistical analysis, the spreadsheet link is used to generate "queries" into the event base that strain out the events necessary for typical statistical analysis purposes.</p><dd><p class="Body"><a name="84364"> </a>Each instrumented library is enabled or disabled as a whole. To control which libraries are logged, use the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Collection Configuration</font></b> dialog box (see <a href="c-collect3.html#84220"><i class="title">3.3 Instrumented Objects</i></a>). To control what is displayed in the view graph, the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Filter Events/States</font></b> dialog box contains an entry for each additional library (see <a href="c-display6.html#84125">Figure 5-14</a>). </p><dd><p class="Body"><a name="84372"> </a>For WindView 2.0 there is one non-kernel library instrumented, <b class="library">memLib</b>. The information displayed from this library is slightly different from the information generated and displayed by kernel events. While the event data generated by this library is somewhat interesting, the critical information is usually the scalar information generated by the event. For example, the most interesting information about memory activities is usually how much memory is allocated at a particular time. See <a href="c-collect3.html#87391">Figure 3-7</a> for an explanation of the display. </p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="84380"><b class="library">memLib</b></a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="84382"> </a>On the host, users can view cumulative information depicting what happens as allocated memory grows and shrinks in each target partition. They can see the addresses of memory blocks that get allocated and freed. This simplifies detecting memory leaks. <a href="c-datacol3.html#85758">Table 7-2</a> shows the memory routines associated with each event. <p class="table"><h4 class="EntityTitle"><a name="85758"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 7-2: Memory Routines Associated with Memory Events</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="85762"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Event</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85764"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Routines</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85962"> </a><font face="Helvetica, sans-serif" size="-1" class="sans"></font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85766"> </a><b class="symbol_lc">memPartAlignedAlloc </b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="85768"> </a><b class="routine"><i class="routine">memAlign</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="85992"> </a><b class="routine"><i class="routine">calloc</i></b><b>( )</b></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85770"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="85772"> </a><b class="routine"><i class="routine">memPartAlignedAlloc</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="85994"> </a><b class="routine"><i class="routine">malloc</i></b><b>( )</b></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85774"> </a></div></td><td width="10"> </td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -