Debug Mode ENH 4/4: Add special iterator support
François Dumont
frs.dumont@gmail.com
Tue May 8 13:15:00 GMT 2018
Here is a patch to teach _Parameter type about special iterator types so
that it improves final output.
It also get rid of the debug layer when possible so that failure output
is cleaner. Debug mode is already transparent to users there is no need
to show the Debug types in the output.
Here is the output for the newly added tests, for the move_iterator:
/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::move_iterator<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<int*,
   std::vector<int> >, std::__debug::vector<int> >;
<template-parameter-2-2> = void; _Tp
   = int; _Allocator = std::allocator<int>]
Backtrace:
   ./debug_neg.exe() [0x402956]
   ./debug_neg.exe() [0x402db5]
   ./debug_neg.exe() [0x4011b9]
   /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)
[0x7f3962ef8830]
   ./debug_neg.exe() [0x401219]
Error: function requires a valid iterator range [__first, __last).
Objects involved in the operation:
   iterator "__first" @ 0x0x7ffc704c05f0 {
     type = std::move_iterator<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > > > (mutable iterator);
     state = dereferenceable;
     references sequence with type 'std::__debug::vector<int,
std::allocator<int> >' @ 0x0x7ffc704c07a0
   }
   iterator "__last" @ 0x0x7ffc704c05f0 {
     type = std::move_iterator<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > > > (mutable iterator);
     state = dereferenceable (start-of-sequence);
     references sequence with type 'std::__debug::vector<int,
std::allocator<int> >' @ 0x0x7ffc704c07a0
   }
XFAIL: 24_iterators/move_iterator/debug_neg.cc execution test
For the reverse_iterator:
/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_iterator<__gnu_cxx::__normal_iterator<int*,
   std::vector<int> >, std::__debug::vector<int> >;
<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]
Error: function requires a valid iterator range [__first, __last).
Objects involved in the operation:
   iterator "__first" @ 0x0x7ffc4e1f77d0 {
     type = std::reverse_iterator<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > > > (mutable iterator);
     state = past-the-reverse-end;
     references sequence with type 'std::__debug::vector<int,
std::allocator<int> >' @ 0x0x7ffc4e1f7800
   }
   iterator "__last" @ 0x0x7ffc4e1f77d0 {
     type = std::reverse_iterator<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > > > (mutable iterator);
     state = dereferenceable (start-of-reverse-sequence);
     references sequence with type 'std::__debug::vector<int,
std::allocator<int> >' @ 0x0x7ffc4e1f7800
   }
XFAIL: 24_iterators/reverse_iterator/debug_neg.cc execution test
Tested under Linux x8-_64.
I'll commit that tomorrow if not told otherwise.
   * include/debug/safe_iterator.h (_Safe_iterator<>::_M_constant()):
   Rename in...
   (_Safe_iterator<>::_S_constant()): ...that.
   * include/debug/safe_local_iterator.h
   (_Safe_local_iterator<>::_M_constant()): Rename in...
   (_Safe_local_iterator<>::_S_constant()): ...that.
   * include/debug/formatter.h: Remove bits/cpp_type_traits.h include.
   (_Iterator_state::__rbegin): New.
   (_Iterator_state::__rmiddle): New.
   (_Iterator_state::__rend): New.
   (_Parameter::_Parameter(const _Safe_iterator<>&, const char*,
   _Is_iterator)): Use _Safe_iterator<>::_S_constant. Grab normal
underlying
   iterator type.
   (_Parameter::_Parameter(const _Safe_local_iterator<>&, const char*,
   _Is_iterator)): Likewise.
   (_Parameter::_S_reverse_state(_Iterator_state)): New.
       (_Parameter(__gnu_cxx::__normal_iterator<> const&, const char*,
   _Is_iterator)): New.
   (_Parameter(std::reverse_iterator<> const&, const char*,
   _Is_iterator)): New.
(_Parameter(std::reverse_iterator<_Safe_iterator<>> const&,
   const char*, _Is_iterator)): New.
   (_Parameter(std::move_iterator<> const&, const char*, _Is_iterator):
   New.
   (_Parameter(std::move_iterator<_Safe_iterator<>> const&, const char*,
   _Is_iterator)): New.
   * testsuite/24_iterators/move_iterator/debug_neg.cc: New.
   * testsuite/24_iterators/normal_iterator/debug_neg.cc: New.
   * testsuite/24_iterators/reverse_iterator/debug_neg.cc: New.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_iterator.patch
Type: text/x-patch
Size: 13885 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180508/6dfd6342/attachment.bin>
More information about the Libstdc++
mailing list