Is it too early to consider this patch ? Or just lack of time ?
Considering the patch I would really appreciate that, if validated, it
gets in as early as possible in next release.
Thanks,
François
On 24/04/21 3:46 pm, François Dumont wrote:
Hi
Here is the patch to add backtrace generation on _GLIBCXX_DEBUG
assertions thanks to libbacktrace.
In addition to this integration I am also improving the generation
of the assertion message thanks to the "%.*s" printf format, it avoids
an intermediate buffer most of the time. I am also removing the "__"
used for uglification to get a nicer output. I can propose it in a
dedicated patch if you prefer.
I am adding GLIBCXX_3.4.30 abi version to properly export the 2
new weak symbols. Let me know if it isn't necessary.
libstdc++: [_GLIBCXX_DEBUG] Add backtrace generation thanks to
libbacktrace
Add _GLIBCXX_DEBUG_BACKTRACE macro to activate backtrace
generation on
_GLIBCXX_DEBUG assertions using libbacktrace.
* config/abi/pre/gnu.ver: Add GLIBCXX_3.4.30 version and
new exports.
* include/debug/formatter.h [_GLIBCXX_DEBUG_BACKTRACE]:
Include <backtrace-supported.h>.
[_GLIBCXX_DEBUG_BACKTRACE && BACKTRACE_SUPPORTED]:
Include <backtrace.h>.
[(!_GLIBCXX_DEBUG_BACKTRACE || !BACKTRACE_SUPPORTED) &&
_GLIBCXX_USE_C99_STDINT_TR1]: Include <stdint.h>.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE]
(__gnu_debug::__create_backtrace_state): New.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE]
(__gnu_debug::__render_backtrace): New.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE](_Error_formatter::_M_print_backtrace):
New.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE](_Error_formatter::_M_backtrace_state):
New.
(_Error_formatter::_Error_formatter): Outline definition.
* src/c++11/debug.cc: Include <cstring>.
(_Print_func_t): New.
(print_word): Use '%.*s' format in fprintf to render only
expected
number of chars.
(print_raw(PrintContext&, const char*, ptrdiff_t)): New.
(print_function(PrintContext&, const char*,
_Print_func_t)): New.
(print_type): Use latter.
(print_string(PrintContext&, const char*, const
_Parameter*, size_t)):
Change signature to...
(print_string(PrintContext&, const char*, ptrdiff_t, const
_Parameter*,
size_t)): ...this and adapt. Remove intermediate buffer to
render input
string.
(print_string(PrintContext&, const char*, ptrdiff_t)): New.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE]
(print_backtrace(void*, uintptr_t, const char*, int, const
char*)): New.
(_Error_formatter::_M_error()): Adapt.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE]
(__gnu_debug::__create_backtrace_state): New, weak symbol.
[_GLIBCXX_DEBUG_USE_LIBBACKTRACE]
(__gnu_debug::__render_backtrace): New, weak symbol.
* testsuite/util/testsuite_abi.cc: Add new symbol version.
* doc/xml/manual/debug_mode.xml: Document
_GLIBCXX_DEBUG_BACKTRACE.
* doc/xml/manual/using.xml: Likewise.
Tested under Linux x86_64.
Ok to commit ?
François