From 4aec49e08a2f0256db5172a39d7a99208e57e9a3 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 10 Aug 2016 16:13:21 +0200 Subject: [PATCH] Allows multiple backtraces objects, as long as they are fully created. --- hurricane/src/hurricane/Backtrace.cpp | 10 ++++++---- hurricane/src/hurricane/hurricane/Backtrace.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hurricane/src/hurricane/Backtrace.cpp b/hurricane/src/hurricane/Backtrace.cpp index c91aa02a..bcb995cb 100644 --- a/hurricane/src/hurricane/Backtrace.cpp +++ b/hurricane/src/hurricane/Backtrace.cpp @@ -413,7 +413,7 @@ namespace Hurricane { // Class : "Hurricane::Backtrace". - int Backtrace::_callCount = 0; + bool Backtrace::_inConstructor = false; TextTranslator Backtrace::_textTranslator = TextTranslator::toTextTranslator(); const size_t Backtrace::_stackSize = 50; @@ -428,7 +428,7 @@ namespace Hurricane { Backtrace::Backtrace () : _stack() { - if (_callCount > 0) { + if (_inConstructor) { _stack.push_back( "[BUG] Backtrace::Backtrace(): An error occurred in the backtace *istself*." ); _stack.push_back( "" ); _stack.push_back( " Under RHEL 6, this may be due to a link with a wrong version of ," ); @@ -438,7 +438,7 @@ namespace Hurricane { _stack.push_back( " For other OSs, check for any problems related to BFD." ); return; } - ++_callCount; + _inConstructor = true; #if (defined __linux__ || defined __FreeBSD__ || defined __APPLE__) void* rawStack [ _stackSize ]; @@ -484,6 +484,7 @@ namespace Hurricane { _stack.push_back( symbols[i] ); } } +#else # ifdef __APPLE__ boost::regex re ( "(\\d+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+\\+\\s+(\\d+)" ); boost::cmatch match; @@ -507,11 +508,12 @@ namespace Hurricane { _stack.push_back( "Backtrace only supported under FreeBSD, Linux and OSX." ); # endif #endif + _inConstructor = false; } Backtrace::~Backtrace () - { --_callCount; } + { } string Backtrace::htmlWhere () const diff --git a/hurricane/src/hurricane/hurricane/Backtrace.h b/hurricane/src/hurricane/hurricane/Backtrace.h index 8d4178a6..eefcfeaa 100644 --- a/hurricane/src/hurricane/hurricane/Backtrace.h +++ b/hurricane/src/hurricane/hurricane/Backtrace.h @@ -50,7 +50,7 @@ namespace Hurricane { inline std::string _getTypeName () const; inline std::string _getString () const; private: - static int _callCount; + static bool _inConstructor; static TextTranslator _textTranslator; static const size_t _stackSize; std::vector _stack;