Changeset d4631b971e1f9590c6c91c0c266bfe665fccaaaf

Show
Ignore:
Timestamp:
06/21/10 09:04:19 (2 years ago)
Author:
Antti-Juhani Kaijanaho <ajk@…>
Children:
72ebe081314754cf0300ebd5b8969fac31b3330e
Parents:
959687afa28ccfe698945609bed89f4f17adc1cb
git-committer:
Antti-Juhani Kaijanaho <ajk@…> (06/21/10 09:04:19)
Message:

Use gdb to get more readable assertion backtraces

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

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • GNUmakefile.in

    r19beb87 rd4631b9  
    1717         @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_THREAD_LIB@ \ 
    1818         @GnuTLS_LIBS@ 
    19 DEFS = @DEFS@ -DCONFFILE=\"$(cfgfile)\" 
     19DEFS = @DEFS@ -DCONFFILE=\"$(cfgfile)\" -DBINDIR=\"${bindir}\" 
    2020 
    2121INSTALL = @INSTALL@ 
  • assert_handler.cc

    r476f073 rd4631b9  
    1818 */ 
    1919 
     20#include "config.hh" 
    2021#include "logger/logline.hh" 
    2122 
    2223#include <boost/assert.hpp> 
    2324#include <execinfo.h> 
     25#include <stdio.h> 
    2426 
    2527namespace boost 
     
    5052                { 
    5153                        ll.nl(); 
    52                         ll << "\t" << bt[i]; 
     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                        } 
    5377                } 
    5478                ll.close(); 
  • config.cc

    r19beb87 rd4631b9  
    5353        opts.add_options() 
    5454                ( "help", "show this help message") 
     55                ( "executable", 
     56                  po::value<std::string>()->default_value(BINDIR "/alue"), 
     57                  "the location of a debuggable executable (for backtraces)" ) 
    5558                ( "daemon", 
    5659                  po::value<bool>()->default_value(true),