showstat
display a procedure with statement numbers for debugging
showsource
display the source procedure with statement numbers for debugging
editsource
open the source file containing procedure with cursor at line of statement number
Calling Sequence
Parameters
Description
Examples
Compatibility
showstat(procName)
showstat(procName, statRange)
showsource(procName)
showsource(procName, statRange)
showsource(fileName)
showsource(fileName, statRange)
editsource(procName)
editsource(procName, statNum)
editsource(fileName)
editsource(fileName, statNum)
procName
-
name of the procedure to display
statRange
statement or range of statements to display
fileName
string; name of a Maple language source file containing a procedure
statNum
statement at which to position the cursor
The showstat function displays a procedure, with at most one statement per line, and with a statement number preceding each line. Statements are numbered consecutively, depth first, starting at 1. Statement numbers are used when using the debugger.
If a statement has a breakpoint associated with it, or if execution is currently stopped at the statement, the statement number is followed by one or two of the following characters:
*
There is a breakpoint at this statement.
?
There is a conditional breakpoint at this statement.
!
Execution is currently stopped here.
If showstat is called with no arguments, all procedures with breakpoints in them are displayed.
The statRange, if specified, can be either an integer, or a range of integers. In either case, only the specified statements are displayed. Elided statements are indicated by ... in the output.
If the procedure specified by procName has tracing information associated with it (see debugopts), showstat shows this information preceding each statement in the procedure. Three columns are displayed. The first column indicates the number of times that the statement has been executed. The second column indicates the amount of CPU time spent within the statement (including time spent within the body of a control structure, such as an if statement). The third column shows the amount of memory, in machine words, allocated by all executions of the statement (including memory allocated by statements within the body of a control structure). See the examples section for a sample of tracing information output.
Procedures that are exported from a module can be displayed by calling showstat(moduleName:-procedureName).
Procedures that are local to a module, and thus not normally accessible outside the module, can be displayed by calling showstat(moduleName::procedureName).
Calling showstat with a module name instead of a procedure name displays the module's ModuleApply procedure (if it has one).
The showsource command is similar to showstat, but displays the original source code corresponding to the requested statements, if that source code is available and, in the case of procedures retrieved from libraries, kernelopts(keepdebuginfo) is true. If source code is not available, showsource raises a warning and then produces the same output as showstat.
The editsource command opens the file containing the procedure, and positions the cursor at the line corresponding to the specified statement number. If source code is not available, editsource displays a warning and does nothing.
The invocation of the text editor is controlled by the global variable `debugger/editor`. This should be set to a string specifying a shell command that will open the editor. The string should contain "%s" to indicate where the filename should appear in the command, and "%d" to indicate the line number. For example, the following string will cause editsource to use "gvim" (the graphics version of "vim") on most Linux installations:
`debugger/editor` := "gvim +%d '%s'";
If you usually use a non-graphical editor (one that runs in a terminal window), a command like this will be more appropriate:
`debugger/editor` := "xterm -e vim +%d '%s' &";
The editor command should be one that opens the editor in a separate window and then returns immediately to the calling process, otherwise the Maple debugger prompt will not reappear until the editor is closed. The second example above uses "&" to put the opened terminal in the background (this was not necessary for the first example because "gvim" does this automatically).
Both showsource and editsource can also be used by specifying a filename instead of a procedure name, as specified in the description of stopat.
f := proc(x) if x <= 2 then print(x); print(x^2) end if; print(-x); x^3 end proc:
showstat⁡f
f := proc(x) 1 if x <= 2 then 2 print(x); 3 print(x^2) end if; 4 print(-x); 5 x^3 end proc
showstat⁡f,1
f := proc(x) 1 if x <= 2 then ... end if; ... end proc
showstat⁡f,3..4
f := proc(x) ... 3 print(x^2) end if; 4 print(-x); ... end proc
debugopts⁡traceproc=f
forito5dof⁡ienddo
1
−1
2
4
−2
−3
−4
−5
125
f := proc(x) |Calls Seconds Words| PROC | 5 0.206 2934641| 1 | 5 0.000 15| if x <= 2 then 2 | 2 0.205 2914030| print(x); 3 | 2 0.001 5825| print(x^2) end if; 4 | 5 0.000 14751| print(-x); 5 | 5 0.000 20| x^3 end proc
The showsource command was introduced in Maple 2017.
For more information on Maple 2017 changes, see Updates in Maple 2017.
The editsource command was introduced in Maple 2019.
For more information on Maple 2019 changes, see Updates in Maple 2019.
The showsource and editsource commands were updated in Maple 2022.
The fileName parameter was introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
See Also
debugopts
showstop
stopat
The Maple debugger
Download Help Document