15.4.10.3 Additions to Ada
As it does for other languages, GDB makes certain generic
extensions to Ada (see Expressions):
- If the expression E is a variable residing in memory (typically
a local variable or array element) and N is a positive integer,
then
E@N
displays the values of E and the
N-1 adjacent variables following it in memory as an array. In
Ada, this operator is generally not necessary, since its prime use is
in displaying parts of an array, and slicing will usually do this in
Ada. However, there are occasional uses when debugging programs in
which certain debugging information has been optimized away.
-
B::var
means “the variable named var that
appears in function or file B.” When B is a file name,
you must typically surround it in single quotes.
- The expression
{type} addr
means “the variable of type
type that appears at address addr.”
- A name starting with ‘$’ is a convenience variable
(see Convenience Vars) or a machine register (see Registers).
In addition, GDB provides a few other shortcuts and outright
additions specific to Ada:
- The assignment statement is allowed as an expression, returning
its right-hand operand as its value. Thus, you may enter
(gdb) set x := y + 3
(gdb) print A(tmp := y + 1)
- The semicolon is allowed as an “operator,” returning as its value
the value of its right-hand operand.
This allows, for example,
complex conditional breaks:
(gdb) break f
(gdb) condition 1 (report(i); k += 1; A(k) > 100)
- Rather than use catenation and symbolic character names to introduce special
characters into strings, one may instead use a special bracket notation,
which is also used to print strings. A sequence of characters of the form
‘["XX"]’ within a string or character literal denotes the
(single) character whose numeric encoding is XX in hexadecimal. The
sequence of characters ‘["""]’ also denotes a single quotation mark
in strings. For example,
"One line.["0a"]Next line.["0a"]"
contains an ASCII newline character (Ada.Characters.Latin_1.LF
)
after each period.
- The subtype used as a prefix for the attributes 'Pos, 'Min, and
'Max is optional (and is ignored in any case). For example, it is valid
to write
- When printing arrays, GDB uses positional notation when the
array has a lower bound of 1, and uses a modified named notation otherwise.
For example, a one-dimensional array of three integers with a lower bound
of 3 might print as
That is, in contrast to valid Ada, only the first component has a =>
clause.
- You may abbreviate attributes in expressions with any unique,
multi-character subsequence of
their names (an exact match gets preference).
For example, you may use a'len, a'gth, or a'lh
in place of a'length.
-
Since Ada is case-insensitive, the debugger normally maps identifiers you type
to lower case. The GNAT compiler uses upper-case characters for
some of its internal identifiers, which are normally of no interest to users.
For the rare occasions when you actually have to look at them,
enclose them in angle brackets to avoid the lower-case mapping.
For example,
(gdb) print <JMPBUF_SAVE>[0]
- Printing an object of class-wide type or dereferencing an
access-to-class-wide value will display all the components of the object’s
specific type (as indicated by its run-time tag). Likewise, component
selection on such a value will operate on the specific type of the
object.