Changes in / [80722d0:4a7d895]


Ignore:
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Assert.cc

    r80722d0 r4a7d895  
    1010// Created On       : Thu Aug 18 13:26:59 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 19 17:07:08 2016
    13 // Update Count     : 10
     12// Last Modified On : Thu Aug 18 23:40:29 2016
     13// Update Count     : 8
    1414//
    1515
    1616#include <assert.h>
    17 #include <cstdarg>                                                                              // varargs
    18 #include <cstdio>                                                                               // fprintf
    19 #include <cstdlib>                                                                              // abort
     17#include <cstdarg>
     18#include <cstdio>
     19#include <cstdlib>
    2020
    2121extern const char * __progname;                                                 // global name of running executable (argv[0])
     
    2626void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    2727        fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file );
    28         abort();
     28        exit( EXIT_FAILURE );
    2929}
    3030
     
    3535        va_start( args, fmt );
    3636        vfprintf( stderr, fmt, args );
    37         abort();
     37        exit( EXIT_FAILURE );
    3838}
    3939
  • src/Makefile.am

    r80722d0 r4a7d895  
    1111## Created On       : Sun May 31 08:51:46 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Aug 20 11:13:12 2016
    14 ## Update Count     : 71
     13## Last Modified On : Thu Aug 18 17:47:06 2016
     14## Update Count     : 70
    1515###############################################################################
    1616
     
    4343driver_cfa_cpp_SOURCES = ${SRC}
    4444driver_cfa_cpp_LDADD = ${LEXLIB}                        # yywrap
    45 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -rdynamic -I${abs_top_srcdir}/src/include
     45driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include
    4646
    4747MAINTAINERCLEANFILES += ${libdir}/${notdir ${cfa_cpplib_PROGRAMS}}
  • src/Makefile.in

    r80722d0 r4a7d895  
    427427driver_cfa_cpp_SOURCES = ${SRC}
    428428driver_cfa_cpp_LDADD = ${LEXLIB}                        # yywrap
    429 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -rdynamic -I${abs_top_srcdir}/src/include
     429driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL -I${abs_top_srcdir}/src/include
    430430all: $(BUILT_SOURCES)
    431431        $(MAKE) $(AM_MAKEFLAGS) all-am
  • src/main.cc

    r80722d0 r4a7d895  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 20 12:52:22 2016
    13 // Update Count     : 403
     12// Last Modified On : Fri Aug 19 08:31:22 2016
     13// Update Count     : 350
    1414//
    1515
    1616#include <iostream>
    1717#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>
    2519#include "Parser/lex.h"
    2620#include "Parser/parser.h"
     
    4135#include "InitTweak/FixInit.h"
    4236#include "Common/UnimplementedError.h"
     37
    4338#include "../config.h"
    4439
    4540using namespace std;
    4641
    47 #define OPTPRINT(x) if ( errorp ) cerr << x << endl;
     42#define OPTPRINT(x) if ( errorp ) std::cerr << x << std::endl;
    4843
    4944
     
    7368static void parse_cmdline( int argc, char *argv[], const char *& filename );
    7469static 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
     70static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout );
    12671
    12772int main( int argc, char * argv[] ) {
    12873        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;
    13076        const char *filename = nullptr;
    131         list< Declaration * > translationUnit;
    132 
    133         signal( SIGSEGV, sigSegvBusHandler );
    134         signal( SIGBUS, sigSegvBusHandler );
    13577
    13678        parse_cmdline( argc, argv, filename );                          // process command-line arguments
     
    180122
    181123                if ( parsep ) {
    182                         parseTree->printList( cout );
     124                        parseTree->printList( std::cout );
    183125                        delete parseTree;
    184126                        return 0;
     
    202144
    203145                if ( expraltp ) {
    204                         ResolvExpr::AlternativePrinter printer( cout );
     146                        ResolvExpr::AlternativePrinter printer( std::cout );
    205147                        acceptAll( translationUnit, printer );
    206148                        return 0;
     
    268210                CodeGen::generate( translationUnit, *output, ! noprotop );
    269211
    270                 if ( output != &cout ) {
     212                if ( output != &std::cout ) {
    271213                        delete output;
    272214                } // if
    273215        } catch ( SemanticError &e ) {
    274216                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 ) {
    281223                        delete output;
    282224                } // if
    283225                return 1;
    284226        } 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 ) {
    287229                        delete output;
    288230                } // if
    289231                return 1;
    290232        } 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 ) {
    294236                        delete output;
    295237                } // if
     
    427369} // notPrelude
    428370
    429 static void dump( list< Declaration * > & translationUnit, ostream & out ) {
    430         list< Declaration * > decls;
     371static void dump( std::list< Declaration * > & translationUnit, std::ostream & out ) {
     372        std::list< Declaration * > decls;
    431373
    432374        if ( noprotop ) {
    433                 filter( translationUnit.begin(), translationUnit.end(), back_inserter( decls ), notPrelude );
     375                filter( translationUnit.begin(), translationUnit.end(), std::back_inserter( decls ), notPrelude );
    434376        } else {
    435377                decls = translationUnit;
Note: See TracChangeset for help on using the changeset viewer.