dprint

Evaluates and displays information

Format:

Prints the value of a variable

dprint variable

Prints the value of an expression

dprint expression

Arguments:

variable

A variable whose value will be displayed. The variable can be local to the current stack frame or it can be global. If the variable being displayed is an array, you can qualify the variable's name with a slice that tells the CLI to display a portion of the array,

expression

A source-language expression to be evaluated and printed. Because expression must also conform to Tcl syntax, you must place it within quotes if it includes any blanks, and it must be enclosed in braces ({}) if it includes brackets ([ ]), dollar signs ($), quote characters ("), or any other Tcl special characters.

expression cannot contain calls to assembler, Fortran, C, or C++ functions.

Description:

The dprint command evaluates and displays a variable or an expression. The CLI interprets the expression by looking up the values associated with each symbol and applying the operators. The result of an expression can be a scalar value or an aggregate (array, array slice, or structure).

As the CLI displays data, it passes the data through a simple more process that prompts you after each screen of text is displayed. After a screen of data is displayed, you can press the Enter key to tell the CLI to continue displaying information. Entering q tells the CLI to stop printing this information.

Since the dprint command can generate a considerable amount of output, you may want to use the capture command to save the output into a variable.

Structure output appears with one field printed per line. For example:

sbfo = {
   f3 = 0x03 (3)
   f4 = 0x04 (4)
   f5 = 0x05 (5)
   f20 = 0x000014 (20)
   f32 = 0x00000020 (32)
}

Arrays are printed in a similar manner. For example:

foo = {
   [0][0] = 0x00000000 (0)
   [0][1] = 0x00000004 (4)
   [1][0] = 0x00000001 (1)
   [1][1] = 0x00000005 (5)
   [2][0] = 0x00000002 (2)
   [2][1] = 0x00000006 (6)
   [3][0] = 0x00000003 (3)
   [3][1] = 0x00000007 (7)
}

You can append a slice to the variable's name to tell the CLI that it should display a portion of an array. For example:

d1,<> p {master_array[::10]}
  master_array(::10) = {
   (1) = 1 (0x00000001)
   (11) = 1331 (0x00000533)
   (21) = 9261 (0x0000242d)
   (31) = 29791 (0x0000745f)
   (41) = 68921 (0x00010d39)
   (51) = 132651 (0x0002062b)
   (61) = 226981 (0x000376a5)
   (71) = 357911 (0x00057617)
   (81) = 531441 (0x00081bf1)
   (91) = 753571 (0x000b7fa3)
}

Note that the slice was placed within {} symbols. This prevents Tcl from trying to evaluate the information within the [] characters. You could, of course, escape the brackets; for example, \[ \].

The CLI evaluates the expression or variable in the context of each thread in the target focus. Thus, the overall format of dprint output is as follows:

first process/thread group:
    expression result

second process/thread group:
    expression result

...

last process/thread group:
    expression result

You can also use the dprint command to obtain values for your computer's registers. For example, on most architectures, $r1 is register 1. You would obtain the contents of this registering by typing:

    dprint \$r1

Notice that you must escape the $ since the name of the register includes the $. This $ is not the standard indicator that tells Tcl to fetch a variable's value. Appendix C, Architectures, in the TotalView Users Guide lists the mnemonic names assigned to registers.

Note:   You do not need a $ when asking dprint to display your program's variables. For example, "$\$r1" looks for a Tcl variable named "$r1", not a program or TotalView variable named "$r1".

Command alias:

You may find the following alias useful:

Alias
Definition
Meaning
p
{dprint}
Evaluates and displays information.

Examples:

dprint scalar_y

Displays the values of variable scalar_y within all processes and threads in the current focus.

p argc

Displays the value of argc.

p argv

Displays the value of argv, along with the first string to which it points.

p {argv[argc-1]}

Prints the value of argv[argc-1]. If the execution point is in main(), this is the last argument passed to main().

dfocus p1 dprint scalar_y

Displays the values of variable scalar_y for the threads in process 1.

f 1.2 p arrayx

Displays the values of the array arrayx for just the second thread in process 1.

for {set i 0} {$i < 100} {incr i} {p argv\[$i\]}

If main() is in the current scope, prints the program's arguments followed by the program's environment strings.

 
 
 
 
support@etnus.com
Copyright © 2001, Etnus, LLC. All rights reserved.
Version 5.0