Changeset b726084 for src/main.cc


Ignore:
Timestamp:
Nov 9, 2016, 2:51:42 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
30b65d8, d073e3c
Parents:
141b786 (diff), 84118d8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into tuples

Conflicts:

src/ControlStruct/LabelTypeChecker.cc
src/InitTweak/FixInit.cc
src/ResolvExpr/Resolver.cc
src/Tuples/TupleAssignment.cc
src/Tuples/TupleAssignment.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r141b786 rb726084  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 29 17:34:39 2016
    13 // Update Count     : 426
     12// Last Modified On : Sun Oct 30 10:11:38 2016
     13// Update Count     : 435
    1414//
    1515
     
    1818#include <signal.h>                                                                             // signal
    1919#include <getopt.h>                                                                             // getopt
    20 #include <execinfo.h>                                                                   // backtrace, backtrace_symbols_fd
     20#include <execinfo.h>                                                                   // backtrace, backtrace_symbols
    2121#include <cxxabi.h>                                                                             // __cxa_demangle
     22#include <cstring>                                                                              // index
    2223
    2324using namespace std;
     
    7677static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
    7778
    78 void backtrace( int start ) {                                                   // skip first N stack frames
     79static void backtrace( int start ) {                                    // skip first N stack frames
    7980        enum { Frames = 50 };
    8081        void * array[Frames];
    81         int size = backtrace( array, Frames );
    82         char ** messages = backtrace_symbols( array, size );
     82        int size = ::backtrace( array, Frames );
     83        char ** messages = ::backtrace_symbols( array, size ); // does not demangle names
     84
     85        *index( messages[0], '(' ) = '\0';                                      // find executable name
     86        cerr << "Stack back trace for: " << messages[0] << endl;
    8387
    8488        // skip last 2 stack frames after main
     
    8690                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
    8791                for ( char *p = messages[i]; *p; ++p ) {        // find parantheses and +offset
    88                         if (*p == '(') {
     92                        if ( *p == '(' ) {
    8993                                mangled_name = p;
    90                         } else if (*p == '+') {
     94                        } else if ( *p == '+' ) {
    9195                                offset_begin = p;
    92                         } else if (*p == ')') {
     96                        } else if ( *p == ')' ) {
    9397                                offset_end = p;
    9498                                break;
     
    99103                int frameNo = i - start;
    100104                if ( mangled_name && offset_begin && offset_end && mangled_name < offset_begin ) {
    101                         *mangled_name++ = '\0';
     105                        *mangled_name++ = '\0';                                         // delimit strings
    102106                        *offset_begin++ = '\0';
    103107                        *offset_end++ = '\0';
    104108
    105                         int status, frameNo = i - start;
     109                        int status;
    106110                        char * real_name = __cxxabiv1::__cxa_demangle( mangled_name, 0, 0, &status );
     111                        // bug in __cxa_demangle for single-character lower-case non-mangled names
    107112                        if ( status == 0 ) {                                            // demangling successful ?
    108113                                cerr << "(" << frameNo << ") " << messages[i] << " : "
    109114                                         << real_name << "+" << offset_begin << offset_end << endl;
    110 
    111115                        } else {                                                                        // otherwise, output mangled name
    112116                                cerr << "(" << frameNo << ") " << messages[i] << " : "
    113                                          << mangled_name << "+" << offset_begin << offset_end << endl;
     117                                         << mangled_name << "(/*unknown*/)+" << offset_begin << offset_end << endl;
    114118                        } // if
     119
    115120                        free( real_name );
    116121                } else {                                                                                // otherwise, print the whole line
     
    125130        cerr << "*CFA runtime error* program cfa-cpp terminated with "
    126131                 <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
    127                  << " backtrace:" << endl;
     132                 << "." << endl;
    128133        backtrace( 2 );                                                                         // skip first 2 stack frames
    129134        exit( EXIT_FAILURE );
Note: See TracChangeset for help on using the changeset viewer.