dprint
Evaluates and displays information
MiniContents:
Arguments
Description
Command alias
Examples
Format:
Prints the value of a variable
dprint [ -nowait ] variable
Prints the value of an expression
dprint [ -nowait ] expression
Arguments:
-nowait
Tells TotalView to evaluate the expression in the background. You will need to use TV::expr to obtain the results as they are not displayed.
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 quote it 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.
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).
If an event such as a $stop, SEGV, breakpoint, or the like occurs, the dprint command throws an exception describing the event. The first exception subcode returned by TV::errorCodes is the susp-eval-id (a suspension-evaluation-ID). You can use this to manipulate suspended evaluations with the dflush and TV::expr commands.
If you use -nowait, TotalView evaluates the expression in the background. It also returns a susp-eval-id that you can use to obtain the results of the evaluation.
As the CLI displays data, it passes the data through a simple more processor that prompts you after it displays each screen of text. At this time, 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:
d.1<> 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 in the [] characters. You could, of course, instead 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 or thread:
expression result
second process or thread:
expression result
...
last process or thread:
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 register by typing:
dprint \$r1
Notice that you must quote the $ since the name of the register's name includes the $. This $ is not the standard indicator that tells Tcl to fetch a variable's value. "Architectures" lists the mnemonic names assigned to registers.
Note: Do not use a $ when asking dprint to display your program's variables.
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 in 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.
f {t1.1 t2.1 t3.1} dprint {f()}
The dprint command evaluates a function contained within three threads. Note that each thread is in a different process:
Thread 1.1:
f(): 2
Thread 2.1:
f(): 3
Thread 3.1:
f(): 5
f {t1.1 t2.1 t3.1} dprint -nowait {f()}
1
This example evaluates a function without waiting. At a later time, the results are obtained using TV::expr. The number displayed immediately after the command, which is "1", is the susp-eval-id. Here is how this is done:
f t1.1 TV::expr get 1 result
2
f t2.1 TV::expr get 1 result
Thread 1.1:
f(): 2
Thread 2.1:
f(): 3
Thread 3.1:
f(): 5
3
f t3.1 TV::expr get 1 result
5