Show
Ignore:
Timestamp:
08/26/10 21:26:02 (21 months ago)
Author:
Antti-Juhani Kaijanaho <antti-juhani@…>
Children:
f3e4a78e6a3f99d9180ec560cdd26ba6c962132a
Parents:
43f521291669f483d361949fa6c886c0fbd94daf
git-committer:
Antti-Juhani Kaijanaho <antti-juhani@…> (08/26/10 21:26:02)
Message:

 boost::assertion_failed Improve on the logging speed.

Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • assert_handler.cc

    rd4631b9 r6c86e7c  
    2727namespace boost 
    2828{ 
    29  
    3029        void assertion_failed(char const *expr, 
    3130                              char const *function, 
     
    5150                for (size_t i = 0; i < size; i++) 
    5251                { 
     52                        ll << "\t" << bt[i] << "\n"; 
     53                } 
     54                logger::logger.flush(); 
     55                std::string gdb = "gdb --batch "; 
     56                for (size_t i = 0; i < size; i++) 
     57                { 
     58                        std::string bta = bt[i]; 
     59                        size_t ob = bta.find('['); 
     60                        size_t cb = bta.rfind(']'); 
     61                        if (ob == std::string::npos || 
     62                            cb == std::string::npos) 
     63                                continue; 
     64                        bta = bta.substr(ob + 1, cb - ob - 1); 
     65                        gdb += "--ex 'info line *"; 
     66                        gdb += bta.c_str(); 
     67                        gdb += "' "; 
     68                } 
     69                gdb += config["executable"].as<std::string>(); 
     70                gdb += " </dev/null"; 
     71                ll.open(); 
     72                ll << gdb; 
     73                ll.close(); 
     74                FILE *fp = ::popen(gdb.c_str(), "r"); 
     75                if (fp != 0) 
     76                { 
     77                        ll.open(); 
     78                        ll << "LINE INFORMATION FOLLOWS:"; 
    5379                        ll.nl(); 
    54                         ll << "\t" << bt[i] << "\n"; 
    55                         std::string bta = bt[i]; 
    56                         int ob = bta.find('['); 
    57                         int cb = bta.rfind(']'); 
    58                         if (ob == std::string::npos || cb == std::string::npos) continue; 
    59                         bta = bta.substr(ob + 1, cb - ob - 1); 
    60                         std::string gdb = "gdb --batch --ex 'info line *"; 
    61                         gdb += bta; 
    62                         gdb += "' "; 
    63                         gdb += config["executable"].as<std::string>();  
    64                         gdb += " </dev/null"; 
    65                         FILE *fp = ::popen(gdb.c_str(), "r"); 
    66                         if (fp != 0) 
    67                         { 
    68                                 while (true) 
    69                                 { 
    70                                         char buf[128]; 
    71                                         int n = ::fread(buf, 1, sizeof buf, fp); 
    72                                         ll << std::string(buf, n);  
    73                                         if (n == 0) break; 
    74                                 } 
    75                                 ::pclose(fp); 
    76                         } 
     80                        while (true) 
     81                        { 
     82                                char buf[128]; 
     83                                int n = ::fread(buf, 1, sizeof buf, fp); 
     84                                ll << std::string(buf, n);  
     85                                if (n == 0) break; 
     86                        } 
     87                        ::pclose(fp); 
     88                        ll.close(); 
     89                        logger::logger.flush(); 
    7790                } 
    78                 ll.close(); 
    79                 logger::logger.flush(); 
    8091 
    8192                std::free(bt);