The WindView defaults are set to allow you to start using WindView to generate useful data immediately. If you experimented with VxWorks as described in 2. Getting Started, you saw how quickly large volumes of event data can be generated. When you are solving a problem with a real-time system, you do not want to dig through large quantities of irrelevant data to find the precise information you need. At the same time, once you know approximately where the problem is, you may need more detailed data from that region of the program. This chapter shows you how to modify the defaults in the Collection Configuration dialog box to log exactly the information necessary to solve your problem most efficiently.
The level of logging you specify determines how much data is collected and how much impact WindView has on your application. The three options are:
The relationship between these levels is shown in Figure 3-1. CSE level collects the smallest amount of data and is the least intrusive. TST level collects all the data collected at CSE level plus additional data about task state transitions. AIL level collects all the data collected at TST level plus additional data about selected objects. At AIL level, you can choose to collect data about only some or all of the possible objects, depending on your needs.
To select a logging level, open the Collection Configuration dialog box by clicking the
button on the Control window toolbar. The Collection Configuration dialog box is shown in Figure 3-2. Select the desired level from the Base Events drop-down combo box.
In real-time systems, the term current context usually refers to the current task and the information needed to restore the task's state, such as the state of the processor registers, operating system control information, and the stack. For WindView, the meaning of current context is extended to include any thread of execution: a task, an ISR, or the kernel's idle loop. A context switch, then, refers to a change in the current context, which can occur when one task preempts another, a task delays itself or pends on a resource, or a task is interrupted by an ISR. To view a sample event log collected with CSE level logging, select Open in the main File menu and open installDir/host/src/windview/samples/switch.wvr. Figure 3-3 shows this event log.
When you select Context Switch on the Collection Configuration dialog box (see Figure 3-2), WindView collects data about the current context and where it is switched. It also records every entry and exit of an ISR, every program error that results in an exception that is handled by a default exception handler, periods of task preemption locking, and periods of priority inheritance. Because CSE level logging is the least intrusive, it can be useful for fine-tuning an otherwise debugged system. For example, you might use it to see that all timing deadlines are being met, or that all tasks get to run.
The term task state transition refers to the process of a task exiting from one state and entering into another. For example, if a task issues a call to semTake( ) and the semaphore is not available, it makes a transition from the executing state to the pended state. If it calls taskDelay( ), it makes a transition from the delayed state to the ready state when the number of ticks specified in the call expire. All context switches involve task state transitions, but a given task state transition may or may not result in a context switch, depending on the states of other tasks in the system when the task in question makes a state transition. View a sample event log collected at TST logging level by selecting Open in the main File menu to installDir/host/src/windview/samples/state.wvr. Figure 3-4 shows a portion of this event log.
When you select Task State Transition on the Collection Configuration dialog box, WindView collects data about task state transitions and the events that cause them. However, when you specify TST level logging WindView does not collect information on events that do not result in task state transitions. For example, if no tasks are pended on a particular semaphore, a semGive( ) of that semaphore does not result in any task state transitions; thus, the semGive event icon is not logged.
AIL level logging works a little differently from CSE and TST levels. At AIL level, WindView gathers all the information included at the other two levels, as well as additional information about instrumented libraries that you choose to log. When you ask WindView to log an instrumented library, it logs all operations on library objects, including creations, gives or sends, takes or receives, and deletions. Events are generated for these operations whether or not they result in task state transitions, context switches, or neither; for example, a semTake( ) of a semaphore that is available would be logged at AIL level, even though it would not change the state of the calling task. To view a sample event log collected at AIL logging level, open installDir/host/src/windview/samples/object.wvr by selecting Open in the main File menu. Figure 3-5 shows this event log.
When you specify AIL level logging, you can collect data for many kinds of objects in your real-time system. By default, the main kernel AIL libraries are selected when you select AIL level: taskLib, semLib, msgQLib, wdLib, and eventLib, which are checked in the default setting shown in Figure 3-2. For information on changing the selected libraries, see 3.3 Instrumented Objects.
Figure 3-5 shows the same scenario as Figure 3-4. The only difference is that Additional Instrumentation was selected on the Collection Configuration dialog box, causing the default libraries to be logged. You can see that in addition to the information shown in Figure 3-4, tNetTask gives and take several semaphores(
and
), only one of which results in a task state transition or a context switch.
Once you have selected Additional Instrumentation, you must decide which objects to log. The kernel objects that can be selected for logging from the Collection Configuration dialog box are tasks, semaphores, watchdog timers, message queues, VxWorks events, and signals. Memory objects and network objects can also be selected. Select the libraries containing the objects you want to log by checking the box in front of the library name.
|
|
|||||||||||||||||||
Once you have selected Additional Instrumentation, you must decide which objects to log. The kernel objects that can be selected for logging from the Collection Configuration dialog box are tasks, semaphores, watchdog timers, message queues, and signals. Memory objects can also be selected. Select the libraries containing the objects you want to log by checking the box in front of the library name.
For all kernel objects except signals, you can enable instrumentation for a particular object, such as task t1, within your application code. You can also enable instrumentation for whole libraries programmatically if you wish. For information on how to specify data collection for AIL level logging in your code, see 7.2 Instrumenting Objects Programmatically.
The view graph shows you when memory events occur, but the most interesting thing about your application's use of memory is how much is allocated at any time. WindView provides an analysis pack to calculate and display this information. To run it, display your log in the view graph and click
. Select Memory Usage in the Analysis dialog box. To display the results of the calculation, click Export to Graph; the view graph displays the memUsage analog graph. (See Figure 3-7.)
To see how WindView can find memory leaks, compile and load this example:
void func1 (int loopcnt)
{
int i;
for (i = 0; i < loopcnt; i++)
{
char *p1 = (char *)malloc (1023);
char *p2 = (char *)malloc (1017);
free ((void *)p1);
/* note: p2 points at an unreturned piece of system memory. */
}
exit (0);
}
Start WindView in additional instrumentation logging level with memLib selected. Run func1 from the shell with a parameter of 5. When func1 returns, stop WindView and display the view graph. Select the Memory Usage analysis pack, click Select All to calculate memory usage for all tasks, select Perform, and click Export to Graph to display the analog graph. The analog graph allows you to quickly identify when func1 was running, and to see that not all the memory it allocated was returned to the system memory pool. (See Figure 3-7.)
Select netLib to log core and auxiliary networking events. Windview presents the Network Instrumentation Configuration dialog, shown in Figure 3-8. Because there are so many networking events compared to other categories of events, they are divided into eight categories based on priority. This gives you more precise control in pinpointing events you want to log. To log only the highest priority networking events, select the EMERGENCY priority level. To log events of all priorities, select VERBOSE.
In practice, while there are many types of networking events that can occur, logging at VERBOSE priority level can still produce readable logs. If a log is unreadable because it is cluttered with too many networking events, you can change the priority level in this dialog. You can also filter the data for display after collection is complete. See "Filtering for Data of Interest" on page 57.for more information.
As you add more instrumentation, you increase the number of logged events. If there is a lot of activity on your target, starting and stopping WindView manually from the control window can generate unnecessarily large logs and make your problem-solving more difficult. There are three ways to control WindView:
and
buttons on the Control window. This is the most straightforward but least precise method.
There are two approaches to using the API. The most straightforward is to use wvOn( ) and wvOff( ), located in target/src/config/usrWindview.c. These routines start a typical instance of event logging and upload. These routines are not used by WindView itself, so they can be modified to suit individual requirements.
The second approach is to use the routines in wvLib and wvNetLib. These routines give much finer control than wvOn( ) and wvOff( ) over the configuration of how events are logged. Detailed information and examples are available in the reference entries; you can examine the source code in target/config/comps/src/usrWindview.c to see how they are used. They are more complex to use than wvOn( ) and wvOff( ), since the order in which they are invoked is critical
All WindView routines are discussed in the online reference pages.