function::print_ubacktrace - Linux


function::print_ubacktrace is a powerful debugger tool that prints a concise representation of the current call stack, including function names, source file paths, and line numbers. It’s particularly useful for:

  • Debugging stack-based programs and analyzing the flow of execution.
  • Identifying the source of errors or crashes and tracing their root causes.
  • Understanding the call hierarchy and relationships between different components.


function::print_ubacktrace [--nocolor]


  • –nocolor (optional): Disables color output for a more compact representation.


Simple Usage:


Colored Output:


# [  0] /home/user/proj/main.cpp:15
# [  1] /usr/lib/
# [  2] /usr/lib/

Contextual Information:

function::print_ubacktrace --nocolor

call stack:

# 0  main                                                  /home/user/proj/main.cpp:15
# 1  std::_124 __cxxabiv1::__uncaught_exceptions           /usr/lib/
# 2  std::terminate                                        /usr/lib/
# 3  __gnu_cxx::new_allocator<std::pair<std::string, std::string> >::_M_destroy                   /usr/lib/
# 4  std::__1::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()  /usr/lib/
# 5  std::_124 __cxxabiv1::__uncaught_exceptions           /usr/lib/
# 6  std::terminate                                        /usr/lib/

Common Issues

  • Missing Symbols: If a function name is not resolved, it may appear as a hexadecimal address. This can occur with optimized builds or when symbols are stripped from the executable.
  • Oversized Stacks: Very large stack traces can overwhelm the terminal window. Use the --nocolor option to reduce the output size or pipe the output to a paging tool like less.


function::print_ubacktrace can be integrated with other debugging tools to provide additional context:

  • GDB: Used as a complement to bt.
  • Valgrind: Can be combined with --track-origins=yes to display a detailed call stack with memory allocation information.

Related Commands

  • backtrace: Prints a backtrace in the traditional GDB format.
  • gdb: A full-featured debugger that provides stack traces and other analysis tools.