/* * Copyright (C) 2022 Kovid Goyal * * Distributed under terms of the GPL3 license. */ #pragma once #include #include #include #include #if __has_include() #include static inline void print_stack_trace(void) { void *array[256]; size_t size; // get void*'s for all entries on the stack size = backtrace(array, 256); // print out all the frames to stderr backtrace_symbols_fd(array, size, STDERR_FILENO); } #else static inline void print_stack_trace(void) { fprintf(stderr, "Stack trace functionality not available.\n"); } #endif