Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » debugging » the debugger » step
next | previous | forward | backward | up | index | toc

step -- step by single lines in the debugger

Description

One useful way to debug code suspected of being in error is to insert an explicit error message, such as error "debug me", and start stepping from there, as in the following demonstration.

i1 : load "Macaulay2Doc/demos/demo2.m2"
i2 : code f

o2 = ${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.
     m2:6:4-12:6: --source code:
     f = t -> (
          x := 1;
          error "debug me";
          y := t+1;
          z := 1/t;
          w := x+t;
          )
i3 : f 0
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:8:10:(3):[1]: error: debug me
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:8:10:(3): entering debugger (enter 'help' to see commands)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:8:5
-8:21: --source code:
     error "debug me";
ii4 : return
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:11:(3):[1]: --stepping limit reached
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:11:(3): entering debugger (enter 'help' to see commands)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:5
-9:13: --source code:
     y := t+1;
ii5 : current

oo5 = local-assign 2 0 2-OP + local-fetch 0 0
                              1

oo5 : PseudocodeClosure
ii6 : disassemble oo

oo6 = (local-assign 2 0 (2-OP + (local-fetch 0 0) 1))
ii7 : step(-3)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:11:(3):[1]: --evaluating: (local-assign 2 0 (2-OP + (local-fetch 0 0) 1))
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:11:(3):[1]: --evaluating: (2-OP + (local-fetch 0 0) 1)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:10:(3):[1]: --evaluating: (local-fetch 0 0)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:12:(3):[1]: --stepping limit reached
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:12:(3): entering debugger (enter 'help' to see commands)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:9:
12-9:13: --source code:
     y := t+1;
ii8 : step
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:10:11:(3):[1]: --stepping limit reached
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:10:11:(3): entering debugger (enter 'help' to see commands)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:10:
5-10:13: --source code:
     z := 1/t;
ii9 : step
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:10:11:(3):[1]: error: division by zero
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:10:11:(3): entering debugger (enter 'help' to see commands)
${prefix}/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:10:
10-10:13: --source code:
     z := 1/t;
ii10 : t

oo10 = 0

See also

For the programmer

The object step is a keyword.


The source of this document is in Macaulay2Doc/ov_debugging.m2:211:0.