Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r0afffee r141b786  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 30 10:11:38 2016
    13 // Update Count     : 435
     12// Last Modified On : Mon Aug 29 17:34:39 2016
     13// Update Count     : 426
    1414//
    1515
     
    1818#include <signal.h>                                                                             // signal
    1919#include <getopt.h>                                                                             // getopt
    20 #include <execinfo.h>                                                                   // backtrace, backtrace_symbols
     20#include <execinfo.h>                                                                   // backtrace, backtrace_symbols_fd
    2121#include <cxxabi.h>                                                                             // __cxa_demangle
    22 #include <cstring>                                                                              // index
    2322
    2423using namespace std;
     
    4342#include "Common/UnimplementedError.h"
    4443#include "../config.h"
     44#include "Tuples/Tuples.h"
    4545
    4646using namespace std;
     
    7676static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
    7777
    78 static void backtrace( int start ) {                                    // skip first N stack frames
     78void backtrace( int start ) {                                                   // skip first N stack frames
    7979        enum { Frames = 50 };
    8080        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 );
    8683
    8784        // skip last 2 stack frames after main
     
    8986                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
    9087                for ( char *p = messages[i]; *p; ++p ) {        // find parantheses and +offset
    91                         if ( *p == '(' ) {
     88                        if (*p == '(') {
    9289                                mangled_name = p;
    93                         } else if ( *p == '+' ) {
     90                        } else if (*p == '+') {
    9491                                offset_begin = p;
    95                         } else if ( *p == ')' ) {
     92                        } else if (*p == ')') {
    9693                                offset_end = p;
    9794                                break;
     
    10299                int frameNo = i - start;
    103100                if ( mangled_name && offset_begin && offset_end && mangled_name < offset_begin ) {
    104                         *mangled_name++ = '\0';                                         // delimit strings
     101                        *mangled_name++ = '\0';
    105102                        *offset_begin++ = '\0';
    106103                        *offset_end++ = '\0';
    107104
    108                         int status;
     105                        int status, frameNo = i - start;
    109106                        char * real_name = __cxxabiv1::__cxa_demangle( mangled_name, 0, 0, &status );
    110                         // bug in __cxa_demangle for single-character lower-case non-mangled names
    111107                        if ( status == 0 ) {                                            // demangling successful ?
    112108                                cerr << "(" << frameNo << ") " << messages[i] << " : "
    113109                                         << real_name << "+" << offset_begin << offset_end << endl;
     110
    114111                        } else {                                                                        // otherwise, output mangled name
    115112                                cerr << "(" << frameNo << ") " << messages[i] << " : "
    116                                          << mangled_name << "(/*unknown*/)+" << offset_begin << offset_end << endl;
     113                                         << mangled_name << "+" << offset_begin << offset_end << endl;
    117114                        } // if
    118 
    119115                        free( real_name );
    120116                } else {                                                                                // otherwise, print the whole line
     
    129125        cerr << "*CFA runtime error* program cfa-cpp terminated with "
    130126                 <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
    131                  << "." << endl;
     127                 << " backtrace:" << endl;
    132128        backtrace( 2 );                                                                         // skip first 2 stack frames
    133129        exit( EXIT_FAILURE );
     
    236232                OPTPRINT( "tweakInit" )
    237233                InitTweak::genInit( translationUnit );
    238 
     234                OPTPRINT( "expandMemberTuples" );
     235                Tuples::expandMemberTuples( translationUnit );
    239236                if ( libcfap ) {
    240237                        // generate the bodies of cfa library functions
     
    261258                        return 0;
    262259                } // 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 );
    263263
    264264                OPTPRINT("instantiateGenerics")
     
    277277                OPTPRINT( "box" )
    278278                GenPoly::box( translationUnit );
     279                OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
     280                Tuples::expandTuples( translationUnit );
    279281
    280282                // print tree right before code generation
Note: See TracChangeset for help on using the changeset viewer.