Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    re0bd0f9 rb4f8808  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 22 13:06:18 2019
    13 // Update Count     : 605
     12// Last Modified On : Fri Aug 23 06:50:08 2019
     13// Update Count     : 607
    1414//
    1515
     
    1717#include <execinfo.h>                       // for backtrace, backtrace_symbols
    1818#include <getopt.h>                         // for no_argument, optind, geto...
    19 #include <signal.h>                         // for signal, SIGABRT, SIGSEGV
    2019#include <cassert>                          // for assertf
    2120#include <cstdio>                           // for fopen, FILE, fclose, stdin
    2221#include <cstdlib>                          // for exit, free, abort, EXIT_F...
     22#include <csignal>                         // for signal, SIGABRT, SIGSEGV
    2323#include <cstring>                          // for index
    2424#include <fstream>                          // for ofstream
     
    5959#include "ResolvExpr/Resolver.h"            // for resolve
    6060#include "SymTab/Validate.h"                // for validate
    61 #include "SynTree/TopLvalue.h"              // for assertTopLvalue, clearInn...
    6261#include "SynTree/Declaration.h"            // for Declaration
    6362#include "SynTree/Visitor.h"                // for acceptAll
     
    9695DeclarationNode * parseTree = nullptr;                                  // program parse tree
    9796
     97static bool waiting_for_gdb = false;                                    // flag to set cfa-cpp to wait for gdb on start
     98
    9899static std::string PreludeDirector = "";
    99100
     
    167168} // sigAbortHandler
    168169
    169 
    170170int main( int argc, char * argv[] ) {
    171171        FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
     
    184184        parse_cmdline( argc, argv );                                            // process command-line arguments
    185185        CodeGen::FixMain::setReplaceMain( !nomainp );
     186
     187        if ( waiting_for_gdb ) {
     188                std::cerr << "Waiting for gdb" << std::endl;
     189                std::cerr << "run :" << std::endl;
     190                std::cerr << "  gdb attach " << getpid() << std::endl;
     191                raise(SIGSTOP);
     192        } // if
    186193
    187194        try {
     
    251258                Stats::Time::StopBlock();
    252259
    253                 //std::cerr << "Post-Parse Check" << std::endl;
    254                 clearInnerLvalue( translationUnit );
    255                 assertTopLvalue( translationUnit );
    256 
    257260                // add the assignment statement after the initialization of a type parameter
    258261                PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
     
    273276                } // if
    274277
    275                 assertTopLvalue( translationUnit );
    276278                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    277                 assertTopLvalue( translationUnit );
    278279                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    279                 assertTopLvalue( translationUnit );
    280280                PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    281                 assertTopLvalue( translationUnit );
    282281                PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
    283                 assertTopLvalue( translationUnit );
    284282                if ( libcfap ) {
    285283                        // generate the bodies of cfa library functions
     
    305303                } // if
    306304
    307                 assertTopLvalue( translationUnit );
    308 
    309305                PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    310306                if ( exprp ) {
     
    313309                } // if
    314310
    315                 clearInnerLvalue( translationUnit );
    316                 assertTopLvalue( translationUnit );
    317 
    318311                // fix ObjectDecl - replaces ConstructorInit nodes
    319312                PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    320                 clearInnerLvalue( translationUnit );
    321                 assertTopLvalue( translationUnit );
    322313                if ( ctorinitp ) {
    323314                        dump ( translationUnit );
     
    326317
    327318                PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent 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
    328                 assertTopLvalue( translationUnit );
    329319
    330320                PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
    331                 assertTopLvalue( translationUnit );
    332321
    333322                PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
    334                 clearInnerLvalue( translationUnit );
    335                 assertTopLvalue( translationUnit );
    336323
    337324                PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
    338                 clearInnerLvalue( translationUnit );
    339                 assertTopLvalue( translationUnit );
    340325
    341326                PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
    342                 assertTopLvalue( translationUnit );
    343327
    344328                if ( tuplep ) {
     
    348332
    349333                PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
    350                 assertTopLvalue( translationUnit );
    351334
    352335                PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
     
    355338                        return EXIT_SUCCESS;
    356339                } // if
    357                 clearInnerLvalue( translationUnit );
    358                 assertTopLvalue( translationUnit );
     340
    359341                PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
    360                 clearInnerLvalue( translationUnit );
    361                 assertTopLvalue( translationUnit );
    362342
    363343                if ( bboxp ) {
     
    366346                } // if
    367347                PASS( "Box", GenPoly::box( translationUnit ) );
    368                 clearInnerLvalue( translationUnit );
    369                 assertTopLvalue( translationUnit );
    370348
    371349                if ( bcodegenp ) {
     
    379357
    380358                CodeTools::fillLocations( translationUnit );
    381                 assertTopLvalue( translationUnit );
    382359                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    383360
     
    445422        { "statistics", required_argument, nullptr, 'S' },
    446423        { "tree", no_argument, nullptr, 't' },
     424        { "gdb", no_argument, nullptr, 'g' },
    447425        { "", no_argument, nullptr, 0 },                                        // -w
    448426        { "", no_argument, nullptr, 0 },                                        // -W
     
    462440        "<directory> prelude directory for debug/nodebug",      // no flag
    463441        "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    464         "build in tree",                                                                        // -t
     442        "building cfa standard lib",                                                                    // -t
     443        "wait for gdb to attach",                                                                       // -g
    465444        "",                                                                                                     // -w
    466445        "",                                                                                                     // -W
     
    572551                        Stats::parse_params( optarg );
    573552                        break;
    574                   case 't':                                                                             // build in tree
     553                  case 't':                                                                             // building cfa stdlib
    575554                        treep = true;
     555                        break;
     556                  case 'g':                                                                             // wait for gdb
     557                        waiting_for_gdb = true;
    576558                        break;
    577559                  case 'w':                                                                             // suppress all warnings, hidden
Note: See TracChangeset for help on using the changeset viewer.