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

finish -- finish the current stack frame in the debugger

Description

One useful way to debug code suspected of being in error is to insert an explicit breakpoint, such as breakpoint "debug me", and start stepping from there. Once you have found the issue within a function, you can call finish to finish the function call. In the following example, the function G calls the function F which has a breakpoint defined inside of it. We execute G(1) which will stop at the defined breakpoint. We can step to get the next line. Once we see that next line, we want to run through the rest of the call to F but stop as soon as we get back up to the main call of G. The final call to continue then finishes the call to G.

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

o2 = /home/m2user/rpmbuild/BUILD/Macaulay2-1.26.06-build/Macaulay2-1.26.06/
     M2/Macaulay2/packages/Macaulay2Doc/demos/demo2.m2:14:4-20:6: --source
     code:
     F = t -> (
          x := 1;
          breakpoint "debug me";
          y := t+1;
          z := 1/t;
          w := x+t;
          )
i3 : code G

o3 = /home/m2user/rpmbuild/BUILD/Macaulay2-1.26.06-build/Macaulay2-1.26.06/
     M2/Macaulay2/packages/Macaulay2Doc/demos/demo2.m2:22:4-26:1: --source
     code:
     G = t -> (
          x := 1;
          F(t);
          Z := "Zedd"
     )
i4 : G(1)
/usr/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:16:16:(3): entering debugger (enter 'help' to see commands)
/home/m2user/rpmbuild/BUILD/Macaulay2-1.26.06-build/Macaulay2-1.26.06/M2/
Macaulay2/packages/Macaulay2Doc/demos/demo2.m2:16:16-16:26: --source code:
     breakpoint "debug me";
ii5 : step
/usr/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:16:16:(3):[3]: unhandled step command
/usr/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:17:11:(3):[3]: --stepping limit reached
/usr/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:17:11:(3): entering debugger (enter 'help' to see commands)
/home/m2user/rpmbuild/BUILD/Macaulay2-1.26.06-build/Macaulay2-1.26.06/M2/
Macaulay2/packages/Macaulay2Doc/demos/demo2.m2:17:5-17:13: --source code:
     y := t+1;
ii6 : finish
/usr/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:25:10:(3):[2]: --stepping limit reached
/usr/share/Macaulay2/Macaulay2Doc/demos/demo2.m2:25:10:(3): entering debugger (enter 'help' to see commands)
/home/m2user/rpmbuild/BUILD/Macaulay2-1.26.06-build/Macaulay2-1.26.06/M2/
Macaulay2/packages/Macaulay2Doc/demos/demo2.m2:25:5-25:16: --source code:
     Z := "Zedd"
ii7 : continue

o7 = Zedd

See also

For the programmer

The object finish is a keyword.


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