6
WindView 2.0
6-1
Introduction
Conguring WindView
Events
WindView 2.0
6.1 Introduction Conguring WindView Events
6-2
What is WindView?
A software logic analyzer or run-time analyzer for your multitasking application. A high precision graphical view of events, tasks, and interrupts in your application, shown across time. Helps diagnose race conditions and timing problems. Data logging can be triggered to focus on events of interest. Other programs may access your event log using C++ or Tcl programmatic interfaces to the event base. WindView for VxSim Lite comes with Tornado. For other targets, WindView is an optional product.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
6-3
Host/Target Architecture
Host Target VxWorks and Application
File
6-4
When event logging is enabled, event data are placed in a buffer in target memory as system instrumentation points and user events are encountered. This buffer may be dynamically extended or contracted by the task tWvRBuffMgr.
The task tWVUpload uploads event data to the host. When and how this upload occurs may be congured.
Events may be uploaded to a listening WindView graph, to the evtRecv tool, or to a host le, by various different upload methods.
Event logging, event upload, and event buffer management may be congured either programmatically or via the Tornado GUI.
Conguring WindView
Conguring WindView involves answering several questions:
q q
When does event logging start and stop? Which events are logged? How is the event buffer managed? When are event data uploaded to the host? How are event data uploaded to the host? What destination will receive the event data? Conguring VxWorks and the target server Using the WindView and Triggering host tools Calling target routines to control logging and upload
Copyright Wind River Systems Wind River Systems
6-5
Specify le system root directory. Specify read or read/write access. Write access is required for the TSFS event log upload to a le.
6-6
The TSFS facilities may be used even on targets without networking support (such as the bundled version of VxSim) so long as there is a communication channel between target server and WDB agent.
When the TSFS component of the WDB agent is included in VxWorks, an I/O system device named /tgtsvr is created on the target. This device allows access to TSFS facilities.
q
To open a le foo/bar on the host under the TSFS root directory, one opens /tgtsvr/foo/bar on the target. Operations on the returned le descriptor are actually handled by the target server, via the WDB agent. To create a TCP socket connection to port number 6164 on host do, one opens the le /tgtsvr/TCP:do:6164 on the target, obtaining a le descriptor which is for most purposes equivalent to a socket. The actual socket, however, is created by the target server on the host.
6-7
Buffer thrashing, a condition in which the ring buffer is repeatedly extended and contracted as the amount of data crosses a threshold, may sometimes occur during continuous upload mode. Often it can be avoided by increasing the minimum buffer count beyond the thrashing point.
wvUploadTaskCong (stackSize, priority) can be used to modify the priority of the upload task for your next run.
WindView 2.0
Introduction 6.2 Conguring WindView Events
6-8
6-9
The windview class instrumentation and windview library components will be required whenever using WindView.
One must select one timestamping component. The sequential timestamping component assigns only sequence numbers to events, so that time information beyond simple ordering is not recorded. The system-dened timestamping component requires support for high resolution timestamping within the BSP. An application note on writing timestamp drivers for custom BSPs is available.
One must select at least one upload path. The TCP/IP socket upload path requires network support on the target. The TSFS (socket) upload path requires support for the Target Server File System within the WDB agent. The le upload path requires a le system accessible to the target, often NFS or TSFS which allow writing les to a host le system.
At the Additional Instrumentation level, one may select which among several instrumented VxWorks Libraries will log events. Programmatically, one may also
q q
6-10
Logging larger classes of events yields more information, but imposes greater overhead. The amount of overhead which WindView imposes on the target system is also affected by
q
The amount of instrumented (kernel) work in the application compared to non-instrumented work. The upload strategy. The event buffer conguration.
Most of the programmatic routines used for controlling instrumentation and logging are implemented in wvLib. See the VxWorks Reference Manual entry for this library for more information.
Congure WV Button opens Collection Conguration Dialog after WindView is already launched.
For Additional Instrumentation logging class, select libraries for which to enable event logging.
6-11
When logging at the Additional Instrumentation level, selecting a library for logging means that all objects of that library will log events. For instance, selecting semLib means that all object events involving any semaphore in VxWorks or your application will be logged. To instrument only some objects of a given type requires that wvLib routines be called in your application (or from the shell). See the reference entries for wvObjInst() and wvObjInstModeSet() for more information on logging events corresponding to particular objects or sets of objects.
Except for the Direct to Graph path, one must specify additional information on the upload destination:
q q
host and port number for socket upload paths. directory and le name for le upload paths.
Copyright Wind River Systems Wind River Systems
6-12
Direct to Graph upload is essentially equivalent to Socket Via TSFS upload; however, it automatically opens a listening WindView graph and assigns appropriate port numbers. This is the default upload path.
For upload via TSFS socket, one must specify the target server device path for the destination host and port number, e.g. /tgtsvr/TCP:myhost:6164.
For upload via TCP/IP socket, one must specify the destination host and port number, e.g. myhost:6164.
For upload to a le via TSFS, one must specify the TSFS path to the le on the host, e.g. /tgtsvr/evtLog.wvr; one must also congure the target server specifying the root of the TSFS le system, and giving read/write TSFS access.
Using File via NFS, one species any le writable by the target.
Upload Mode
Deferred upload:
q q
Data are uploaded on request after logging stopped Logging also stops if event buffer becomes full. Data are uploaded periodically as logging continues. Ring buffer grows during times of greater event production, shrinks once data are uploaded. Logging stops if event buffer becomes full. Data are uploaded on request after logging stops, often after warm reboot. Event buffer is treated as circular. Buffers must be in memory not overwritten during the reboot.
Copyright Wind River Systems Wind River Systems
Continuous upload:
q q
6-13
For deferred and continuous upload, logging stops if the buffer becomes full, that is, if either the maximum buffer count is reached, or if memory becomes exhausted to the granularity of the individual buffer size, or if new buffers cannot be allocated fast enough to store events.
In deferred and post-mortem mode, it is recommended that you stop logging (if it is going on) before clicking the upload button .
Conguring VxWorks for post-mortem mode requires specifying the location of the event buffer and ensuring that neither VxWorks nor the boot program overwites this memory when the target reboots. This is discussed in the WindView Users Guide. A common technique is to specify the macro USER_RESERVED_MEM to reserve memory between sysPhysMemTop() and sysMemTop() for the applications own use before rebuilding both VxWorks and the boot program.
3. Specify upload path and destination data. 4. Specify upload mode when upload occurs.
Deferred: Upload after collection stops. Continuous: Upload while collecting. Post-Mortem: Upload after system crash.
6-14
In deferred mode, collection continues until either it is explicitly stopped or the event buffer lls. The data may be uploaded after collection stops. This mode has the advantage that upload activity does not appear in the uploaded log. This is the default mode.
In continuous mode, upload occurs periodically during collection as the event buffer lls. The event buffer may be dynamically expanded or contracted during upload. This mode has the advantage that very large logs may be collected, but upload activity will occur in the log.
In post-mortem mode, once the event buffer is lled it starts to be rewritten, in a circular fashion. Event data is only uploaded after logging is stopped, typically by a system crash and reboot. In this mode, the buffer management portion of the dialog changes to specify only the region of preserved memory where the event buffer will be written.
and buttons on WindView control panel. Triggering facility. Programmatic control from target.
For socket upload paths, start evtRecv or open listening WindView graph before uploading.
q
For continuous mode, start the listener before starting collection. wvLib reference page. usrWindview documentation in WindView Users Guide.
Copyright Wind River Systems Wind River Systems
6-15
The usrWindview module denes the routines wvOn() and wvOff() which start and stop a typical WindView logging and upload session. The upload mechanism used is the last one of TCP/IP socket upload path TSFS socket upload path File upload path which has been included in the VxWorks image.
q q q
In Tornado, the usrWindview module is implemented in usrWindView.c, together with urWvFileUploadPath.c, usrWvSockUploadPath.c, and usrWvTsfsUploadPath.c, all of which you may nd in the target/cong/comps/src directory.
Triggering
Associates actions with WindView events. Action may be:
q q
Start or stop WindView logging. Call a function. Optionally, disable trigger and/or enable another. Any combination of event type, context, and involved system object ID. Optional conditional expression involving integral global variable or ISR-safe function of no argument.
User trigger events, distinct from user WindView events, may be generated using trgEvent().
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
6-16
Using Triggering to start and stop WindView is a good way to collect short event logs focused on the events of interest.
Starting or stopping WindView, or calling a function which you do not explicitly identify as safe to call from an ISR, occurs in the context of a task trgActDef spawned specically for this purpose. In the case of a trigger starting WindView, this means that logging is not started immediately upon the event which res the trigger, but only when the trgActDef task gets a chance to run. For this purpose, then, it is best if you trigger on an event which occurs somewhat before the events of interest. Stopping WindView after an event of interest is an alternative.
The triggering facility is documented in the WindView Users Guide. Triggering may be controlled from the target application using the routines in trgLib; see the reference entry for this library for more information.
2. Click Create Trigger (or Maintain Trigger ) to open the Trigger Maintenance dialog.
6-17
For more information on the Triggering user interface, see the WindView Users Guide.
WindView 2.0
Introduction Conguring WindView 6.3 Events
6-18
Examples: Task state change. semGive & semTake. msgQSend and msgQReceive. Timer expiration. Anything you dene as an event.
6-19
The event dictionary, available in the WindView Users Guide, and online via Help => WindView Help => Legend, lists all system WindView events, and describes the conditions under which each event occurs, its effects on task state, and the amount of information logged about the event at each logging level.
User-Dened Events
STATUS wvEvent (eventNo, buffer, bufsize) eventNo buffer bufSize
ID number for the event, which will appear on the viewgraph. address of user supplied data. NULL if none. size of user supplied data, in bytes.
The buffer can contain user data which is passed up to WindView on upload. This is displayed in a hex-dump format. Use this to programatically instrument events in your code.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
6-20
It is easy to assign bitmaps to user events. This is discussed in section F.4 of the WindView Users Guide. The bitmap les are in the (.bmp) format. They are placed in a subdirectory .wind/windview of your home directory (determined under Windows by the value of the environmental variable %HOME%). The bitmap corresponding to user event N must be named somethinguserN.bmp, where something is anything you like; for example, the bitmap for user event 3 could be named enterFooFunc_user3.bmp.
A useful technique is to create macros for instrumentation functions such as wvEvent(); after development completes the macros can be turned into no-ops so as to avoid instrumentation in the production code.
User Eventpoints
STATUS e (addr, eventNo, taskNameOrId, evtRtn, arg)
Where: addr eventNo taskNameOrId evtRtn address to set eventpoint. an event number for display. the task ID of the task in which to raise the eventpoint, 0 = all tasks. function to call when event point is hit. Event is logged if evtRtns return value is zero. an integer argument to pass to evtRtn above.
Copyright Wind River Systems Wind River Systems
arg
6-21
An eventpoint is like a breakpoint, except that instead of stopping the task which hits it, a WindView event may be logged and a function may be called.
The e() function is a WindSh built-in, which also exists as a target function in dbgLib.
Example use:
If the evtRtn argument is used, it should return an integer and take a four-byte argument (passed as an integer). If the returned value is nonzero, the event will not be logged.
WindView Example
Initialization:
Create message queue; Spawn consumer task; Spawn producer task;
Producer Task:
FOREVER { Allocate block; Initialize data in block; Send pointer to block across message queue; Delay one tick; }
Tornado Training Workshop
Consumer Task:
FOREVER { Wait for message (pointer to block) to arrive on queue; Process data in block; Free block; }
6-22
6-23
On this board, INT 6 is the system clock interrupt and INT 3 is the network interrupt. The time scale is in seconds. The system clock is ticking 60 times per second. Tasks are listed in priority order on the left.
The log starts with a network interrupt INT 3, which wakes up tNetTask, which delivers a WDB request to the WDB agent tWdbTask.
Task t4 is spawned by the WDB agent to execute the initialization code. Task t4 spawns tSend1, the producer task, and tRecv1, the consumer task. Eventually t4 is deleted with help from tExcTask.
The tasks tWVUpload and tWvRBuffMgr belong to WindView itself. Task tWVUpload controls upload of event log data from target to host, while tWvRBuffMgr manages the target event buffer, expanding it or contracting it dynamically as necessary. Neither of these tasks is active in the displayed interval.
Zooming In
One cycle of the producer - consumer program. Events are shown in the context in which they occur.
Tornado Training Workshop Copyright Wind River Systems Wind River Systems
6-24
INT 6 , the system clock tick interrupt, occurs during the kernel idle loop and undelays the producer task tSend1.
The producer allocates a block of memory in a semaphore-guarded critical region . It then initializes the data in the block (selected region between user events and ). Then tSend1 sends a pointer to the block across a message queue , and delays itself .
When tSend1 sends the message, tRecv1 is made ready to run, but does not run until tSend1 delays itself . After receiving the pointer to the block from the message queue, tRecv1 processes the data in the block in the interval between user events and . It then frees the block , and pends itself on the message queue waiting for another block to process.
cursor over event, and description appears in status bar. q Double-click, and Show Event dialog appears.
6-25
Double-clicking an event, or right-clicking and selecting Show Event... from the context menu brings up the Show Event dialog.
The Show Event dialog allows one to search forwards or backwards in time for events matching particular criteria:
q q
The type of event. The task or interrupt context in which the event occurs. The VxWorks object (semaphore, message queue, watchdog, etc.) involved, if any.
Select or type in the appropriate values, and lock the elds of interest, then click the Prev or Next buttons. For instance,
q
Type user19 in the event type eld and lock only that eld to search for occurrences of user event 19. Double-click on a semTake() event, lock only the object ID eld, and search forwards or backwards in time for a corresponding semGive().
The task pop-up menu can be used to hide any task. Right-click on task name on left side of graph for a context menu. To act on multiple tasks, select Attributes.... Non-executing task states may be hidden by pressing the appropriate button on the tool bar. Specic events and states may be ltered out using the Filter Events/States dialog. Move mouse over event, or double-click on event. Right-click on task state stipple, select Context State Right-click and select Legend to see event dictionary.
Copyright Wind River Systems Wind River Systems
6-26
Preemption locking and priority inheritance are covered in the next chapter.
A task which is not running may be in any combination of the PEND, DELAY, and SUSPEND states. If neither pended nor delayed nor suspended, the task is READY.
6-27
Right-click on a task state stipple line segment and select Context State to see the task state label for that interval, as well as information about when the task entered that state and how long it spent there.
The Task State Summary dialog can display information for the selected interval, the screen width, the full log, or an interval specied by the timestamps of its endpoints.
A task which has specied a timeout in a pending call is in the PEND+DELAY state while pended. It may return to ready if either the timeout expires, or the event it was waiting for occurs.
A nal state, DEAD, is the state reported for a task after it has been deleted. WindView displays no state stipple for this state, but you may see it in the Task State Summary or the Context State dialog.
6-28
Analysis packs calculate analog information from event log data. WindView 2.0 comes with two pre-built analysis packs:
q
Memory usage analysis pack exports its results to the graph (pictured above). CPU usage analysis pack calculates and exports a list of CPU idle intervals to a Microsoft Excel spreadsheet. Memory allocations, all types. Logged as memPartAlignedAlloc. Memory frees, logged as memPartFree Memory partition creations, logged as memPartCreate Memory reallocations, logged as memPartRealloc. Additions to memory pools, logged as memPartAddToPool.
Event base as a whole. Task, ISR, or idle context. Individual event. Cursor for iterating through event base. Appendix D of WindView Users Guide Tornado Tools Workshop
Copyright Wind River Systems Wind River Systems
6-29
The dynamic link library for the event base API is host/x86-win32/bin/apilib.dll (Windows) host/sun4-solaris2/lib/libwvapi.so (Solaris) host/parisc-hpux10/lib/libwvapi.sl (HP-UX) These may be loaded into a tcl interpreter such as wtxtcl using the load command.
Using the Tcl interface is convenient and quick; it is good for one-shot uses or prototyping.
Using the C++ interface yields faster, more structured programs and somewhat more numerically accurate results.
The header le host/include/wvapi.h is available for programs using the C++ event base API.
6-30
WindView 2.0 also supports the ability to display logs from multiple processors in the same graph. If the same timstamp source is used on all processors, the logs will be synchronized; no other synchronization mechanism is provided.