<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>step -- step by single lines in the debugger</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="___Stop__Before__Computation.html">next</a> | <a href="_stdio.html">previous</a> | <a href="___Stop__Before__Computation.html">forward</a> | <a href="_stdio.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>step -- step by single lines in the debugger</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>step n</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>n</tt>, <span>an <a href="___Z__Z.html">integer</a></span></span></li> </ul> </div> </li> <li><div class="single">Consequences:<ul><li>This command is active within the debugger. The current expression is executed and execution is continued until <tt>n</tt> lines of source code whose load depth is as large as <a href="_error__Depth.html" title="set the error printing depth">errorDepth</a> have been encountered. If <tt>n</tt> is omitted, then 1 is used. If <tt>n</tt> is negative then instead, <tt>n</tt> microsteps in the inner interpreter are executed and traced.</li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><p>One useful way to debug code suspected of being in error is to insert an explicit error message, such as <tt>error "debug me"</tt>, and start stepping from there, as in the following demonstration.</p> <table class="examples"><tr><td><pre>i1 : load "Macaulay2Doc/demo2.m2"</pre> </td></tr> <tr><td><pre>i2 : code f o2 = /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:6:7-12:13: --source code: f = t -> ( x := 1; error "debug me"; y := t+1; z := 1/t; w := x+t; )</pre> </td></tr> <tr><td><pre>i3 : f 0 /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:8:6:(3):[1]: error: debug me /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:8:6:(3):[1]: --entering debugger (type help to see debugger commands) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:8:6-8:6: --source code: error "debug me";</pre> </td></tr> <tr><td><pre>ii4 : help --loading the Macaulay2 documentation from /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/ oo4 = --debugging control: return -- bypass current expression, return null, stop return x -- bypass current expression, return x, stop step -- step 1 line step n -- step n lines step (-n) -- trace n microsteps end (or eof char) -- enter debugger one level up continue -- leave the debugger, continuing execution -- with current expression break -- leave the debugger, returning to top level --debugging information: listLocalSymbols -- display local symbols and their values listUserSymbols -- display user symbols and their values current -- the current expression; initially, the one -- that produced an error code current -- source code of current expression value current -- execute current expression, obtain value disassemble current -- display microcode of current expression currentString -- the string being evaluated by 'value', if -- an error occurred within it -- emacs commands in *M2* buffer: RET -- on an file/position line, go to source</pre> </td></tr> <tr><td><pre>ii5 : return /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:8:(3):[1]: --stepping limit reached /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:8:(3):[1]: --entering debugger (type help to see debugger commands) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:8-9:13: --source code: y := t+1;</pre> </td></tr> <tr><td><pre>ii6 : disassemble current oo6 = (store 2 0 (2-OP + (fetch 0 0) 1))</pre> </td></tr> <tr><td><pre>ii7 : step(-3) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:8:(3):[1]: --evaluating: (store 2 0 (2-OP + (fetch 0 0) 1)) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:12:(3):[1]: --evaluating: (2-OP + (fetch 0 0) 1) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:11:(3):[1]: --evaluating: (fetch 0 0) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:13:(3):[1]: --stepping limit reached /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:13:(3):[1]: --entering debugger (type help to see debugger commands) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:9:13-9:13: --source code: y := t+1;</pre> </td></tr> <tr><td><pre>ii8 : step /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:10:8:(3):[1]: --stepping limit reached /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:10:8:(3):[1]: --entering debugger (type help to see debugger commands) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:10:8-10:13: --source code: z := 1/t;</pre> </td></tr> <tr><td><pre>ii9 : step /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:10:12:(3):[1]: error: division by zero /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:10:12:(3):[1]: --entering debugger (type help to see debugger commands) /builddir/build/BUILD/Macaulay2-1.3.1-r10737/Macaulay2/packages/Macaulay2Doc/demo2.m2:10:11-10:13: --source code: z := 1/t;</pre> </td></tr> <tr><td><pre>ii10 : t oo10 = 0</pre> </td></tr> </table> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_debugging.html" title="">debugging</a></span></li> </ul> </div> <div class="waystouse"><h2>For the programmer</h2> <p>The object <a href="_step.html" title="step by single lines in the debugger">step</a> is <span>a <a href="___Keyword.html">keyword</a></span>.</p> </div> </div> </body> </html>