diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2018-05-08 19:41:02 +0000 |
---|---|---|
committer | François Dumont <fdumont@gcc.gnu.org> | 2018-05-08 19:41:02 +0000 |
commit | a5277405c8ec3cc34a48c1498abcfc3145046477 (patch) | |
tree | 09b24aa95a0be23379b9f508ae725c5434a3bfae | |
parent | 9f171abdbcdb944e317ddee480d62b4dc7ce6cbf (diff) | |
download | gcc-a5277405c8ec3cc34a48c1498abcfc3145046477.zip gcc-a5277405c8ec3cc34a48c1498abcfc3145046477.tar.gz gcc-a5277405c8ec3cc34a48c1498abcfc3145046477.tar.bz2 |
formatter.h (_Error_formatter::_M_function): New.
2018-05-08 François Dumont <fdumont@gcc.gnu.org>
* include/debug/formatter.h (_Error_formatter::_M_function): New.
(_Error_formatter(const char*, unsigned int)): Adapt.
(_Error_formatter::_M_at): Rename in...
(_Error_formatter::_S_at): ...that and adapt.
* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_AT_F): New.
(_GLIBCXX_DEBUG_VERIFY_AT, _GLIBCXX_DEBUG_VERIFY): Adapt.
* src/c++11/debug.cc (_Error_formatter::_M_error): Render _M_function
when available.
From-SVN: r260052
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/formatter.h | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/macros.h | 16 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/debug.cc | 13 |
4 files changed, 38 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8c03e2f..87bd39c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2018-05-08 François Dumont <fdumont@gcc.gnu.org> + + * include/debug/formatter.h (_Error_formatter::_M_function): New. + (_Error_formatter(const char*, unsigned int)): Adapt. + (_Error_formatter::_M_at): Rename in... + (_Error_formatter::_S_at): ...that and adapt. + * include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_AT_F): New. + (_GLIBCXX_DEBUG_VERIFY_AT, _GLIBCXX_DEBUG_VERIFY): Adapt. + * src/c++11/debug.cc (_Error_formatter::_M_error): Render _M_function + when available. + 2018-05-08 Jonathan Wakely <jwakely@redhat.com> * include/bits/regex_automaton.h (_NFA_base::_M_paren_stack, _NFA): diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h index 52a8762..c160bd8 100644 --- a/libstdc++-v3/include/debug/formatter.h +++ b/libstdc++-v3/include/debug/formatter.h @@ -467,8 +467,10 @@ namespace __gnu_debug #endif private: - _Error_formatter(const char* __file, unsigned int __line) + _Error_formatter(const char* __file, unsigned int __line, + const char* __function) : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0) + , _M_function(__function) { } #if !_GLIBCXX_INLINE_VERSION @@ -483,12 +485,13 @@ namespace __gnu_debug _Parameter _M_parameters[__max_parameters]; unsigned int _M_num_parameters; const char* _M_text; + const char* _M_function; public: static _Error_formatter& - _M_at(const char* __file, unsigned int __line) + _S_at(const char* __file, unsigned int __line, const char* __function) { - static _Error_formatter __formatter(__file, __line); + static _Error_formatter __formatter(__file, __line, __function); return __formatter; } }; diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h index 12eac2e..6f901bc 100644 --- a/libstdc++-v3/include/debug/macros.h +++ b/libstdc++-v3/include/debug/macros.h @@ -38,16 +38,20 @@ * the user error and where the error is reported. * */ -#define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line) \ +#define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \ do \ { \ - if (! (_Condition)) \ - __gnu_debug::_Error_formatter::_M_at(_File, _Line) \ - ._ErrorMessage._M_error(); \ + if (! (_Cond)) \ + __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \ + ._ErrMsg._M_error(); \ } while (false) -#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ - _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__) +#define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \ + _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,__PRETTY_FUNCTION__) + +#define _GLIBCXX_DEBUG_VERIFY(_Cond,_ErrMsg) \ + _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond, _ErrMsg, __FILE__, __LINE__, \ + __PRETTY_FUNCTION__) // Verify that [_First, _Last) forms a valid iterator range. #define __glibcxx_check_valid_range(_First,_Last) \ diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index 7c0b540..89d387c 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -923,9 +923,9 @@ namespace continue; } - if (*start != '%') + if (!num_parameters || *start != '%') { - // Normal char. + // Normal char or no parameter to look for. buf[bufindex++] = *start++; continue; } @@ -1034,6 +1034,15 @@ namespace __gnu_debug if (ctx._M_max_length) ctx._M_wordwrap = true; + if (_M_function) + { + print_literal(ctx, "In function:\n"); + print_string(ctx, _M_function, nullptr, 0); + print_literal(ctx, "\n"); + ctx._M_first_line = true; + print_literal(ctx, "\n"); + } + print_literal(ctx, "Error: "); // Print the error message |