next up previous contents index
Next: Catalogs in MIDAS Up: Running a Program within Previous: Running a Program within

    
Debugging of Procedures and Modules

Normally, the command lines of a MIDAS procedure are not displayed on the terminal. To control the display of the lines of a MIDAS procedure, use the command ECHO. With ECHO/ON the lines of a MIDAS procedure are displayed on the terminal as they are read from the file and executed. This way, it is possible to get an impression of how much time various parts of a procedure need.
With ECHO/FULL the lines are displayed as they are read and if symbols have to be substituted, the lines are again displayed after substitution. To avoid echoing and return to a silent mode, enter ECHO/OFF.
The ECHO command has as parameter the procedure-level-interval where it should be applicable. Thus you can, e.g., display only the lines of a MIDAS procedure executing at level 2, etc. Echoing each command line of a MIDAS procedure will identify most of the syntax and other obvious errors. However, this may not be sufficient for long and complicated procedures.   
For these cases use the Midas Command Language Debugger:
  
DEBUG/PROCEDURE levla,levlb ON/OFF !en/disable procedure debugging
DEBUG/MODULE levla,levlb ON/OFF !en/disable module (F 77, C) debugging
SHOW/CODE comnd/qualif !display the code of related procedure
  
Once procedure debugging  is switched on, e.g., via DEBUG/PROC 1,3 ON, all MIDAS procedures executing at level 1, 2 or 3 start up in stepwise debugging mode. The prompt changes to Mdb and each command line is displayed on the terminal, and only executed when you hit \fbox{\tt Return}. Furthermore, a set of basic debugging commands may be executed, e.g. listing the preprocessed procedure code, setting and clearing break points, and switching from stepwise to continuous mode. Also the keywords may be inspected at any moment. This is an important tool because local keywords cannot be checked otherwise; once the procedure terminates, all local keywords disappear.
If you want to execute any other command, enter PAUSE to interrupt the procedure you're debugging, execute any other command you want, and enter CONTINUE to continue debugging the procedure.   
When you are in the debugger (indicated via the Mdb prompt), use the command `h' (for HELP) to display all the available debug commands.
To switch the debugging mode for procedures off, use DEBUG/PROC 1,3 off.
  
If you must debug your application program, first compile and link that program with the debugger of your host system. Make sure, that this is the same debugger as the one stored in a system keyword of MIDAS (via the command SET/MIDAS_SYSTEM debug=...). Enter the command DEBUG/MODULE to switch on the debugging mode for applications. Subsequently, your application (as well as all other programs activated via the MIDAS RUN command) will be started with the debugger of your system and you can debug it in the usual way.

Note
Typing $dbx myprog.exe (e.g. on a SUN) would also start up program myprog.exe in debug mode. But that would not tie the application into the MIDAS environment, i.e. the keywords would not be set correctly.
  
If you just want to list the preprocessed code of a MIDAS procedure use the command TRANSLATE/SHOW proc. TRANSLATE/SHOW proc X will also check all commands in the procedure for completeness, so it's a good idea to execute that command for all your MIDAS procedures.
The command SHOW/CODE comnd/qualif will display the code of the procedure which is actually executed when you enter comnd/qualif as a MIDAS command.
Note
For a detailed description of the integration of user applications into MIDAS as well as complete examples (in FORTRAN and C) see the MIDAS Environment Document.


next up previous contents index
Next: Catalogs in MIDAS Up: Running a Program within Previous: Running a Program within
Petra Nass
1999-06-09