This section contains some basic examples that show what SCA can
do to help you with your programs. The examples have very little
explanation. For a more detailed explanation of the underlying
concepts, see the Basic_Query_Concepts help topic. The remainder
of this section is written in terms that are specific to Ada
programs.
If you want to follow along and try the examples, you will need to
have an SCA library available. The examples use generic variable
names (such as 'i'). You will have to substitute variable names that
exist in your code when trying the examples.
The first example is the easiest query: It lets you find all the
items in your SCA library named 'i', and shows you all the places
where they appear (all occurrences of 'i').
FIND i
You can search for any name in this manner, including using
wildcard characters (for example, FIND i*).
Suppose you are looking for an occurrence, and you know that
it occurs in a particular file. The following query finds all
occurrences of items that are named 'i' but will then limit them
to those which happen to occur in the file named PROG.ADA.
FIND i AND FILE_SPEC="PROG.ADA"
Another typical question one might ask is, "Find all the places
where this item is assigned to (or read from, called, declared,
and so forth)." The next example finds all occurrences of items
that are named 'i', but then limits them to only those occurrences
where 'i' is assigned a value:
FIND i AND OCCURRENCE=WRITE
(SCA understands many occurrence classes other then WRITE. See the
help subtopics under Getting_Started for tables containing all the
SCA attributes and their corresponding meanings in Ada.)
Often, you only want to know where (in what file or package) a
particular function is, so that you can go to it and edit it.
You can use the first query (where 'i' will be the name of the
function) and then look through the output. The output will
include all occurrences of the function, one of which would be
its declaration, which you can then select. Or, you can ask SCA to
limit the search for you by typing the following query:
FIND i AND OCCURRENCE=PRIMARY
In SCA terms, a primary declaration is the most significant
declaration of an item. For an Ada function, this means the body
of the function, or package, or generic, and so forth. This is in
contrast to the specification, which is considered an associated
declaration.
Another problem you might have is that there are many different
items in your system having a given name. Some may be variables;
others may be functions, constants, tasks, and so forth. Suppose
you want to find only the functions named i. Again, the query
FIND i will give you what you want, but it will also give you much
more. It is preferable to issue the following query:
FIND i AND SYMBOL_CLASS=FUNCTION
The previous four examples have selected information based on two
attributes. The last example selected information based on a name
attribute (in this case, i) and a symbol class attribute (in this
case, FUNCTION). Note how the attributes are combined using the
boolean operator AND. In general, you can select items out of your
library based on any combination of attributes, using AND as well
as the other logical operators OR, XOR, and NOT.
The next example shows another primary feature of SCA - the
ability to display relationships between items. This example shows
the most common use of this feature. It finds the complete call
tree (that is, all functions called directly and indirectly) of
the function named i.
FIND CALLED_BY (i, DEPTH=ALL)
If you want to limit the depth of the call tree, replace the
keyword ALL by any positive integer.
To obtain help on the following topics, request help as indicated.
o For help on query language, see the Basic_Query_Concepts help
topic.
o For help on libraries, see the Building_An_SCA_Library help
topic.