DEBUG - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

DEBUG

The Maple debugger breakpoint function

 Calling Sequence DEBUG(arg1, arg2,...)

Parameters

 argN - (optional) any expression

Description

 • The DEBUG function has the effect of a breakpoint when encountered in a Maple procedure. When the DEBUG function is executed, execution stops before the next statement executed, and the debugger (implemented by the Maple function debugger) is invoked. If the debugger returns anything other than NULL, the returned value is evaluated, and the debugger function is reinvoked.
 • The stopat function (and the stopat debugger command) set breakpoints by inserting a call to the DEBUG function before the statement at which the breakpoint is set. Such breakpoints can be removed using the unstopat function (or the unstopat debugger command).
 • A breakpoint can be inserted explicitly into the source code of a Maple procedure by inserting a call to the DEBUG function. Such breakpoints cannot be removed using the unstopat function (or the unstopat debugger command).
 • Arguments passed to the DEBUG function are interpreted in one of three ways:
 • A single argument that is of type boolean makes the breakpoint conditional. The argument is evaluated in the context in which execution is about to stop, and if it does not return true, execution continues instead. To avoid the condition being evaluated too soon, it should be enclosed in unevaluation (single) quotes.
 • A single argument that is a range, N..M, with integer literal lower and upper bounds (for example, 3..5) will cause execution to stop only at the N-th through M-th times that the breakpoint is encountered since a command was last invoked from the Maple (not the debugger) prompt.
 • Any other type of argument, or any sequence of two or more arguments, is displayed by the debugger. If no arguments were passed, the debugger displays the result of the previous computation.
 • The DEBUG function returns NULL so as not to affect %, %%, and %%%.  Therefore, inserting it as the last statement of a procedure will hide the return value of the procedure, so this is not recommended. It is not possible to use stopat to set a breakpoint after the last statement in a procedure.

 • The DEBUG command is thread-safe as of Maple 15.

Examples

Note: These examples illustrate the use of these debugger commands in Maple's command-line interface. In the standard (graphical) interface, the debugger runs in its own window, with controls for most of the common commands.  See Interactive Maple Debugger for details.

 > f := proc(x,y) local a;     a := x^2; DEBUG(); a := y^2; DEBUG(Hello); a := (x+y)^2 end proc:
 > $f\left(2,3\right)$

 4 f: 3    a := y^2; DBG> cont Hello f: 5    a := (x+y)^2; DBG> cont

 ${25}$ (1)