MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
my_stacktrace.h
1 /* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef _my_stacktrace_h_
17 #define _my_stacktrace_h_
18 
19 #include <my_global.h>
20 
21 #ifdef TARGET_OS_LINUX
22 #if defined (__x86_64__) || defined (__i386__) || \
23  (defined(__alpha__) && defined(__GNUC__))
24 #define HAVE_STACKTRACE 1
25 #endif
26 #elif defined(__WIN__) || defined(HAVE_PRINTSTACK)
27 #define HAVE_STACKTRACE 1
28 #endif
29 
30 #if HAVE_BACKTRACE && (HAVE_BACKTRACE_SYMBOLS || HAVE_BACKTRACE_SYMBOLS_FD)
31 #undef HAVE_STACKTRACE
32 #define HAVE_STACKTRACE 1
33 #endif
34 
35 #define HAVE_WRITE_CORE
36 
37 #if HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS && \
38  HAVE_CXXABI_H && HAVE_ABI_CXA_DEMANGLE && \
39  HAVE_WEAK_SYMBOL
40 #define BACKTRACE_DEMANGLE 1
41 #endif
42 
43 C_MODE_START
44 
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);
52 #endif
53 #ifdef __WIN__
54 void my_set_exception_pointers(EXCEPTION_POINTERS *ep);
55 #endif
56 #endif
57 
58 #ifdef HAVE_WRITE_CORE
59 void my_write_core(int sig);
60 #endif
61 
62 
63 
80 char *my_safe_itoa(int base, longlong val, char *buf);
81 
90 char *my_safe_utoa(int base, ulonglong val, char *buf);
91 
103 size_t my_safe_snprintf(char* to, size_t n, const char* fmt, ...)
104  ATTRIBUTE_FORMAT(printf, 3, 4);
105 
113 size_t my_safe_printf_stderr(const char* fmt, ...)
114  ATTRIBUTE_FORMAT(printf, 1, 2);
115 
123 size_t my_write_stderr(const void *buf, size_t count);
124 
125 C_MODE_END
126 
127 #endif /* _my_stacktrace_h_ */