Chapter 10. Using the X/Motif Analyzer: A Tutorial

This chapter provides an interactive sample session that demonstrates most of the X/Motif Analyzer functions. The session outlines common tasks you can perform with the X/Motif Analyzer.

This chapter contains the following sections:

Setting Up the Sample Session

For this tutorial, use the demo files in the directory /usr/demos/WorkShop/bounce, which contains the complete source code for the C++ application bounce. To prepare for the session, you first need to create the fileset, then launch the X/Motif Analyzer from the Debugger.

Figure 10-1. Execution View Icon

Figure 10-1 Execution View Icon

Preparing the Fileset

You must enter the commands listed below:

  1. cd /usr/demos/WorkShop/bounce

  2. make bounce

  3. cvd bounce &

    The cvd command brings up the CaseVision Debugger, from which you can use the X/Motif Analyzer. You see the Execution View icon (shown in Figure 10-1) and Main View (shown in Figure 10-2) appear. Note that the source code status indicator in the Debugger is (Read Only).

    Figure 10-2. Debugger Main View

    Figure 10-2 Debugger Main View

  4. Open the Execution View and position the window so you can see it and the Debugger Main View.

  5. To see what the program does, click Run. The bounce program opens a window on your desktop. Click Run in the new window, resize the window to make it taller, and then add balls from the Actors Menu to see how the program executes.

  6. The Execution View shows the program output (see Figure 10-3).

    Figure 10-3. Program Results in Execution View

    Figure 10-3 Program Results in Execution View

    If your screen shows different results, the program files may have been modified during a previous tutorial session.

Launching the X/Motif Analyzer

Once the bounce fileset is built and the debugger is active, you need to launch the X/Motif Analyzer with the following steps:

  1. Pull down the Views menu in the menu bar of the debugger Main View.

  2. Select "X/Motif Analyzer."

  3. Click OK when asked if you wish to change your $LD_LIBRARY_PATH environment variable to include /usr/lib/WorkShop/Motif. These are instrumented versions of the Silicon Graphics 5.3 libraries and add special support for the X/Motif Analyzer, in addition to containing symbols.

  4. Click Kill in the debugger Main View to kill bounce.

You are now ready to begin the sample session.

Navigating the Widget Structure

After being launched, the X/Motif Analyzer brings up an empty Widget examiner. The tab panel also shows the Breakpoints area, Trace examiner, and Tree examiner (see Figure 10-4).

Figure 10-4. First View of the X/Motif Analyzer (Widget Examiner)

Figure 10-4 First View of the X/Motif Analyzer (Widget Examiner)

  1. Click Run in the debugger Main View to run bounce again (this time with the augmented versions of the libraries).

  2. Click Run in the bounce window and resize the window to make it taller.

  3. Click Select in the X/Motif Analyzer. This brings up an information dialog and changes the cursor to a +. Do not click OK in the information dialog. Click Step in the Bounce window as instructed by the dialog. The widget examiner displays the Step widget structure.

  4. In the X/Motif Analyzer, click the Tree tab. The tree examiner displays the widget hierarchy of the target object (see Figure 10-5).

    Figure 10-5. Widget Hierarchy Displayed in the Tree Examiner

    Figure 10-5 Widget Hierarchy Displayed in the Tree Examiner

  5. Double-click the "Run" node in the tree. ("Run" is in the upper-right area of the window). This brings up the widget examiner, which displays the Run widget structure. Notice that the Parent button shows the name of the current widget's parent.

  6. In the X/Motif Analyzer, click the Parent button to switch the view to the Run widget's parent, the Control object. The widget examiner now displays the Control widget structure. You can navigate through the widget hierarchy using either the widget examiner or the tree examiner.

Examining Widgets

  1. In the widget examiner, pull down the Children... menu and select "Run." The Run widget structure is now displayed in the examiner.

  2. In the bounce window, pull down the Actors... menu and select "Add Red Ball."

  3. In the debugger Main View, enter stop in Clock::timeout in the cvd command-line area to set a breakpoint in bounce. Notice that the "Event" tab (for the event examiner) is added to the tab list.

  4. In the debugger Main View, click Continue a few times to observe the behavior of bounce with this breakpoint added.

  5. In the X/Motif Analyzer, click the Breakpoints tab to go to the breakpoints examiner. This examiner allows you to set widget-level breakpoints.

  6. In the "Callback Name" text field, enter activateCallback, then click Add to add a breakpoint for the activateCallback object of the Run widget. The result is displayed in Figure 10-6.

    Figure 10-6. Adding a Breakpoint for a Widget

    Figure 10-6 Adding a Breakpoint for a Widget

  7. In the debugger Main View, click the breakpoint arrow to remove the Clock::timeout breakpoint.

  8. In the debugger Main View, click Continue.

  9. In the bounce window, click Stop.

  10. In the bounce window, click Run. The process stops in the Run button's registered activateCallback. This is the routine that was passed to XtAddCallback routine. Notice that the "Callback" tab (for the callback examiner) is added to the tab list.

Setting Callback Breakpoints

  1. In the X/Motif Analyzer, click the Breakpoints list item to highlight the breakpoint.

  2. In the X/Motif Analyzer, delete the widget address in the "Widget" text field and click Modify. This changes the activateCallback breakpoint to apply to all push button gadgets (XmPushButtonGadget, set in the "Class" text field) rather than just the Run button (see Figure 10-7).

    Figure 10-7. Setting Breakpoints for a Widget Class

    Figure 10-7 Setting Breakpoints for a Widget Class

  3. In the debugger Main View, click Continue.

  4. In the bounce window, click Stop. The process now stops in the Stop button's activateCallback routine.

  5. In the X/Motif Analyzer, click the Callback tab to go to the callback examiner. This examiner displays the callback context and the appropriate call_data structure (see Figure 10-8).

    Figure 10-8. Viewing the Callback Context With the Callback Examiner

    Figure 10-8 Viewing the Callback Context With the Callback Examiner

  6. Double-click the window value in the callback structure, fourth line from bottom.

  7. Pull down the Examine menu and select "Window." The X/Motif Analyzer displays the window attributes for that window (the window of the Stop button). Notice that the "Window" tab (for the window examiner) is added to the tab list. See Figure 10-9.

    You can also accomplish the same action by triple-clicking the window value in the callback structure of the callback examiner. In general, triple-clicking on an address brings you to that object in the appropriate examiner.

    Figure 10-9. Viewing Window Attributes With the Window Examiner

    Figure 10-9 Viewing Window Attributes With the Window Examiner

Using Additional Features of the Analyzer

  1. In the X/Motif Analyzer, click the Widget tab.

  2. Double-click the widget_class value on the fourth line.

  3. Pull down the Examine menu and select "Widget Class." The X/Motif Analyzer displays the class record for the XmPushButtonGadget routine. Notice that the "Widget Class" tab (for the widget class examiner) is added to the tab list.

    (Again, the same action can be accomplished by triple-clicking the widget_class value in the widget examiner.)

  4. Triple-click the superclass value on the third line. The X/Motif Analyzer displays the class record for XmLabelGadget, the superclass of XmPushButtonGadget. (Triple-clicking is a shortcut for automatically selecting the correct examiner.)

  5. Triple-click the superclass value on the third line. The X/Motif Analyzer displays the class record for XmGadget, the superclass of XmLabelGadget.

  6. Click the Widget tab to change to the widget examiner.

  7. Triple-click the parent value on the fifth line. The X/Motif Analyzer now displays the widget control, the parent of Run. This action produces the same results as clicking the Parent button.

  8. In the X/Motif Analyzer, click the tab overflow area (the area where the tabs overlap, to the far left of the tab list) and select the Breakpoints tab (see Figure 10-10).

    Figure 10-10. Selecting the Breakpoints Tab From the Overflow Area

    Figure 10-10 Selecting the Breakpoints Tab From the Overflow Area

  9. Change the Breakpoint Type from "Callback" to "Resource-Change."

  10. In the "Class" text field, enter Any.

  11. In the "Resource Name" text field, enter sensitive.

  12. Click Add. This adds a breakpoint in instances when the "sensitive" resource is changed for any push button gadget.

  13. In the debugger Main View, click Continue. The Resource-Change breakpoint was reached, stopping the process in the XtSetValues routine.

  14. In the debugger Main View, pull down the Views menu and select "Call Stack." Notice the call to XtSetValues on the second line (see Figure 10-11).

    Figure 10-11. Viewing Breakpoint Results in the Callstack View

    Figure 10-11 Viewing Breakpoint Results in the Callstack View

  15. In the Callstack view, double-click the Cmdinterface::activate frame (just below XtSetSensitive). This is where the sensitive resource was changed.

  16. In the X/Motif Analyzer, click the Widget tab.

  17. In the X/Motif Analyzer, double-click the widget address in the "Widget" text field, press backspace, enter _w, and press <Enter>. The X/Motif Analyzer now displays the Run widget, which is the widget currently being changed.

  18. In the debugger Main View, click Continue. The process stops again in the XtSetValues routine, which is another sensitivity change.

  19. Double-click the Cmdinterface::active frame (just below XtSetSensitive).

  20. Double-click in Widget field, press backspace, enter _w, and press <Enter>. The X/Motif Analyzer displays the Step widget, which is the widget now being changed.