tracelast
show the Maple call stack as of the most recent exception
Calling Sequence
Description
Examples
Compatibility
tracelast;
The tracelast command will display the Maple call stack from the time of the last exception that occurred (whether it was trapped by a try-catch statement or not). This is the same display that would have been generated if printlevel had been set to 3 or higher at the time the exception occurred, and the exception had not been trapped.
The tracelast command will only work at the top level. It cannot be executed from within a procedure.
The information provided by tracelast is transient. It can become unavailable at any time that Maple does a garbage collection. Therefore, it is best to use tracelast immediately after an exception occurs.
The trace information displayed begins with a trace of the surrounding procedure activations (beginning with the top level if 100 or less procedures were active).
Each procedure activation is displayed as two lines:
The first line shows the arguments with which the procedure was invoked.
If the tracelast command was terminated by a colon instead of a semicolon, this line is not printed. This is useful if the arguments are large Arrays, Matrices, Vectors, Records, or modules.
The second line begins with #, the procedure name and statement number (see showstat), and the statement being executed in that procedure.
If the source code of the procedure is available, kernelopts(keepdebuginfo) is true, and kernelopts(tracelineinfo) is greater than 0, the source file name and line number are also displayed.
The procedure name and statement number are displayed in a form that is suitable as arguments for the showstat, showsource, and stopat debugging facilities.
After the last line of the stack trace, the original error message is redisplayed, followed by the values of all the local variables of the procedure in which the exception occurred.
If the global variable debugger/max_width is set to a positive integer value, each value of an argument or local variable displayed by tracelast is truncated to that width, followed by "...", and then the appropriate sequence of closing delimiters for any incompletely printed expressions.
If an exception is caught by a try-catch statement, and then either is rethrown or a different exception is thrown from within the catch clause, the reported error location will be the procedure containing that catch clause. However, the stack trace will continue all the way down to the location in which the original exception occurred.
f := proc() g(args) end proc:
g := proc() if h(args) then args end if; end proc:
h := proc() try dsolve(args); catch: error; end try; end proc:
f⁡diff⁡y⁡x,x+y⁡x+x=0,y
Error, (in h) found wrong extra argument(s): y
f called with arguments: diff(y(x), x)+y(x)+x = 0, y #(f,1): g(_passed)
g called with arguments: diff(y(x), x)+y(x)+x = 0, y #(g,1): if h(_passed) then ... end if
h called with arguments: diff(y(x), x)+y(x)+x = 0, y #(h,3): error
dsolve called with arguments: diff(y(x), x)+y(x)+x = 0, arbitraryconstants = subscripted, atomizenames = true, build = false, numeric = false, type = none, y #(dsolve,77): error
\`ODEtools/odsolve\` called with arguments: diff(y(x), x)+y(x)+x = 0, atomizenames = false, y #(\`ODEtools/odsolve\`,81): \`ODEtools/info\`(ARGS,ode,'FAIL',y,x,diff_ord,hint,WAY,extra,int_scheme, methods,singsol);
\`ODEtools/info\` called with arguments: [diff(y(x), x)+y(x)+x = 0, y], ode, FAIL, y, x, diff_ord, hint, WAY, extra, int_scheme, methods, singsol #(\`ODEtools/info\`,177): error "found wrong extra argument(s): %0", op(l_args)
locals defined as: Y = y(x), derivs = {diff(y(x), x)}, ode = diff(y(x), x)+y(x)+x, f = f, y = y, x = x, diff_ord = 1, hint = (), WAY = [], l_args = {y}, methods = [], zz = [false, false, false], tmp = tmp, algorithms = [2, 3, 4, 5, 6, 7, abaco1, abaco2, all, exp_sym, formal, mu, pdsolve, patterns], Yn = Yn, i = i, singsol = []
showstat⁡h,1
h := proc() 1 try catch : ... end try end proc
stopat⁡g,1
g
showstat⁡g
g := proc() 1* if h(_passed) then 2 _passed end if end proc
Display of the stack trace past an exception (re)thrown in a catch clause is new in Maple 2020.
Display of source file and line number information in the stack trace is new in Maple 2020.
The tracelast command was updated in Maple 2020.
See Also
debugger
showstat
stopat
Tracing a Procedure
where
Download Help Document