Avoiding Pitfalls in Multi-Language Programming
Turn on range and overflow checking in languages that support it.
For languages that support level 2 optimization, the optimizer can sometimes detect uninitialized
variables and give a warning.
C, Cobol, Fortran and Pascal support the XDB and Toolset symbolic debuggers.
Use compiler options to print code offsets and symbol maps for assembly-
level debugging. Symbol
maps can also help detect inconsistencies with structure layouts that
are shared between multiple
languages.
Debugging block-mode applications can be done
by redirecting I/O to a hardwired terminal or nailed
network device.
Details:
Some languages have an option to turn on automatic initialization. If the program works with
initialization on and fails with it off, this could indicate the problem is due to an uninitialized variable.
In the linker, an indirect file can contain options to be passed to the link command. Some useful
debugging options are:
-v Display verbose messages during linking.
For each library module that is loaded, the linker
indicates which symbol caused that module to be loaded.
-y <symbol> Indicate each file in which <symbol> appears. Many such options can be given to
trace
many symbols, but -y must precede each one.
Even when the outer block language does not
support the Symbolic Debugger (XDB), routines written
in C, Cobol, Fortran and Pascal can be compiled for XDB debugging
and linked into the program.
This will allow those routines to be symbolically debugged, while the rest of the program can be
debugged at the assembly level.
XDB does not currently support debugging code
in XLs. Statically link all code you wish to
symbolically debug into the program file.
By default, XDB uses the language syntax of
the current procedure. This can cause confusion when
debugging programs written in multiple languages. For example, in XDB C
language mode, the
command
p x = 0
will assign 0 to x and print 0, the new value
of x. In Pascal mode, it will print 0 if x is not 0, but the
value of x will not change.
p $lang
will print the name of the language currently
being used. If you explicitly set $lang to a particular
language, all debugging commands will use this language syntax
regardless of the language of the
procedure you are debugging.
RPG has a DEBUG operator which may be used
(in the RPG program only, not in the external
subroutine) to display indicator settings and the contents of a field wherever it is used in C-
specs.
This may not be adequate for debugging, particularly in the external procedure. The only
other
approach is to use NMDEBUG. RPG does not support XDB or
Toolset. RPG RLABL global items can
be referenced by name in NMDEBUG.
One place where you can get in trouble is in
debugging applications that use RSI or VPLUS. Since
Page
11
of
14
Avoiding Pitfalls in Multi
-
Language Programming
7/18/2008
http://www.hp.com/cgi
-
bin/pf
-
new.cgi?IN=http://jazz.external.hp.com/papers/lang/pgm_pi
...