02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Tornado</strong> 2.0<br />

User’s Guide<br />

7.6 Tcl: Debugger Automation<br />

CrossWind exploits Tcl at two levels: like other <strong>Tornado</strong> tools, it uses Tcl to build<br />

the graphical interface, but it also includes a Tcl interpreter at the GDB command<br />

level. This section discusses using the Tcl interpreter inside the CrossWind<br />

enhanced GDB, at the command level.<br />

NOTE: For information about using Tcl to customize the CrossWind GUI, see<br />

7.7 Tcl: CrossWind Customization, p.273. The discussion in this section is mainly of<br />

interest when you need complex debugger macros; you might want to skip this<br />

section on first reading.<br />

Tcl has two major advantages over the other GDB macro facility (the define<br />

command). First, Tcl provides control and looping (such as for, foreach, while, and<br />

case). Second, Tcl procedures can take parameters. Tcl, building on the command<br />

interface, extends the scripting facility of GDB to allow you to create new<br />

commands.<br />

7.6.1 Tcl: A Simple Debugger Example<br />

To submit commands to the Tcl interpreter within GDB from the command panel,<br />

use the tcl command. For example:<br />

(gdb) tcl info tclversion<br />

This command reports which version of Tcl is integrated with GDB. All the text<br />

passed as arguments to the tcl command (in this example, info tclversion) is<br />

provided to the Tcl interpreter exactly as typed. Convenience variables (described<br />

in GDB User’s Guide: Convenience Variables) are not expanded by GDB. However, Tcl<br />

scripts can force GDB to evaluate their arguments; see 7.6.3 Tcl: Invoking GDB<br />

Facilities, p.268.<br />

You can also define Tcl procedures from the GDB command line. The following<br />

example procedure, mld, calls the load command for each file in a list:<br />

(gdb) tcl proc mload args {foreach obj $args {gdb load $obj}}<br />

You can run the new procedure from the GDB command line; for example:<br />

(gdb) tcl mload vxColor.o priTst.o<br />

To avoid typing tcl every time, use the tclproc command to assign a new GDB<br />

command name to the Tcl procedure. For example:<br />

266

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!