Totalview® Reference Guide : PART I CLI Commands : Chapter 2 CLI Commands : dprint
dprint
Evaluates and displays information
Format 
Prints the value of a variable
dprint [ -nowait ] [ -slice "slice_expr" ] variable
Prints the value of an expression
dprint [ -nowait ] [ -slice "slice_expr" ] [ -stats [ -data ]] expression
Arguments 
-nowait
Tells TotalView to evaluate the expression in the background. Use TV::expr to obtain the results, as they are not displayed.
-slice "slice_expr"
Defines an array slice—that is, a portion of the array—to print. If the programming language is C or C++, use a backslash (\) when you enter the array subscripts. For example, "\[100:110\]".
-stats
Displays statistical data about an array. When using this switch, the expression provided to dprint must resolve to an array. The -slice switch may be used with -stats to select a subset of values from the array to calculate statistics on.
-data
Returns the results of dprint -stats as data in the form of a Tcl nested associative array rather than as output to the console. See the description section for the structure of the array.
Note: This switch can be used only in conjunction with the stats switch.
variable
A variable whose value is displayed. The variable can be local to the current stack frame or it can be global. If the displayed variable is an array, you can qualify the variable’s name with a slice that displays a portion of the array,
expression
A source-language expression to evaluate and print. Because expression must also conform to Tcl syntax, you must enclose it within quotation marks it if it includes any blanks, and in braces ({}) if it includes brackets ([ ]), dollar signs ($), quotation marks ("), or 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 occurs, the dprint command throws an exception that describes 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. For example:
dfocus tdpid.dtid TV::expr get susp-eval-id
NOTE >> If the expression calls a function, the focus must not specify more than one thread for each process.
If you use the -nowait option, 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 using TV::expr.
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 stops printing.
Since the dprint command can generate a considerable amount of output, you might want to use the capture command to save the output to 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 print 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 to display a portion of an array; for example:
d.1<> p -slice "\[10:20\]" random
random slice:(10:30) = {
(10) = 0.479426
(11) = 0.877583
(12) = 0.564642
(13) = 0.825336
(14) = 0.644218
(15) = 0.764842
(16) = 0.717356
(17) = 0.696707
(18) = 0.783327
(19) = 0.62161
(20) = 0.841471
}
The following is an another way of specifying the same slice:
d.1<> set my_var \[10:20\]
d.1<> p -slice $my_var random
random slice:(10:30) = {
The following example illustrates the output from dprint -stats command:
d1.<> dprint -stats twod_array
 
Count: 2500
Zero Count: 1
Sum: 122500
Minimum: 0
Maximum: 98
Median: 49
Mean: 49
Standard Deviation: 20.4124145231932
First Quartile: 34
Third Quartile: 64
Lower Adjacent: 0
Upper Adjacent: 98
 
NaN Count: N/A
Infinity Count: N/A
Denormalized Count: N/A
 
Checksum: 41071
By adding the -data switch,
d1.<> dprint -stats -data twod_array
the statistics are returned in a Tcl nested associative array, which has the following structure:
{
<dpid.dtid>
{
Count <value>
ZeroCount <value>
Sum <value>
Minimum <value>
Maximum <value>
Median <value>
Mean <value>
StandardDeviation <value>
FirstQuartile <value>
ThirdQuartile <value>
LowerAdjacent <value>
UpperAdjacent <value>
NaNCount <value>
InfinityCount <value>
DenormalizedCount <value>
Checksum <value>
}
<dpid.dtid>
{
...
}
}
To access data for a single process/thread, use the following Tcl commands:
array set stats_data [dprint -stats -data <arrayexpression>]
array set stats $stats_data([lindex [array names stats_data] 0])
puts "Array Sum: $stats(Sum)"
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
TotalView lets you cast variables and cast a variable to an array. If you are casting a variable, the first array address is the address of the variable. For example, assume the following declaration:
float bint;
The following statement displays the variable as an array of one integer:
dprint {(int \[1\])bint:
If the expression is a pointer, the first addresses is the value of the pointer. Here is an array declaration:
float bing[2], *bp = bint;
TotalView assumes the first array address is the address of what bp is pointing to. So, the following command displays the array:
dprint {(int \[2\])bp}
You can also use the dprint command to obtain values for your computer’s registers. For example, on most architectures, $r1 is register 1. To obtain the contents of this register, type:
dprint \$r1
You must precede the dollar sign ($) with a backslash to escape it since the register’s name includes the $. This $ is not the standard indicator that tells Tcl to fetch a variable’s value. Chapter 11, "Architectures" lists the mnemonic names assigned to -registers.
NOTE >> Do not use a $ when asking the dprint command to display your program’s variables.
Command alias 
Alias
Definition
Description
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 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()}
Evaluates a function contained in three threads. 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
Evaluates a function without waiting. Later, you can obtain the results using TV::expr. The number displayed immediately after the command, which is “1”, is the susp-eval-id. The following example shows how to get this result:
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