30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using Built-in Variables and Statements<br />

The built-in variables let you create thread-specific breakpoints from the<br />

expression system. For example, the $tid variable and the $stop built-in function<br />

let you create a thread-specific breakpoint, as the following code shows:<br />

if ($tid == 3)<br />

$stop;<br />

This tells <strong>TotalView</strong> to stop the process only when the third thread evaluates<br />

the expression.<br />

You can also create complex expressions using these variables; for example:<br />

if ($pid != 34 && $tid > 7)<br />

printf (“Hello from %d.%d\n”, $pid, $tid);<br />

Using any of the following variables means that the eval point is interpreted<br />

instead of compiled: $clid, $duid, $nid, $processduid, $systid, $tid, and<br />

$visualize. In addition, $pid forces interpretation on AIX.<br />

You can’t assign a value to a built-in variable or obtain its address.<br />

Using Built-In Statements<br />

<strong>TotalView</strong> statements help you control your interactions in certain circumstances.<br />

These statements are available in all languages, and are described<br />

in the following table. The most commonly used statements are $count,<br />

$stop, and $visualize.<br />

Statement Use<br />

$count expression<br />

$countprocess expression<br />

Sets a process-level countdown breakpoint.<br />

When any thread in a process executes this<br />

statement for the number of times specified by<br />

expression, the process stops. The other processes in<br />

the control group continue to execute.<br />

$countall expression Sets a program-group-level countdown breakpoint.<br />

All processes in the control group stop when any<br />

process in the group executes this statement for the<br />

number of times specified by expression.<br />

$countthread expression Sets a thread-level countdown breakpoint.<br />

When any thread in a process executes this<br />

statement for the number of times specified by<br />

expression, the thread stops. Other threads in the<br />

process continue to execute.<br />

If the target system cannot stop an individual thread,<br />

this statement performs the same as $countprocess.<br />

A thread evaluates expression when it executes $count<br />

for the first time. This expression must evaluate to a<br />

positive integer. When <strong>TotalView</strong> first encounters this<br />

variable, it determines a value for expression. <strong>TotalView</strong><br />

does not reevaluate until the expression actually<br />

stops the thread. This means that <strong>TotalView</strong> ignores<br />

changes in the value of expression until it hits the<br />

breakpoint. After the breakpoint occurs, <strong>TotalView</strong><br />

reevaluates the expression and sets a new value for<br />

this statement.<br />

The internal counter is stored in the process and<br />

shared by all threads in that process.<br />

<strong>TotalView</strong> <strong>Users</strong> <strong>Guide</strong>: version 8.7 395

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

Saved successfully!

Ooh no, something went wrong!