31 #include <graphlab/parallel/pthread_tools.hpp>
32 #include <graphlab/rpc/get_last_dc_procid.hpp>
36 std::string demangle(
const char* symbol) {
42 if (1 == sscanf(symbol,
"%*[^(]%*[^_]%127[^)+]", temp)) {
43 if (NULL != (demangled = abi::__cxa_demangle(temp, NULL, &size, &status))) {
44 std::string result(demangled);
50 if (1 == sscanf(symbol,
"%127s", temp)) {
60 static size_t write_count = 0;
61 static bool write_error = 0;
63 void __print_back_trace() {
69 back_trace_file_lock.
lock();
72 back_trace_file_lock.
unlock();
76 sprintf(filename,
"backtrace.%d",
int(graphlab::dc_impl::get_last_dc_procid()));
79 if (write_count == 0) {
80 ofile = fopen(filename,
"w");
83 ofile = fopen(filename,
"a");
88 fprintf(stderr,
"Unable to open output backtrace file.\n");
90 back_trace_file_lock.
unlock();
95 size = backtrace(array, 1024);
96 strings = backtrace_symbols(array, size);
98 fprintf(ofile,
"Pointers\n");
99 fprintf(ofile,
"------------\n");
100 for (i = 0; i < size; ++i) {
101 fprintf(ofile,
"%p\n", array[i]);
105 fprintf(ofile,
"Raw\n");
106 fprintf(ofile,
"------------\n");
107 for (i = 0; i < size; ++i) {
108 fprintf(ofile,
"%s\n", strings[i]);
110 fprintf(ofile,
"\nDemangled\n");
111 fprintf(ofile,
"------------\n");
113 for (i = 0; i < size; ++i) {
114 std::string ret = demangle(strings[i]);
115 fprintf(ofile,
"%s\n", ret.c_str());
119 fprintf(ofile,
"\n\n\n\n\n\n\n\n\n\n\n\n\n");
122 back_trace_file_lock.
unlock();