Changeset 2178
- Timestamp:
- 28/05/2008 15:35:20 (4 years ago)
- File:
-
- 1 edited
-
box/trunk/lib/common/Utils.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Utils.cpp
r2127 r2178 19 19 #endif 20 20 21 #ifdef HAVE_CXXABI_H 22 #include <cxxabi.h> 23 #endif 24 21 25 #include "Utils.h" 22 26 #include "CommonException.h" … … 77 81 for(i = 0; i < size; i++) 78 82 { 79 BOX_TRACE(strings[i]); 83 // Demangling code copied from 84 // cctbx_sources/boost_adaptbx/meta_ext.cpp, BSD license 85 86 std::string mangled_frame = strings[i]; 87 std::string output_frame = strings[i]; // default 88 89 #ifdef HAVE_CXXABI_H 90 int start = mangled_frame.find('('); 91 int end = mangled_frame.find('+', start); 92 std::string mangled_func = mangled_frame.substr(start + 1, 93 end - start - 1); 94 95 size_t len = 256; 96 std::auto_ptr<char> output_buf(new char [len]); 97 int status; 98 99 if (abi::__cxa_demangle(mangled_func.c_str(), output_buf.get(), 100 &len, &status) == NULL) 101 { 102 if (status == 0) 103 { 104 BOX_WARNING("Demangle failed but no error: " << 105 mangled_func); 106 } 107 else if (status == -1) 108 { 109 BOX_WARNING("Demangle failed with " 110 "memory allocation error: " << 111 mangled_func); 112 } 113 else if (status == -2) 114 { 115 /* 116 BOX_WARNING("Demangle failed with " 117 "with invalid name: " << 118 mangled_func); 119 */ 120 } 121 else if (status == -3) 122 { 123 BOX_WARNING("Demangle failed with " 124 "with invalid argument: " << 125 mangled_func); 126 } 127 else 128 { 129 BOX_WARNING("Demangle failed with " 130 "with unknown error " << status << 131 ": " << mangled_func); 132 } 133 } 134 else 135 { 136 output_frame = mangled_frame.substr(0, start + 1) + 137 // std::string(output_buf.get()) + 138 output_buf.get() + 139 mangled_frame.substr(end); 140 } 141 #endif // HAVE_CXXABI_H 142 143 BOX_TRACE("Stack frame " << i << ": " << output_frame); 80 144 } 81 145
Note: See TracChangeset
for help on using the changeset viewer.
