showstat - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Debugging : showstat

showstat

display a procedure with statement numbers for debugging

showsource

display the source procedure with statement numbers for debugging

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

showstat(procName)

showstat(procName, statRange)

showsource(procName)

showsource(procName, statRange)

editsource(procName)

editsource(procName, statNum)

Parameters

procName

-

name of the procedure to display

statRange

-

statement or range of statements to display

statNum

-

statement at which to position the cursor

Description

• 

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 file name 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).

Examples

f := proc(x) if x <= 2 then print(x); print(x^2) end if; print(-x); x^3 end proc:

showstatf


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

showstatf&comma;1


f := proc(x)
   1   if x <= 2 then
           ...
       end if;
       ...
end proc

showstatf&comma;3..4


f := proc(x)
       ...
   3       print(x^2)
       end if;
   4   print(-x);
       ...
end proc

debugoptstraceproc&equals;f

forito5dofiend do

1

1

−1

2

4

−2

−3

−4

−5

125

(1)

showstatf


f := proc(x)
     |Calls Seconds  Words|
PROC |    5   0.139 2269374|
   1 |    5   0.000     15| if x <= 2 then
   2 |    2   0.138 2249128|     print(x);
   3 |    2   0.001   5695|     print(x^2)
                            end if;
   4 |    5   0.000  14516| print(-x);
   5 |    5   0.000     20| x^3
end proc

Compatibility

• 

The showsource command was introduced in Maple 2017.

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

See Also

debugopts

showstop

stopat

The Maple debugger