stacktrace
stacktrace( [g_unevaluated] [x_depth] [x_skip] [p_port] ) =>x_result
Description
Prints the functions on the stack and their arguments to the depth specified, or to the bottom of the stack if no depth is specified.
The function observes the following rules:
-
When debug mode is on
stacktrace, it prints the evaluated function arguments by default if the status switchtraceArgshas been set tot. -
When debug mode is off,
stacktracealways prints the unevaluated arguments. -
If the status switch
stacktraceis set (using the sstatus function) to an integer, it prints that number of stack frames automatically whenever an error occurs. -
If there are no functions on the stack, that is, you are at the top, then
stacktracedoes not print anything and returns 0.
stacktrace has a more flexible interface for user convenience. Thus if the first argument is a number it will interpret it to be x_depth, otherwise if it is non-nil it will take it to be g_unevaluated.This function is usually used inside the break or error handler.
Arguments
|
|
|
Value Returned
Examples
Prints all the functions on the stack.
stacktrace()
Prints the top five functions on the stack.
stacktrace( 5 )
Prints the five functions on the stack that come after the first three to the trace port.
stacktrace( t 5 3 ptport )
Prints the first six stack frames every time an error occurs.
sstatus( stacktrace 6 )
Related Topics
Return to top