16 #ifndef _my_stacktrace_h_
17 #define _my_stacktrace_h_
19 #include <my_global.h>
21 #ifdef TARGET_OS_LINUX
22 #if defined (__x86_64__) || defined (__i386__) || \
23 (defined(__alpha__) && defined(__GNUC__))
24 #define HAVE_STACKTRACE 1
26 #elif defined(__WIN__) || defined(HAVE_PRINTSTACK)
27 #define HAVE_STACKTRACE 1
30 #if HAVE_BACKTRACE && (HAVE_BACKTRACE_SYMBOLS || HAVE_BACKTRACE_SYMBOLS_FD)
31 #undef HAVE_STACKTRACE
32 #define HAVE_STACKTRACE 1
35 #define HAVE_WRITE_CORE
37 #if HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS && \
38 HAVE_CXXABI_H && HAVE_ABI_CXA_DEMANGLE && \
40 #define BACKTRACE_DEMANGLE 1
45 #if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)
46 void my_init_stacktrace();
47 void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack);
48 void my_safe_print_str(
const char* val,
int max_len);
49 void my_write_core(
int sig);
50 #if BACKTRACE_DEMANGLE
51 char *my_demangle(
const char *mangled_name,
int *status);
54 void my_set_exception_pointers(EXCEPTION_POINTERS *ep);
58 #ifdef HAVE_WRITE_CORE
59 void my_write_core(
int sig);
80 char *my_safe_itoa(
int base, longlong val,
char *
buf);
90 char *my_safe_utoa(
int base, ulonglong val,
char *
buf);
103 size_t my_safe_snprintf(
char*
to,
size_t n,
const char*
fmt, ...)
104 ATTRIBUTE_FORMAT(printf, 3, 4);
113 size_t my_safe_printf_stderr(const
char* fmt, ...)
114 ATTRIBUTE_FORMAT(printf, 1, 2);
123 size_t my_write_stderr(const
void *
buf,
size_t count);