Debug Mode ENH 3/4: Add backtrace
François Dumont
frs.dumont@gmail.com
Tue May 8 19:54:00 GMT 2018
On 08/05/2018 17:27, Jonathan Wakely wrote:
> On 07/05/18 22:20 +0200, François Dumont wrote:
>> Hi
>>
>> Â Â Â Here is the patch to add backtrace info to debug assertion
>> failure output.
>>
>> Example:
>>
>> /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/vector:188:
>>
>> In function:
>> Â Â Â std::__debug::vector<_Tp, _Allocator>::vector(_InputIterator,
>> Â Â Â _InputIterator, const _Allocator&) [with _InputIterator =
>> std::reverse_iterator<__gnu_debug::_Safe_tagged_iterator<__gnu_cxx::__normal_iterator<int*,
>>
>>
>> Â Â Â std::vector<int> >, std::__debug::vector<int>,
>> Â Â Â std::random_access_iterator_tag> >; <template-parameter-2-2> =
>> void; _Tp
>> Â Â Â = int; _Allocator = std::allocator<int>]
>>
>> Backtrace:
>> Â Â Â ./debug_neg.exe() [0x4020c1]
>> Â Â Â ./debug_neg.exe() [0x400e59]
>> Â Â Â /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)
>> [0x7f13fc56e830]
>> Â Â Â ./debug_neg.exe() [0x400eb9]
>>
>> I tried to use add2line on the output address and it worked fine.
>>
>> Tested under Linux x86_64.
>>
>> I'll commit tomorrow if not told otherwise.
>>
>> Â Â Â * src/c++11/debug.cc [_GLIBCXX_HAVE_EXECINFO_H]: Include execinfo.h.
>> Â Â Â [_GLIBCXX_HAVE_EXECINFO_H](_Error_formatter::_M_error): Render
>> backtrace.
>
> Did you look into using libbacktrace? That resolves the addresses and
> prints nice symbols. See the output of AddressSantizer for what it
> looks like (I think that uses libbacktrace).
>
>
I'll go with this version for now but I'll look into libbacktrace.
It will be perhaps the occasion to play with autoconf & al tools to find
out if I can use libbacktrace.
More information about the Libstdc++
mailing list