Contents|Index|Previous|Next
Modula-2

The following documentation describes specific Modula-2 extensions for GDB. The extensions made to GDB to support Modula-2 only support output from the GNU Modula-2 compiler (currently in development). Other Modula-2 compilers are not currently supported, and attempting to debug executables produced by them is most likely to give an error as GDB reads in the executable’s symbol table.

Operators

Operators must be defined on values of specific types. For instance, + is defined on numbers and not on structures. Operators are often defined on groups of types. For the purposes of Modula-2, the following definitions hold.

The following operators are supported, and appear in order of increasing precedence. Built-in functions and procedures

Modula-2 also makes available several built-in procedures and functions. In describing these, the following meta-variables are used:

Constants

GDB allows you to express the constants of Modula-2 in the following ways:

Modula-2 defaults

If type and range checking are set automatically by GDB, they both default to on whenever the working language changes to Modula-2. This happens regardless of whether you, or GDB, selected the working language.

If you allow GDB to set the language automatically, then entering code compiled from a file whose name ends with ‘.mod’ sets the working language to Modula-2. See Setting the working language for further details.

Deviations from standard Modula-2

A few changes have been made to make Modula-2 programs easier to debug. This is done primarily via loosening its type strictness.

Modula-2 type and range checks
  GDB considers two Modula-2 variables type equivalent if they have the following criteria. As long as type checking is enabled, any attempt to combine variables whose types are not equivalent is an error. Range checking is done on all mathematical operations, assignment, array index bounds, and all built-in functions and procedures.

The scope operators, :: and .

There are a few subtle differences between the Modula-2 scope operator (.) and the GDB scope operator (::). The two have similar syntax:

scope is the name of a module or a procedure, module, the name of a module, and id is any declared identifier within your program, except another module. Using the :: operator makes GDB search the scope specified by scope for the identifier id. If it is not found in the specified scope, then GDB searches all scopes enclosing the one specified by scope.

Using the . operator makes GDB search the current scope for the identifier specified by id that was imported from the definition module specified by module. With this operator, it is an error if the identifier, id, was not imported from definition module, module, or if id is not an identifier in module.

GDB and Modula-2

Some GDB commands have little use when debugging Modula-2 programs. Five subcommands of set print and show print apply specifically to C and C++:‘vtbl’, ‘demangle’, ‘asm-demangle’, ‘object’, and ‘union’. The first four apply to C++, and the last to the C union type, which has no direct analogue in Modula-2.

The @ operator (see Expressions), while available while using any language, is not useful with Modula-2. Its intent is to aid the debugging of dynamic arrays, which cannot be created in Modula-2 as they can in C or C++. However, because an address can be specified by an integral constant, the construct ‘{type}adrexp’ is still useful. (see Expressions)

In GDB scripts, the Modula-2 inequality operator # is interpreted as the beginning of a comment. Use <> instead.


Top|Contents|Index|Previous|Next