22#include <drizzled/util/backtrace.h>
37void custom_backtrace(
const char *file,
int line,
const char *func,
size_t depth)
39 (void)file; (void)line; (void)func; (void)depth;
42 size_t size= backtrace(array, 50);
43 char **strings= backtrace_symbols(array, size);
50 std::cerr << std::endl <<
"call_backtrace(" << size <<
") began at " << file <<
":" << line <<
" for " << func <<
"()" << std::endl;
58 depth= std::min(depth, size);
61 char *named_function= (
char *)::realloc(NULL, 1024);
63 if (named_function == NULL)
69 for (
size_t x= 1; x < depth; x++)
74 char *named_function_ptr= (
char *)::realloc(named_function, sz);
75 if (named_function_ptr == NULL)
79 named_function= named_function_ptr;
82 char *begin_offset= 0;
85 for (
char *j= strings[x]; *j; ++j)
95 else if (*j ==
')' and begin_offset)
102 if (begin_name and begin_offset and end_offset and begin_name < begin_offset)
105 *begin_offset++=
'\0';
109 char *ret= abi::__cxa_demangle(begin_name, named_function, &sz, &status);
113 std::cerr <<
" " << strings[x] <<
" : " << begin_name <<
"() + " << begin_offset << std::endl;
117 std::cerr <<
" " << strings[x] <<
" : " << begin_name <<
"() + " << begin_offset << std::endl;
122 std::cerr <<
" " << strings[x] << std::endl;
127 std::cerr <<
" unmangled:" << strings[x] << std::endl;
131 ::free(named_function);
TODO: Rename this file - func.h is stupid.