Like every other Tornado tool, the CrossWind graphical user interface is "soft" (amenable to customization) because it is written in Tcl, which is an interpreted language. Tornado API Guide: UI Tcl describes the graphical building blocks available; you can also study the Tcl implementation of CrossWind itself. You can find the source in host/resource/tcl/CrossWind.tcl.
You can write Tcl code to customize the debugger's graphical presentation in a file called .wind/crosswind.tcl under your home directory. Use this file to collect your custom modifications, or to incorporate shared customizations from a central repository of Tcl extensions at your site.
Recall that the debugger uses two separate Tcl interpreters. Previous sections described the .gdbinit and ~/.wind/gdb.tcl initialization files that initialize the debugger command language (see 7.6 Tcl: Debugger Automation).
The following outline summarizes the role of all the CrossWind customization files. The files are listed in the order in which they execute.
You can prevent CrossWind from looking for the two .gdbinit files, if you choose, by setting the internal GDB parameter inhibit-gdbinit to yes. Because the initialization files execute in the order they are listed above, you have the opportunity to set this parameter before the debugger reads either .gdbinit file. To do this, insert the following line in your ~/.wind/gdb.tcl:
gdb set inhibit-gdbinit yes
You can use the following specialized Tcl commands to pass control between the two CrossWind Tcl interpreters.
The major use of uptcl is to experiment with customizing or extending the graphical interface. For example, if you have a file myXWind containing experimental Tcl code for extending the interface, you can try it out by entering the following in the command panel:
(gdb) tcl uptcl source myXWind
By contrast, downtcl and ttySend are likely to be embedded in Tcl procedures, because (in conjunction with the commands discussed in 7.6.3 Tcl: Invoking GDB Facilities) they are the path to debugger functionality from the graphical front end.
Most of the examples in 7.7.3 Tcl: Experimenting with CrossWind Extensions, below, center around calls to downtcl.
The examples in this section use the Tcl extensions summarized in Table 7-3. For detailed descriptions of these and other Tornado graphical building blocks in Tcl, see Tornado API Guide: UI Tcl.
|
|||||||||||||||||||
|
|||||||||||||||||||
|
|||||||||||||||||||
In C++ programs, one particular named value has great special interest: this, which is a pointer to the object where the currently executing function is a member.
Example 7-1 defines two buttons related to this:
The Tcl primitive catch is used in the second button definition in order to avoid propagating error conditions (for instance, if the buttons are pressed with no code loaded) from GDB back to the controlling CrossWind session. This does not prevent GDB from issuing the appropriate error messages to the command panel.
# Make a nice gap before new buttons toolBarItemCreate " " space # BUTTON: "t" Print C++ "this" value. toolBarItemCreate " t " button { ttySend "print this\n" } # BUTTON: "t*" Launch "inspect" window on current C++ class (*this) toolBarItemCreate " t*" button { catch {downtcl gdb display/W *this} }
Example 7-2 illustrates how to add extensions to the CrossWind graphical interface with a simple enhancement: adding a menu command to list the displayed program source centered on a particular line.
In Example 7-2, the procedure xwindList uses downtcl to run the GDB list command. To tie this into the graphical interface, the example adds a new command List from to the File menu. The new command displays a form (described in the dialogCreate call) to collect input specifying an argument to the list command. When input is complete, the form in turn runs xwindList, through a call-back attached to its OK button. Figure 7-14 shows the new menu command and form defined here (and the Example 7-3 menu command).
# FORM: a form to prompt for list argument # (part of "List from..." command addition to "File" menu) dialogCreate "List from?" -size 290 100 { {text "line spec:" -hspan} {button "OK" -left 2 -right 48 -bottom .+5 xwindList} {button "Dismiss" -left 52 -right 98 -bottom .+5 {dialogUnpost "List from?"}} }
As explained in What Modules to Debug, you sometimes need to tell the debugger explicitly to load symbols for modules that were downloaded to the target using other programs (such as the shell).
Example 7-3 illustrates a File menu command Add Symbols to handle this through the graphical user interface, instead of typing the add-symbol-file command.
# MENU COMMAND: "Add Symbols", additional entry under "File" menuButtonCreate File "Add Symbols..." S { xwindAddSyms }