Revert from std::regex to C POXIX regex.
* Bug: In Hurricane::Backtrace(), the std::regex supplied by gcc 4.8.5 seems to be buggy. So, for now, to compile on my reference system, revert to C POSIX.
This commit is contained in:
parent
35c44f8b81
commit
9852c76c2c
|
@ -90,7 +90,8 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <regex>
|
//#include <regex>
|
||||||
|
#include <regex.h>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
namespace boptions = boost::program_options;
|
namespace boptions = boost::program_options;
|
||||||
#include "hurricane/Backtrace.h"
|
#include "hurricane/Backtrace.h"
|
||||||
|
@ -431,7 +432,6 @@ namespace Hurricane {
|
||||||
: _stack()
|
: _stack()
|
||||||
{
|
{
|
||||||
if (not enabled) return;
|
if (not enabled) return;
|
||||||
|
|
||||||
if (_inConstructor) {
|
if (_inConstructor) {
|
||||||
_stack.push_back( "[BUG] Backtrace::Backtrace(): An error occurred in the backtace *istself*." );
|
_stack.push_back( "[BUG] Backtrace::Backtrace(): An error occurred in the backtace *istself*." );
|
||||||
_stack.push_back( "" );
|
_stack.push_back( "" );
|
||||||
|
@ -458,18 +458,27 @@ namespace Hurricane {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined __linux__ || defined __FreeBSD__)
|
#if (defined __linux__ || defined __FreeBSD__)
|
||||||
std::regex re ( "([^(]+)\\(([^+]+)\\+([^)]+)\\) \\[(.+)]" );
|
//std::regex re ( "([^(]+)\\(([^+]+)\\+([^)]+)\\) \\[(.+)]", std::regex::extended );
|
||||||
std::cmatch match;
|
//std::cmatch match;
|
||||||
string homeDir = getHome();
|
regex_t re;
|
||||||
|
regmatch_t match[5];
|
||||||
|
string homeDir = getHome();
|
||||||
|
regcomp( &re, "([^(]+)\\(([^+]+)\\+([^)]+)\\) \\[(.+)]", REG_EXTENDED );
|
||||||
|
|
||||||
for ( size_t i=0 ; i<depth ; ++i ) {
|
for ( size_t i=0 ; i<depth ; ++i ) {
|
||||||
if (std::regex_search(symbols[i],match,re)) {
|
//if (std::regex_search(symbols[i],match,re)) {
|
||||||
// int64_t symbolOffset = std::stol( match[3], 0, 16 );
|
if (not regexec(&re,symbols[i],5,match,0)) {
|
||||||
// int64_t rlocAddress = std::stol( match[4], 0, 16 );
|
|
||||||
ostringstream debugline;
|
ostringstream debugline;
|
||||||
|
string match1 = string(symbols[i]).substr( match[1].rm_so, match[1].rm_eo - match[1].rm_so );
|
||||||
|
string match2 = string(symbols[i]).substr( match[2].rm_so, match[2].rm_eo - match[2].rm_so );
|
||||||
|
|
||||||
#ifdef HAVE_LIBBFD
|
#ifdef HAVE_LIBBFD
|
||||||
Bfd::Request request ( match[1], match[2], symbolOffset, rlocAddress );
|
string match3 = string(symbols[i]).substr( match[3].rm_so, match[3].rm_eo - match[3].rm_so );
|
||||||
|
string match4 = string(symbols[i]).substr( match[4].rm_so, match[4].rm_eo - match[4].rm_so );
|
||||||
|
|
||||||
|
int64_t symbolOffset = std::stol( match3, 0, 16 );
|
||||||
|
int64_t rlocAddress = std::stol( match4, 0, 16 );
|
||||||
|
Bfd::Request request ( match1, match2, symbolOffset, rlocAddress );
|
||||||
|
|
||||||
if (bfds.lookup(request) and not request.fileName().empty()) {
|
if (bfds.lookup(request) and not request.fileName().empty()) {
|
||||||
string fileName = request.fileName();
|
string fileName = request.fileName();
|
||||||
|
@ -480,8 +489,8 @@ namespace Hurricane {
|
||||||
<< fileName << ":" << request.lineno();
|
<< fileName << ":" << request.lineno();
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
string demangled = demangle( match[2] );
|
string demangled = demangle( match2 );
|
||||||
if (demangled.empty()) demangled = match[2];
|
if (demangled.empty()) demangled = match2;
|
||||||
|
|
||||||
debugline << "<b>" << demangled << "</b>";
|
debugline << "<b>" << demangled << "</b>";
|
||||||
#ifdef HAVE_LIBBFD
|
#ifdef HAVE_LIBBFD
|
||||||
|
@ -492,6 +501,7 @@ namespace Hurricane {
|
||||||
_stack.push_back( symbols[i] );
|
_stack.push_back( symbols[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
regfree( &re );
|
||||||
#else
|
#else
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
std::regex re ( "(\\d+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+\\+\\s+(\\d+)" );
|
std::regex re ( "(\\d+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+\\+\\s+(\\d+)" );
|
||||||
|
|
Loading…
Reference in New Issue