Logo

Programming-Idioms

  • C++
  • Haskell
  • Perl
  • Js

Idiom #253 Print stack trace

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

console.trace()
import GHC.Stack
msgStacktraced :: HasCallStack => String -> IO ()
msgStacktraced msg = putStrLn (msg ++ "\n" ++ prettyCallStack callStack)
import Carp 'cluck';
cluck 'print this message and a full stack track';

See documentation of Carp for many other variations.
import "runtime/debug"
debug.PrintStack()

Prints to standard error

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