!TSS command CAll name(expr,expr,...) DONE FUnction name IF ( expr ) request MAin QUIT REturn SHow SUbroutine name [n] COntinue [n] PAUSE [n] PRINT expr, expr, ... [n] STOP n GOto label var = expr
integer di, do ... call fdebug call fdebug( di ) call fdebug( di, do )
FDEBUG is a very powerful tool for finding out where a program is going wrong. It is normally used interactively at the terminal but may be driven by input from a file. FDEBUG is entered if it is called from your program, if a breakpoint (PAUSE request) from a previous call is encountered during execution, or if you hit break after calling FDEBUG for the first time.
If you hit carriage return immediately after entering FDEBUG, you will get a traceback showing the routines called to get your program to its present context. To get a traceback again, you must first use the MA, FU or SU request to reestablish the debugging context, then hit carriage return again. Note that until FDEBUG is called the first time, hitting break in TSS will cause your program to cease execution.
In batch, FDEBUG can be invoked by including the FDS option in the operand field of the $FORT77 control line. FDEBUG requests can be planted by supplying debugging requests on logical unit 44 using $DATA~44 or equivalent control cards. This works for both EXECUTE and RLHS activities.
In TSS, if you want FDEBUG to be called during F77 run-time initialization, you can specify the +FDS option on the F77 command line. You must also call FDEBUG at some convenient point in the program (say the first executable line of the main program).
Another way to call FDEBUG during TSS Fortran run-time initialization is to specify the +FDeBug option on the F77 command. As long as +FDS was specified when the program was compiled, you can use +FDeBug when running the compiled program.
f77 .h +fdebug 05</data
This works by setting switch bit 48, so the set of commands
switch +48 f77 .h 05</data
would have the same effect.
With some exceptions, debugging requests can be executed in one of two ways. If a request is not preceded by a statement label, FDEBUG interprets the request immediately. If a request is preceded by a statement label, FDEBUG plants the request at the indicated statement. When the program is executing, such a request will be interpreted before the indicated statement is executed but after any requests previously planted at that statement are executed.
In the request descriptions below, the following conventions and notations are used.
It should be pointed out that debugging of optimized programs may be complicated by the fact that the values of certain variables are often kept in registers rather than in memory. This is particularly true of DO loop indices in loops which exit only from the bottom. In this case, it is not possible to print the value of the DO loop index (it appears to remain constant) or to make use of the value in other ways.
To print the values of variables or segments of arrays in other than the default format, it has been found useful to have your program include subroutines similar to the following.
SUBROUTINE PR (A,N,FORMAT) INTEGER A(N), FORMAT (1) WRITE (6,FORMAT) A RETURN END
FDEBUG requests like
CALL PR (ARRAY,3,"(1X,3A6)")
can be used to print data under special formats. This example prints the first three elements of ARRAY under A6 format.
To make debugging link overlay jobs less tedious, there is a system supplied subroutine of the form
SUBROUTINE LODLNK(LINK) CHARACTER*6 LINK 1 RETURN END
which is called by the LINK/LLINK overlay subroutine immediately after loading a link.
To pass control to FDEBUG after a certain link has been loaded, an appropriate conditional request may be planted in this subroutine. For example, the sequence
SUBROUTINE LODLNK 1 IF(LINK .EQ. "A") PAUSE
will plant a request which causes FDEBUG to be entered immediately after link A is loaded. Note that any requests previously planted in the region overlaid will be forgotten. The SHow request can always be used to discover which requests are still present. Note that CALL LINK can cause the currently executing link to be overlaid and thus destroy the subroutine nesting list and possibly LODLNK; therefore control is passed directly to the link entry point by LINK without calling LODLNK. In this case, it is not possible to pass control to FDEBUG and it is recommended that LLINK be used instead. Another virtue of using LLINK is that the program is more easily moved to other environments by simply supplying a dummy subroutine called LLINK.
The FDEBUG requests MAin, SUbroutine, and FUnction may not work in some programs (for unknown reasons).
When FDEBUG gets control before execution starts, it responds to requests with "symbol table empty or missing". The reason is that it has no context: use MAin, SUbroutine, or FUnction to give it one and you will be able to plant requests.
FDEBUG will not allow you to say GOTO label. You must plant this request (this is more of a restriction than a bug).
If the CAll request is used to call a debugging subroutine, break service is turned off. If the subroutine goes into a loop, no amount of hitting break will get you out.
Copyright © 1996, Thinkage Ltd.