This is an archive of the discontinued LLVM Phabricator instance.

Overload != operator, make overloaded - operator const, for libunwind::EHABISectionIterator.
ClosedPublic

Authored by chadduffin on Jun 10 2020, 10:51 AM.

Details

Summary

This change fixes two issues that arise when compiling libunwind with GCC and specifying the flag "-D_GLIBCXX_DEBUG". The first issue is that there is no overloaded != operator for libunwind::EHABISectionIterator:

In file included from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/debug.h:127:0,
                 from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_iterator_base_funcs.h:65,
                 from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_algobase.h:66,
                 from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/algorithm:61,
                 from ../../third_party/llvm-project/libunwind/src/libunwind.cpp:19:
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/functions.h: In instantiation of ‘bool __gnu_debug::__check_partitioned_upper(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>; _Tp = unsigned int]’:
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_algo.h:2483:7:   required from ‘_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>; _Tp = unsigned int]’
../../third_party/llvm-project/libunwind/src/UnwindCursor.hpp:806:69:   required from ‘bool libunwind::UnwindCursor<A, R>::getInfoFromEHABISection(libunwind::UnwindCursor<A, R>::pint_t, const libunwind::UnwindInfoSections&) [with A = libunwind::LocalAddressSpace; R = libunwind::Registers_arm; libunwind::UnwindCursor<A, R>::pint_t = unsigned int]’
../../third_party/llvm-project/libunwind/src/UnwindCursor.hpp:1320:32:   required from ‘void libunwind::UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool) [with A = libunwind::LocalAddressSpace; R = libunwind::Registers_arm]’
../../third_party/llvm-project/libunwind/src/libunwind.cpp:420:1:   required from here
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/functions.h:372:22: error: no match for ‘operator!=’ (operand types are ‘libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>’ and ‘libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>’)
       while (__first != __last && !(__value < *__first))

The next issue was that the overloaded - operator was not a const member:

In file included from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/debug.h:127:0,
                 from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_iterator_base_funcs.h:65,
                 from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_algobase.h:66,
                 from /usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/algorithm:61,
                 from ../../third_party/llvm-project/libunwind/src/libunwind.cpp:19:
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/functions.h: In instantiation of ‘bool __gnu_debug::__valid_range_aux2(const _RandomAccessIterator&, const _RandomAccessIterator&, std::random_access_iterator_tag) [with _RandomAccessIterator = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>]’:
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/functions.h:122:43:   required from ‘bool __gnu_debug::__valid_range_aux(const _InputIterator&, const _InputIterator&, std::__false_type) [with _InputIterator = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>]’
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/functions.h:134:60:   required from ‘bool __gnu_debug::__valid_range(const _InputIterator&, const _InputIterator&) [with _InputIterator = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>]’
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_algo.h:2483:7:   required from ‘_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>; _Tp = unsigned int]’
../../third_party/llvm-project/libunwind/src/UnwindCursor.hpp:813:69:   required from ‘bool libunwind::UnwindCursor<A, R>::getInfoFromEHABISection(libunwind::UnwindCursor<A, R>::pint_t, const libunwind::UnwindInfoSections&) [with A = libunwind::LocalAddressSpace; R = libunwind::Registers_arm; libunwind::UnwindCursor<A, R>::pint_t = unsigned int]’
../../third_party/llvm-project/libunwind/src/UnwindCursor.hpp:1327:32:   required from ‘void libunwind::UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool) [with A = libunwind::LocalAddressSpace; R = libunwind::Registers_arm]’
../../third_party/llvm-project/libunwind/src/libunwind.cpp:420:1:   required from here
/usr/local/google/home/chadduffin/raspi_tools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/debug/functions.h:93:21: error: passing ‘const libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>’ as ‘this’ argument of ‘size_t libunwind::EHABISectionIterator<A>::operator-(const _Self&) [with A = libunwind::LocalAddressSpace; size_t = unsigned int; libunwind::EHABISectionIterator<A>::_Self = libunwind::EHABISectionIterator<libunwind::LocalAddressSpace>]’ discards qualifiers [-fpermissive]
     { return __last - __first >= 0; }

With both of these operators overloaded the issue is resolved.

Diff Detail

Event Timeline

chadduffin created this revision.Jun 10 2020, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2020, 10:51 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Could you please upload the diff with additional context in the future? Why not just make the member that is currently defined const? It shouldn't have to modify this.

Full context is now provided with the diff, and the recommended change of updating the overloaded - operator instead of overloading it again has been made.

Good looking out, did not realize that the diff had zero context. I have updated that, as well as changed the overloaded - instead of duplicating it. Thank you for your help-- PTAL!

compnerd accepted this revision.Jun 12 2020, 8:56 AM
This revision is now accepted and ready to land.Jun 12 2020, 8:56 AM

Do you need this committed on your behalf or do you have commit access?

I do not believe I have commit access, so if you would be able to do that for me it would be appreciated :)