PowerAda Debugging Mixed-Language Programs

From OC Systems Wiki!
< PowerAda:APPENDIX F. Debugger Command Reference
Revision as of 21:53, 14 April 2019 by imported>WikiVisor
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Programs that contain both Ada code and code written in another language present special problems during debugging. The following commands enable you to debug mixed-language programs using commands and expressions similar to those provided in C, C++, and assembler.

To ensure that AIX debugging information is available for any C code linked into your programs, compile the C source files with the XLC -g option. For Linux, you should compile the C source files with the gcc -g option. Because this option makes the resulting object and executable files bigger, do not use it once your program is fully debugged. On AIX, the debugger can use in the information from XCOFF stab strings in the object file, regardless of the language; the following discussion refers only to the C language.

Selecting the Language to Debug: MODE

The preceding discussion of debugging commands describes how they work while debugging Ada code. With the MODE command, you can select C mode to work with C subprograms, variables, and expressions. After debugging the C portion of the program, you can return to Ada mode. The MODE command with no argument displays the current language mode. The syntax to use is:

mode [ada | c]

The debugger starts in Ada mode. When it stops at a breakpoint, it automatically switches to the appropriate language mode, depending on whether the breakpoint is in Ada code or not.

Most commands work the same way regardless of the language mode. The major differences are in the way the debugger interprets program locations and object names:

Breakpoint locations for BREAK and UNBREAK

You can use the name of the C subprogram as either the compilation unit or the subprogram. You cannot use a name of the form CompilationUnit.Subprogram.

Expressions for PUT, PUT_LINE, and ?

These expressions refer to C objects. You can always refer to global variables. You can refer to parameters and other variables that are local to a subprogram or block only while the program is stopped inside that subprogram or block.

Expressions for :=

These expressions also refer to C objects. You can use the :layout and :type qualifiers, and the 'ADDRESS, 'SIZE, and 'LAST (for one-dimensional arrays) attributes. You can use the 0x and 0 notations to specify hexadecimal and octal numeric literals. You can only assign a value to a discrete object that has one of the C predefined types.

C Operators

You can use the '.' operator for structure components, the square brackets operators for array elements or slices, and the + and - operators. + and - must be used within square brackets, and are the only operators allowed within square brackets.