Fancy ZSTEP GTM: Difference between revisions

From VistApedia
Jump to navigationJump to search
Created page with "General procedure: # Put a breakpoint on the code you want to debug: ZB UPDATE^DIE # Set special ZSTEP # Execute the code you want to debug: S FDA(3.1,"?+1,",.01)="BOO" D UPDA..."
 
Added detection of a write to the screen.
 
Line 15: Line 15:
<pre>
<pre>
b:($g(olddic)'=$d(DIC(0)))  s olddic=$d(DIC(0)) zstep into
b:($g(olddic)'=$d(DIC(0)))  s olddic=$d(DIC(0)) zstep into
</pre>
Detect if a write is made ($X changes):
<pre>
set $zstep="b:$g(oldx)'=$x  s oldx=$x zstep into"
</pre>
</pre>



Latest revision as of 21:54, 8 January 2025

General procedure:

  1. Put a breakpoint on the code you want to debug: ZB UPDATE^DIE
  2. Set special ZSTEP
  3. Execute the code you want to debug: S FDA(3.1,"?+1,",.01)="BOO" D UPDATE^DIE(,$NA(FDA))
  4. Once you hit the breakpoint, type ZSTEP INTO to activate stepping. The entire routine execution will be shown.


Regular ZSTEP (save dev and restore dev after each line)

n oldio s oldio=$i u 0 w $t(@$zpos),! b  u oldio

Detect if a variable has changed (in this case, $data of DIC(0)):

b:($g(olddic)'=$d(DIC(0)))  s olddic=$d(DIC(0)) zstep into

Detect if a write is made ($X changes):

set $zstep="b:$g(oldx)'=$x  s oldx=$x zstep into"

Print source code while executing

S $ZSTEP="W $ZPOS,?20,$T(@$ZPOS),! ZSTEP INTO"

You can combine these together, for example, to print all executed lines and stop when a variable changes. Here's how I did that:

n oldio s oldio=$i u 0 b:($g(olddic)'=$d(DIC(0)))  s olddic=$d(DIC(0)) zp @$zpos u oldio zstep into