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.

Scoping and Symbol Names<br />

program) as the root. At the next level are executable files and dynamic<br />

libraries; further down are compilation units (source files), procedures,<br />

modules, and other scoping units (for example, blocks) supported by the<br />

programming language. Qualifying a symbol is equivalent to describing the<br />

path to a file in UNIX file systems.<br />

A symbol is fully scoped when you name all levels of its tree. The following<br />

example shows how to scope a symbol and also indicates parts that are<br />

optional:<br />

[#executable-or-lib#][file#][procedure-or-line#]symbol<br />

The pound sign (#) separates elements of the fully qualified name.<br />

Because of the number of different types of elements that can appear in your program, a<br />

complete description of what can appear and their possible order is complicated and<br />

unreadable. In contrast, after you see a name in the Stack Frame Pane, it is easy to<br />

read a variable’s scoped name.<br />

<strong>TotalView</strong> interprets most programs and components as follows:<br />

� You do not need to qualify file names with a full path, and you do not<br />

need to use all levels in a symbol’s scoping tree. <strong>TotalView</strong> conventions<br />

here are similar to the way UNIX displays file names.<br />

� If a qualified symbol begins with #, the name that follows indicates the<br />

name of the executable or shared library (just as an absolute file path begins<br />

with a directory immediately in the root directory). If you omit the executable<br />

or library component, the qualified symbol doesn’t begin with #.<br />

� The source file’s name can appear after the possibly omitted executable<br />

or shared library.<br />

� Because programming languages typically do not let you name blocks,<br />

that portion of the qualifier is specified using the symbols $b followed by<br />

a number that indicates which block. For example, the first unnamed<br />

block is named $b1, the second is $b2, and so on.<br />

You can omit any part of the scope specification that <strong>TotalView</strong> doesn’t<br />

need to uniquely identify the symbol. Thus, foo#x identifies the symbol x in<br />

the procedure foo. In contrast, #foo#x identifies either procedure x in executable<br />

foo or variable x in a scope from that executable.<br />

Similarly, #foo#bar#x could identify variable x in procedure bar in executable<br />

foo. If bar were not unique in that executable, the name would be<br />

ambiguous unless you further qualified it by providing a file name. Ambiguities<br />

can also occur if a file-level variable (common in C programs) has the<br />

same name as variables declared in functions in that file. For instance,<br />

bar.c#x refers to a file-level variable, but the name can be ambiguous when<br />

there are different definitions of x embedded in functions that occur in the<br />

same file. In this case, you need to enter bar.c#b1#x to identify the scope<br />

that corresponds to the outer level of the file (that is, the scope that contains<br />

line 1 of the file).<br />

332 Chapter 14: Examining and Changing Data

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

Saved successfully!

Ooh no, something went wrong!