Logo

Programming-Idioms

  • Pascal
  • C++
  • Elixir
  • Python

Idiom #253 Print stack trace

Print the stack frames of the current execution thread of the program.

import inspect
for frame in inspect.stack():
    print(frame)
dump_stack(stdout,0);

Compile with -gl flag to get line info (FreePascal compiler).
import "runtime/debug"
debug.PrintStack()

Prints to standard error

New implementation...
< >
programming-idioms.org