|This article does not cite any references or sources. (December 2009)|
A stack trace allows to track the sequence of nested functions called up to the point where the stack trace is generated. In a post-mortem scenario this is up to function where the failure occurred (but not necessarily is caused there). Sibling function calls are not visible in a stack trace.
As an example, the following Python program contains an error.
def a(): b() def b(): c() def c(): error() a()
Running the program under the standard Python interpreter produces the following error message.
Traceback (most recent call last): File "tb.py", line 10, in <module> a() File "tb.py", line 2, in a b() File "tb.py", line 5, in b c() File "tb.py", line 8, in c error() NameError: global name 'error' is not defined
The stack trace shows where the error occurs, namely in the
c function. It also shows that the
c function was called by
b, which was called by
a, which was in turn called by the code on line 10 (the last line) of the program.
Most programming languages, including Java and C#, have built-in support for retrieving the current stack-trace via system calls. C++ has no built-in support for doing this, but C++ users can retrieve stack traces with (for example) the stacktrace library.
|This computer science article is a stub. You can help Wikipedia by expanding it.|