9

Browser



9.1    A System-Object Browser

The Tornado browser conveniently monitors the state of your target. The main browser window summarizes active system and application tasks, memory consumption, and a summary of the current target memory map. Using the browser, you can also examine:

  • detailed task information
  • semaphores
  • message queues
  • memory partitions
  • watchdog timers
  • stack usage by all tasks on the target
  • target CPU usage by task
  • object-module structure and symbols
  • interrupt vectors

These displays are snapshots. They can be updated interactively, or the browser can be configured to automatically update its displays at a specified interval. When any displayed information changes, in any browser display, the browser highlights the affected line.



9.2    Starting the Browser

There are two ways to start a Tornado browser:

  • From the Tornado Launch toolbar, click the button. This launches a browser for the currently selected target server (see Tornado Launch Toolbar).

  • From the Tools menu, click on Browser. The dialog box shown in Figure 9-1 appears, to allow you to select a target server from the Targets drop-down list.

Figure 9-1:   Browser Target-Selection Dialog Box



9.3    Anatomy of the Browser Window

The top of the browser window, shown in Figure 9-2, allows you to request particular browser displays and to control other browser functionality.

Figure 9-2:   Controls and Data Area in Browser Display

Browser Window Selector


Button Bar

Data Area




9.4    Browser Buttons

The button bar at the top right of each browser window provides the following controls:

Immediate-update button. Use this button to update all browser displays immediately. You can use this button for an immediate update even if a periodic update is running.

Periodic-update button. This button is a toggle: press it to request or cancel regular updates of all browser displays (the time period between updates is one of the parameters controlled by the button, described below).

Parameter adjustment button. Press this button to adjust the parameters that govern the browser's behavior. Figure 9-3 shows the Browser Configuration dialog box, displayed when you click this button.

Figure 9-3:   Browser Configuration Dialog Box

The Browser Configuration dialog box contains the following controls:

Symbol sort

Spy mode

Browser/Spy update time

Spy collect frequency

Reuse Browser Window



9.5    Target-Information Window

Figure 9-4:   Target Information Window

The Target Information window (Figure 9-4) displays the following summary information about the selected target:

Name

Version

Status

Runtime

Agent

CPU

BSP

Memory

Link

User

Start

Last

Attached Tools



9.6    Task-List Window

Figure 9-5 shows two examples of the task list produced by clicking Tasks in the browser window selector.

Figure 9-5:   System Tasks and Application Tasks

The tasks in this window are organized into two lists:

WRS Tasks

User Tasks

Each task list is marked with a small (minus sign) icon.You can double-click on this icon to hide data that is not of current interest; the browser changes the marker to a small (plus sign) to indicate that hidden data is available. To reveal the contents of a hidden task list, click the plus-sign icon. (This convention for controlling the display of hierarchical information is used in many parts of Tornado.)

The task-summary display (for either system or application tasks) includes the task ID, the task name (if known), and the task state.

You can display detailed information on any of these tasks by clicking on the summary line for that task; see 9.8.1 The Task Browser.



9.7    Memory-Usage Window

Figure 9-6 shows an example of the window produced by clicking Memory Usage in the browser window selector.

Figure 9-6:   Memory Usage Window

The Memory Usage window has the following areas:

  • Memory-Consumption Graphs

The two bar graphs in this area show what proportions of target memory are currently in use.

The upper bar shows the state of the memory pool managed by the target agent.2 This represents target memory consumed by Tornado tools, for example with dynamically linked modules or for variables defined from the shell.



In both bars, the numeric label inside the bar measures the memory currently in use. The numbers below the right edge of each graph indicate the total memory size available in each pool. All memory-size numbers are byte counts in decimal.

  • Loaded-Module List

This area lists each object file currently loaded on your target. This includes the VxWorks image and all dynamically linked object modules.



9.8    Object-Information Windows

Clicking Object Information in the browser window selector brings up a window where you can request a specialized display for VxWorks system objects (Figure 9-7). Type or paste either the name or the ID of a system object in the text box next to the Show button. Then click Show (or press ENTER) to display information about that particular object. As a convenient shorthand, we refer to the browser's object-information windows as object browsers: task browsers, semaphore browsers, and so on.

Another way to bring up an object-information window is to click on the name of an object in the module browser (9.9 The Module-Information Window). If the object is a recognized system object, the data area for it is displayed just as if you had copied the name to the Show box.

For example, Figure 9-7 shows the Show box filled in with a request to display an object called graphSem.

Figure 9-7:   Filling in the Object-Display Box

9.8.1   The Task Browser

To see more detailed information about a particular task, click on any task's summary line in a browser Tasks window (or enter the task name or task ID in the Show box of an Object Information browser window). The browser displays a window for that task, similar to Figure 9-8.

Figure 9-8:   Task Browser (Initial Display)

At the top of the task browser you can see global task attributes, and information about stack allocation and usage. The last major region shows the hardware registers for this task; their precise organization and contents depends on your target architecture. As usual, a scrollbar is displayed if more room is needed.

Notice the (minus sign) icons; the lines they mark categorize the task information. As in other parts of Tornado that display hierarchical data, you can hide categories by clicking on any icon, or expose hidden categories by clicking on any (plus sign) icon.

Figure 9-9 shows another task browser running on the same target, but with most of the hardware registers hidden.

Figure 9-9:   Task Browser (Hiding Registers)

9.8.2   The Semaphore Browser

To inspect a semaphore, enter either its name or its semaphore ID in the Show box of a browser window with Object Information selected. A specialized semaphore browser appears, similar to the one shown in Figure 9-10. The semaphore browser displays both information about the semaphore itself (under the heading Attributes), and the complete queue of tasks blocked on that semaphore, under the heading Blocked Tasks.

Figure 9-10:   Semaphore Browser

Figure 9-10 shows a binary semaphore with several blocked tasks in its queue. As in other browser windows, you can click on the levels of the display to control detail. To start a browser for any queued task, click on the task name or ID; both are displayed for each task.

POSIX semaphores have a somewhat different collection of attributes, and the browser display for a POSIX semaphore reflects those differences. Similarly, the semaphore browser adapts to shared-memory semaphores.

9.8.3   The Message-Queue Browser

To inspect a message queue, enter its name or message-queue ID in the Show box of a browser window with Object Information selected. A message-queue browser like the one in Figure 9-11 is displayed.

Figure 9-11:   Message-Queue Browser

In addition to displaying the attributes of the message queue, the message-queue browser shows three queues:

  • Receivers Blocked shows all tasks waiting for messages from the message queue.

  • Senders Blocked shows all tasks waiting for space to become available to place a message on the message queue.

  • Messages Queued shows the address and length of each message currently on the message queue.

Shared-memory message queues have a very similar display format (differing only in the title bar). Just as for semaphores, the message-queue browser also has a version for POSIX message queues.

9.8.4   The Memory-Partition Browser

The memory-partition browser comes up when you enter a memory partition ID (or the name of a variable containing one) in the Show box of a browser window with Object Information selected, as do all specialized browser windows. Figure 9-12 shows the VxWorks system memory partition, memSysPartId.

Figure 9-12:   Memory-Partition Browser

By default the memory-partition browser displays the following:

  • The total size of the partition.
  • The number of blocks currently allocated, and their total size in bytes.
  • The number of blocks currently free, and their total size in bytes.
  • The totals allocated since booting the target system (headed Cumulative).
  • The size and address of each block currently on the free list.

As with other object browsers, you can control the level of detail visible by clicking on the (minus sign) or (plus sign) icons beside each heading.

9.8.5   The Watchdog Browser

When the Tornado browser recognizes a watchdog-timer ID (or a variable containing one) in the Show box of a browser window with Object Information selected, it displays a window like those shown in Figure 9-13.

Figure 9-13:   Watchdog Browser

Before you start a timer, the display resembles the one on the left of Figure 9-13; only the state field is particularly meaningful. However, after the timer starts counting, you can see the number of ticks remaining, the address of the routine to be executed when the timer expires, and the address of the routine's parameter.

9.8.6   The Class Browser

VxWorks kernel objects are implemented as related classes: collections of objects with similar properties. Each class has an identifier in the run-time; the symbol names for these identifiers end with the string ClassId, making them easy to recognize. When you enter a class identifier in the Show box of a browser window with Object Information selected, the browser displays overall information about the objects in that class.

For example, Figure 9-14 shows the display for semClassId (the semaphore class).

Figure 9-14:   Class Browser (Semaphore Class)

You can get a list of the class identifiers in your run-time system by executing the following in a shell window:

-> lkup "ClassId" 


9.9    The Module-Information Window

To inspect the memory map of any currently loaded module, click on the line that lists that module in the loaded-module list (described in 9.7 Memory-Usage Window).

Figure 9-15:   Loaded-Module List in Memory Usage Window

The browser opens a module-information window resembling Figure 9-16 for the selected object module.

Figure 9-16:   Module Information Window

  

The module-information window displays information in the following categories:

Module

Segments

Symbols

Each symbol's display occupies one line. The symbol display includes the symbol's address in hexadecimal, a letter representing the symbol type (Table 9-1), and the symbol name (in its internal representation--C++ symbols are displayed "mangled," and all compiled-language symbols begin with an underbar).

Table 9-1:   Key Letters in Symbol Displays


Symbol Key

Global
Local
Symbol Type

A
a
absolute
B
b
bss segment
C
common (uninitialized global symbol)
D
d
data segment
T
t
text segment
?
?
unrecognized symbol

Symbol displays are grouped by category. There is one category for the symbols in each section, plus a category headed Other_Symbols that contains uninitialized globals and unrecognized symbols.

For symbols that represent system objects, clicking on the symbol name brings up the corresponding object browser; see 9.8 Object-Information Windows.



9.10    The Spy Window

Clicking Spy Chart in the browser window selector produces a display similar to Figure 9-17. This window reports on CPU utilization for each task on your target, as a percentage of CPU cycles. Besides tasks, the spy window always includes the following additional categories for CPU-cycle usage: time spent in the kernel, time spent in interrupt handlers, and idle time. These additional categories appear below all task data; you may need to use the scrollbar to see them.

Figure 9-17:   Spy Window

Spy data is reported in one of two modes (selected with the Browser Configuration dialog box shown in Figure 9-3). When the Differential check box is off in the Browser Parameters dialog box (see 9.4 Browser Buttons), the spy window is in cumulative mode: it shows total CPU usage since you first display the spy window. Spy reports in differential mode reflect only the CPU usage since the last update.

The spy window uses the facilities of the VxWorks target software in spyLib (which is automatically downloaded to the target when you request a spy window, if it is not already present there). For related information, see the reference entries for spyLib.



9.11    The Stack-Check Window

Clicking Stack Check in the browser window selector produces a window similar to Figure 9-18. The stack-check window summarizes the current and maximum stack usage for each task currently running.

Figure 9-18:   Stack-Check Window

The display for each task presents three values:

  • The stack size allocated for each task, shown as a number of bytes beneath the bar representing that task.

  • The maximum stack space used so far by each task is indicated graphically by the shaded portion of each task's bar.

  • The portion of the stack currently in use, shown as a number of bytes, displayed within the bar graph for each task.


*      
NOTE: It is possible for a task to write beyond the end of its stack while not writing to the last part of its stack. This will not be detected by checkStack( ), the underlying routine for the stack-check window.



9.12    The Vector Table Window

To inspect the interrupt/exception vector table, click Vector Table in the browser window selector. (This facility is available for all target architectures except the Windows simulator, PowerPC, and ARM.) The display is similar to Figure 9-19.

Figure 9-19:   Vector Table Window

Vectors are numbered from 0 to X (X = number of interrupt/exception vectors). The connected routines or addresses are displayed, or if no routine is connected the following key words are be displayed:

Std Excep. Handler

Default Trap

Uninit. Int

Corrupted Int

If you set a new vector from WindSh and then update the browser, the new vector is highlighted.



9.13    Browser Displays and Target Link Speed

If your communications link to the target is slow (a serial line, for example), use the browser judiciously. The traffic back and forth to the target grows with the number of objects displayed, and with the update frequency. On slow links, this traffic may seriously slow down overall Tornado performance. If you experience this problem, try displaying fewer objects, updating browser displays on request instead of periodically, or setting updates to a longer interval.



9.14    Troubleshooting with the Browser

Many problem conditions in target applications become much clearer with the browser's visual feedback on the state of tasks and critical objects in the target. The examples in this section illustrate some of the possibilities.

9.14.1   Memory Leaks

The memory-consumption bar graphs in the Memory Usage window makes memory leaks easy to notice. If the allocated portion of memory grows continually, you have a problem. The memory-consumption graph in Figure 9-20 indicates a memory leak in an application that has run long enough to exhaust memory almost completely.

Figure 9-20:   A Memory Leak as Seen in the Browser

9.14.2   Memory Fragmentation

A more subtle memory-management problem occurs when small blocks of memory that are not freed for long periods are allocated interleaved with moderate-sized blocks of memory that are freed more frequently: memory can become fragmented, because the calls to free( ) for the large blocks cannot coalesce the free memory back into a single large available-memory pool. This problem is easily observed by examining the affected memory partition (in many applications this is the VxWorks system memory partition, memSysPartId) with the browser. Figure 9-21 shows an example of a growing free-list with many small blocks, characteristic of memory fragmentation.

Figure 9-21:   Fragmented Memory as Seen in the Browser

9.14.3   Stack Overflow

When a task exceeds its stack size, the resulting problem is often hard to trace, because the initial symptom may be in some other task altogether. The browser's stack-check window is useful when faced with behavior that is hard to explain: if the problem is a stack overflow, you can spot it immediately (Figure 9-22).

Figure 9-22:   Stack Overflow on Task u9

9.14.4   Priority Inversion

Browser displays are most useful when they complement each other. For example, suppose you notice in a task-list window (as in Figure 9-23) that a task uHi, expected to be high priority, is blocked while two other tasks are ready to run.

Figure 9-23:   Browser: uHi Pended

An immediate thing to check is whether the three tasks really have the expected priority relationship (in this example, the names are chosen to suggest the intended priorities: uHi is supposed to have highest priority, uMed medium priority, and uLow the lowest). You can check this immediately by clicking on each task's summary line, thus bringing up the windows shown in Figure 9-24.

Figure 9-24:   Task Browsers for uHi, uMed, uLow

Unfortunately, that turns out to be the wrong explanation; the priorities (shown for each task under Attributes) are indeed as expected. Examining the CPU allocations with the spy window (Figure 9-25) reveals that the observed situation is ongoing; uMed is monopolizing the target CPU. It should certainly execute by preference to the low-priority uLow, but why is uHi not getting to run?

Figure 9-25:   uMed Monopolizing CPU (Spy Window Excerpt)

At this point examining the code (not shown) may seem worthwhile. Doing so, you notice that uMed uses no shared resources, but uHi and uLow synchronize their work with a semaphore. Could that be the problem?

Examining the semaphore with the browser (Figure 9-26) confirms this suspicion: uHi is blocking on the semaphore, which uLow cannot release because uMed has preempted it.

Figure 9-26:   uHi Blocked on Semaphore

Having diagnosed the problem as a classic priority inversion, the fix is straightforward. As described in VxWorks Programmer's Guide: Basic OS, you can revise the application to synchronize uLow and uHi with a mutual-exclusion semaphore created with the SEM_INVERSION_SAFE option.



9.15    Tcl: the Browser Initialization File

When the browser begins executing, it first checks for a file called .wind\browser.tcl in two places: first under c:\tornado, and then in the directory specified by the HOME environment variable (if that environment variable is defined). In each of these directories, if a browser.tcl file is found, its contents are sourced as Tcl code; this gives you an opportunity to customize the browser.


1:  You can also restrict your target servers to permit connections only by a particular list of users; see Sharing and Reserving a Target Server.

2:  To set the size of this memory pool, see Scaling the Target Agent.