Difference between revisions of "Debugging with GT.M"

From VistApedia
Jump to: navigation, search
(Simple 'IDE' with GT.M)
(Added glossary link to Prompt~)
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
Back to [[Programming VistA Issues]]
 +
 
=== Simple 'IDE' with GT.M ===
 
=== Simple 'IDE' with GT.M ===
  
This is a simple (pre pre alpha) IDE created with GT.M debugging commands:
+
This is a simple debugger created with GT.M debugging commands:
  
 +
It will currently show the source code, with the current line highlighted, as it steps through the code.
 +
 +
Here are the modules
 
[[TMGIDE.m]]
 
[[TMGIDE.m]]
 
[[TMGTERM.m]]
 
[[TMGTERM.m]]
 
[[TMGTPSTP.m]]
 
[[TMGTPSTP.m]]
 +
 +
'''NOTE: These modules have been greatly modified since first posted. The latest versions can be found in the TMG code library, which can be downloaded [http://groups.google.com/group/Hardhats/files here].  Look for VistAMisc_TMG-library_Kevin_<date>'''
 +
 +
 +
To invoke:
 +
do ^TMGIDE
 +
 +
K. Toppenberg
  
 
=== GT.M Debugging commands ===
 
=== GT.M Debugging commands ===
 
This information is from the GT.M Programmer's Manual.  I'll just summarize a few points.
 
This information is from the GT.M Programmer's Manual.  I'll just summarize a few points.
 +
 +
* Dumping Information (actually just writes it out) when an error occurs.
 +
* ZSHOW argument
 +
** ZSHOW "*" dumps all info known
 +
** ZSHOW "S" dumps the current stack
 +
** ZSHOW "B" dumps the current breakpoints established with ZBREAK command (below)
  
  
Line 40: Line 59:
 
     Shows the current position of the current line of execution  
 
     Shows the current position of the current line of execution  
 
   (or the last line exececuted in case of an error)
 
   (or the last line exececuted in case of an error)
 +
  From the manual: $ZPOSITION is a read-only GT.M special variable that provides another tool
 +
  for locating and displaying the current line. It contains the current entry reference as a
 +
  character string in the format label+offset^routine, where the label is the closest
 +
  preceding label. The current entry reference appears at the top of the M invocation stack,
 +
  that can also be displayed with a ZSHOW “S” command.
 +
  <hr>
 +
  Example:
 +
  GTM>W $ZPOS
 +
  name+2^dmex
 +
  This example writes the current line position.
 +
  
 
* ZWRITE
 
* ZWRITE
 
     Shows the entire variable table, displaying all defined variables.
 
     Shows the entire variable table, displaying all defined variables.
  
* ZBREAK address
+
* ZBREAK address:CodeToExecute
     Toggles a break point at address
+
     Toggles a break point at address.  If CodeToExecute is null, then a
     It is possible to have the breakpoint execute code, and then resume. See manual.
+
     default value of break is used (dropping one back to the command line.)
 +
    If CodeToExecute does not contain break, zbreak (or is not null) then control
 +
    will not be dropped to the command line GTM>
 +
 
 +
    I believe that GT.M maintains only ONE breakpoint.
 +
   
 +
    e.g. GTM>ZBREAK Label+1^MyFunct:"set x=1"
  
 
* ZSTEP x
 
* ZSTEP x
 
     Will execute the program one line at a time.  I think this would be typically
 
     Will execute the program one line at a time.  I think this would be typically
     used after a ZBREAK drops command back to GT.M> prompt.
+
     used after a ZBREAK drops command back to GT.M> [[prompt~|Prompt]].
 
       ZSTEP INTO -- start execution at current execution point, and stops at
 
       ZSTEP INTO -- start execution at current execution point, and stops at
 
                     next line (even if that line is in a subroutine).
 
                     next line (even if that line is in a subroutine).
Line 65: Line 101:
  
 
.. More later
 
.. More later
 +
 +
[[Category:GT.M]]

Latest revision as of 09:48, 3 March 2012

Back to Programming VistA Issues

Simple 'IDE' with GT.M

This is a simple debugger created with GT.M debugging commands:

It will currently show the source code, with the current line highlighted, as it steps through the code.

Here are the modules TMGIDE.m TMGTERM.m TMGTPSTP.m

NOTE: These modules have been greatly modified since first posted. The latest versions can be found in the TMG code library, which can be downloaded here. Look for VistAMisc_TMG-library_Kevin_<date>


To invoke:

do ^TMGIDE

K. Toppenberg

GT.M Debugging commands

This information is from the GT.M Programmer's Manual. I'll just summarize a few points.

  • Dumping Information (actually just writes it out) when an error occurs.
  • ZSHOW argument
    • ZSHOW "*" dumps all info known
    • ZSHOW "S" dumps the current stack
    • ZSHOW "B" dumps the current breakpoints established with ZBREAK command (below)


  • $ECODE
   This is a list of past errors, separated by commas. 
   Subsequent errors are added to the end of the list.
   Example:
     GTM>w $ECODE
     ,M6,Z150373850, 
   Errors beginning with: "M" are standard errors
                          "U" are user errors
                          "Z" are GT.M errors
  • $ZSTATUS
   This is detail about the most recent error.
   Example:
     GTM>w $ZSTATUS
     150373850,SubName+3^MyFunct,%GTM-E-UNDEF, Undefined local variable: Jxack
  • $ZMESSAGE(x)
   This will give a text message for a given error number.
   Example: To get details about the error number, 150373850, given above...
     GTM>w $ZMESSAGE(150373850)
     %GTM-E-UNDEF, Undefined local variable: !AD
  • ZPRINT x (e.g. ZPRINT SubName+3^MyFunct)
   This will display the line that cause the program exception.
   The 'x' may be obtained from $ZSTATUS, or from $ZPOS (see below)
  • $ZPOSITION (OR $ZPOS)
   Shows the current position of the current line of execution 
  (or the last line exececuted in case of an error)
  From the manual: $ZPOSITION is a read-only GT.M special variable that provides another tool
  for locating and displaying the current line. It contains the current entry reference as a
  character string in the format label+offset^routine, where the label is the closest 
  preceding label. The current entry reference appears at the top of the M invocation stack,
  that can also be displayed with a ZSHOW “S” command.

  Example:
  GTM>W $ZPOS
  name+2^dmex
  This example writes the current line position.


  • ZWRITE
   Shows the entire variable table, displaying all defined variables.
  • ZBREAK address:CodeToExecute
   Toggles a break point at address.  If CodeToExecute is null, then a 
   default value of break is used (dropping one back to the command line.)
   If CodeToExecute does not contain break, zbreak (or is not null) then control
   will not be dropped to the command line GTM>
   I believe that GT.M maintains only ONE breakpoint.
   
   e.g. GTM>ZBREAK Label+1^MyFunct:"set x=1" 
  • ZSTEP x
   Will execute the program one line at a time.  I think this would be typically
   used after a ZBREAK drops command back to GT.M> Prompt.
     ZSTEP INTO -- start execution at current execution point, and stops at
                   next line (even if that line is in a subroutine).
     ZSTEP [OVER] -- start execution at current exec. point, and stop at the 
                   next line at the same level on the invocation stack.
     ZSTEP OUTOF -- ??
  • ZCONTINUE
   Continue execution from break point.
  • $STACK AND $ZLEVEL
   $STACK starts at 0 and each DO inc's the value, each QUIT dec's it
   $ZLEVEL is $STACK+1

.. More later