diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h index 9c5c9ad468..65ffad677c 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -104,6 +104,10 @@ #include #endif +#ifdef __linux__ +#include +#endif + #include #include #include @@ -220,6 +224,27 @@ extern "C" { #define ftdm_is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119) +#ifdef __linux__ +#define ftdm_print_stack(level) \ + do { \ + void *__stacktrace[100] = { 0 }; \ + char **__symbols = NULL; \ + int __size = 0; \ + int __i = 0; \ + __size = backtrace(__stacktrace, ftdm_array_len(__stacktrace)); \ + __symbols = backtrace_symbols(__stacktrace, __size); \ + if (__symbols) { \ + for (__i = 0; __i < __size; __i++) { \ + ftdm_log(__level, "%s\n", __symbols[i]); \ + } \ + free(__symbols); \ + } \ + } while (0); +#else +#define ftdm_print_stack(level) ftdm_log(level, "FTDM_PRINT_STACK is not implemented in this operating system!\n"); +#endif + + #define FTDM_SPAN_IS_BRI(x) ((x)->trunk_type == FTDM_TRUNK_BRI || (x)->trunk_type == FTDM_TRUNK_BRI_PTMP) /*! \brief Copy flags from one arbitrary object to another