Changes in src/main.cc [0afffee:141b786]
- File:
-
- 1 edited
-
src/main.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r0afffee r141b786 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 30 10:11:38201613 // Update Count : 4 3512 // Last Modified On : Mon Aug 29 17:34:39 2016 13 // Update Count : 426 14 14 // 15 15 … … 18 18 #include <signal.h> // signal 19 19 #include <getopt.h> // getopt 20 #include <execinfo.h> // backtrace, backtrace_symbols 20 #include <execinfo.h> // backtrace, backtrace_symbols_fd 21 21 #include <cxxabi.h> // __cxa_demangle 22 #include <cstring> // index23 22 24 23 using namespace std; … … 43 42 #include "Common/UnimplementedError.h" 44 43 #include "../config.h" 44 #include "Tuples/Tuples.h" 45 45 46 46 using namespace std; … … 76 76 static void dump( list< Declaration * > & translationUnit, ostream & out = cout ); 77 77 78 static void backtrace( int start ) {// skip first N stack frames78 void backtrace( int start ) { // skip first N stack frames 79 79 enum { Frames = 50 }; 80 80 void * array[Frames]; 81 int size = ::backtrace( array, Frames ); 82 char ** messages = ::backtrace_symbols( array, size ); // does not demangle names 83 84 *index( messages[0], '(' ) = '\0'; // find executable name 85 cerr << "Stack back trace for: " << messages[0] << endl; 81 int size = backtrace( array, Frames ); 82 char ** messages = backtrace_symbols( array, size ); 86 83 87 84 // skip last 2 stack frames after main … … 89 86 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 90 87 for ( char *p = messages[i]; *p; ++p ) { // find parantheses and +offset 91 if ( *p == '(') {88 if (*p == '(') { 92 89 mangled_name = p; 93 } else if ( *p == '+') {90 } else if (*p == '+') { 94 91 offset_begin = p; 95 } else if ( *p == ')') {92 } else if (*p == ')') { 96 93 offset_end = p; 97 94 break; … … 102 99 int frameNo = i - start; 103 100 if ( mangled_name && offset_begin && offset_end && mangled_name < offset_begin ) { 104 *mangled_name++ = '\0'; // delimit strings101 *mangled_name++ = '\0'; 105 102 *offset_begin++ = '\0'; 106 103 *offset_end++ = '\0'; 107 104 108 int status ;105 int status, frameNo = i - start; 109 106 char * real_name = __cxxabiv1::__cxa_demangle( mangled_name, 0, 0, &status ); 110 // bug in __cxa_demangle for single-character lower-case non-mangled names111 107 if ( status == 0 ) { // demangling successful ? 112 108 cerr << "(" << frameNo << ") " << messages[i] << " : " 113 109 << real_name << "+" << offset_begin << offset_end << endl; 110 114 111 } else { // otherwise, output mangled name 115 112 cerr << "(" << frameNo << ") " << messages[i] << " : " 116 << mangled_name << " (/*unknown*/)+" << offset_begin << offset_end << endl;113 << mangled_name << "+" << offset_begin << offset_end << endl; 117 114 } // if 118 119 115 free( real_name ); 120 116 } else { // otherwise, print the whole line … … 129 125 cerr << "*CFA runtime error* program cfa-cpp terminated with " 130 126 << (sig_num == SIGSEGV ? "segment fault" : "bus error") 131 << " ." << endl;127 << " backtrace:" << endl; 132 128 backtrace( 2 ); // skip first 2 stack frames 133 129 exit( EXIT_FAILURE ); … … 236 232 OPTPRINT( "tweakInit" ) 237 233 InitTweak::genInit( translationUnit ); 238 234 OPTPRINT( "expandMemberTuples" ); 235 Tuples::expandMemberTuples( translationUnit ); 239 236 if ( libcfap ) { 240 237 // generate the bodies of cfa library functions … … 261 258 return 0; 262 259 } // if 260 261 OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 262 Tuples::expandUniqueExpr( translationUnit ); 263 263 264 264 OPTPRINT("instantiateGenerics") … … 277 277 OPTPRINT( "box" ) 278 278 GenPoly::box( translationUnit ); 279 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this? 280 Tuples::expandTuples( translationUnit ); 279 281 280 282 // print tree right before code generation
Note:
See TracChangeset
for help on using the changeset viewer.