Changes in / [80722d0:4a7d895]
- Location:
- src
- Files:
-
- 4 edited
-
Common/Assert.cc (modified) (3 diffs)
-
Makefile.am (modified) (2 diffs)
-
Makefile.in (modified) (1 diff)
-
main.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/Assert.cc
r80722d0 r4a7d895 10 10 // Created On : Thu Aug 18 13:26:59 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 19 17:07:08201613 // Update Count : 1012 // Last Modified On : Thu Aug 18 23:40:29 2016 13 // Update Count : 8 14 14 // 15 15 16 16 #include <assert.h> 17 #include <cstdarg> // varargs18 #include <cstdio> // fprintf19 #include <cstdlib> // abort17 #include <cstdarg> 18 #include <cstdio> 19 #include <cstdlib> 20 20 21 21 extern const char * __progname; // global name of running executable (argv[0]) … … 26 26 void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { 27 27 fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file ); 28 abort();28 exit( EXIT_FAILURE ); 29 29 } 30 30 … … 35 35 va_start( args, fmt ); 36 36 vfprintf( stderr, fmt, args ); 37 abort();37 exit( EXIT_FAILURE ); 38 38 } 39 39 -
src/Makefile.am
r80722d0 r4a7d895 11 11 ## Created On : Sun May 31 08:51:46 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Aug 20 11:13:12201614 ## Update Count : 7 113 ## Last Modified On : Thu Aug 18 17:47:06 2016 14 ## Update Count : 70 15 15 ############################################################################### 16 16 … … 43 43 driver_cfa_cpp_SOURCES = ${SRC} 44 44 driver_cfa_cpp_LDADD = ${LEXLIB} # yywrap 45 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL - rdynamic -I${abs_top_srcdir}/src/include45 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include 46 46 47 47 MAINTAINERCLEANFILES += ${libdir}/${notdir ${cfa_cpplib_PROGRAMS}} -
src/Makefile.in
r80722d0 r4a7d895 427 427 driver_cfa_cpp_SOURCES = ${SRC} 428 428 driver_cfa_cpp_LDADD = ${LEXLIB} # yywrap 429 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL - rdynamic -I${abs_top_srcdir}/src/include429 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include 430 430 all: $(BUILT_SOURCES) 431 431 $(MAKE) $(AM_MAKEFLAGS) all-am -
src/main.cc
r80722d0 r4a7d895 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 20 12:52:22 201613 // Update Count : 40312 // Last Modified On : Fri Aug 19 08:31:22 2016 13 // Update Count : 350 14 14 // 15 15 16 16 #include <iostream> 17 17 #include <fstream> 18 #include <signal.h> // signal 19 #include <getopt.h> // getopt 20 #include <execinfo.h> // backtrace, backtrace_symbols_fd 21 #include <cxxabi.h> // __cxa_demangle 22 23 using namespace std; 24 18 #include <getopt.h> 25 19 #include "Parser/lex.h" 26 20 #include "Parser/parser.h" … … 41 35 #include "InitTweak/FixInit.h" 42 36 #include "Common/UnimplementedError.h" 37 43 38 #include "../config.h" 44 39 45 40 using namespace std; 46 41 47 #define OPTPRINT(x) if ( errorp ) cerr << x <<endl;42 #define OPTPRINT(x) if ( errorp ) std::cerr << x << std::endl; 48 43 49 44 … … 73 68 static void parse_cmdline( int argc, char *argv[], const char *& filename ); 74 69 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false ); 75 static void dump( list< Declaration * > & translationUnit, ostream & out = cout ); 76 77 void sigSegvBusHandler( int sig_num ) { 78 enum { Frames = 50 }; 79 void * array[Frames]; 80 int size = backtrace( array, Frames ); 81 82 cerr << "*CFA runtime error* program cfa-cpp terminated with " 83 << (sig_num == SIGSEGV ? "segment fault" : "bus error") 84 << " backtrace:" << endl; 85 86 char ** messages = backtrace_symbols( array, size ); 87 88 // skip first stack frame (points here) 89 for ( int i = 2; i < size - 2 && messages != nullptr; i += 1 ) { 90 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 91 for ( char *p = messages[i]; *p; ++p ) { // find parantheses and +offset 92 if (*p == '(') { 93 mangled_name = p; 94 } else if (*p == '+') { 95 offset_begin = p; 96 } else if (*p == ')') { 97 offset_end = p; 98 break; 99 } // if 100 } // for 101 102 // if line contains symbol, attempt to demangle 103 if ( mangled_name && offset_begin && offset_end && mangled_name < offset_begin ) { 104 *mangled_name++ = '\0'; 105 *offset_begin++ = '\0'; 106 *offset_end++ = '\0'; 107 108 int status; 109 char * real_name = __cxxabiv1::__cxa_demangle( mangled_name, 0, 0, &status ); 110 if ( status == 0 ) { // demangling successful ? 111 cerr << "(" << i - 2 << ") " << messages[i] << " : " 112 << real_name << "+" << offset_begin << offset_end << endl; 113 114 } else { // otherwise, output mangled name 115 cerr << "(" << i - 2 << ") " << messages[i] << " : " 116 << mangled_name << "+" << offset_begin << offset_end << endl; 117 } // if 118 free( real_name ); 119 } else { // otherwise, print the whole line 120 cerr << "(" << i - 2 << ") " << messages[i] << endl; 121 } // if 122 } // for 123 free( messages ); 124 exit( EXIT_FAILURE ); 125 } // sigSegvBusHandler 70 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout ); 126 71 127 72 int main( int argc, char * argv[] ) { 128 73 FILE * input; // use FILE rather than istream because yyin is FILE 129 ostream *output = & cout; 74 std::ostream *output = & std::cout; 75 std::list< Declaration * > translationUnit; 130 76 const char *filename = nullptr; 131 list< Declaration * > translationUnit;132 133 signal( SIGSEGV, sigSegvBusHandler );134 signal( SIGBUS, sigSegvBusHandler );135 77 136 78 parse_cmdline( argc, argv, filename ); // process command-line arguments … … 180 122 181 123 if ( parsep ) { 182 parseTree->printList( cout );124 parseTree->printList( std::cout ); 183 125 delete parseTree; 184 126 return 0; … … 202 144 203 145 if ( expraltp ) { 204 ResolvExpr::AlternativePrinter printer( cout );146 ResolvExpr::AlternativePrinter printer( std::cout ); 205 147 acceptAll( translationUnit, printer ); 206 148 return 0; … … 268 210 CodeGen::generate( translationUnit, *output, ! noprotop ); 269 211 270 if ( output != & cout ) {212 if ( output != &std::cout ) { 271 213 delete output; 272 214 } // if 273 215 } catch ( SemanticError &e ) { 274 216 if ( errorp ) { 275 cerr << "---AST at error:---" <<endl;276 dump( translationUnit, cerr );277 cerr << endl << "---End of AST, begin error message:---\n" <<endl;278 } // if 279 e.print( cerr );280 if ( output != & cout ) {217 std::cerr << "---AST at error:---" << std::endl; 218 dump( translationUnit, std::cerr ); 219 std::cerr << std::endl << "---End of AST, begin error message:---\n" << std::endl; 220 } // if 221 e.print( std::cerr ); 222 if ( output != &std::cout ) { 281 223 delete output; 282 224 } // if 283 225 return 1; 284 226 } catch ( UnimplementedError &e ) { 285 cout << "Sorry, " << e.get_what() << " is not currently implemented" <<endl;286 if ( output != & cout ) {227 std::cout << "Sorry, " << e.get_what() << " is not currently implemented" << std::endl; 228 if ( output != &std::cout ) { 287 229 delete output; 288 230 } // if 289 231 return 1; 290 232 } catch ( CompilerError &e ) { 291 cerr << "Compiler Error: " << e.get_what() <<endl;292 cerr << "(please report bugs to " <<endl;293 if ( output != & cout ) {233 std::cerr << "Compiler Error: " << e.get_what() << std::endl; 234 std::cerr << "(please report bugs to " << std::endl; 235 if ( output != &std::cout ) { 294 236 delete output; 295 237 } // if … … 427 369 } // notPrelude 428 370 429 static void dump( list< Declaration * > & translationUnit,ostream & out ) {430 list< Declaration * > decls;371 static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) { 372 std::list< Declaration * > decls; 431 373 432 374 if ( noprotop ) { 433 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), notPrelude );375 filter( translationUnit.begin(), translationUnit.end(), std::back_inserter( decls ), notPrelude ); 434 376 } else { 435 377 decls = translationUnit;
Note:
See TracChangeset
for help on using the changeset viewer.