[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

Nicholas Mosier via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 8 07:27:26 PST 2024


================
@@ -276,6 +276,10 @@ class DecodedThread : public std::enable_shared_from_this<DecodedThread> {
 
     /// The string message of this item if it's an error
     std::string error;
+
+    TraceItemStorage() {}
+    ~TraceItemStorage() {}
----------------
nmosier wrote:

`TraceItemStorage()` can't be defaulted because the union member `std::string error` has a non-trivial default constructor (quoted from [here](https://en.cppreference.com/w/cpp/language/union)):
> If a union contains a non-static data member with a non-trivial default constructor, the default constructor of the union is deleted by default unless a variant member of the union has a default member initializer.

`~TraceItemStorage()` can't be defaulted because the union member `std::string error` has a non-trivial destructor (quoted from [here](https://en.cppreference.com/w/cpp/language/union)):
> If a union contains a non-static data member with a non-trivial special member function (copy/move constructor, copy/move assignment, or destructor), that function is deleted by default in the union and needs to be defined explicitly by the programmer.


Anyways, if I try to default them, I get these compile errors:
```
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h:33,
                 from /usr/include/c++/11/bits/allocator.h:46,
                 from /usr/include/c++/11/unordered_map:40,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/include/lldb/Target/Trace.h:13,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:13,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:9:
/usr/include/c++/11/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage]’:
/usr/include/c++/11/bits/alloc_traits.h:516:17:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>]’
/usr/include/c++/11/bits/vector.tcc:115:30:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Alloc = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>; std::vector<_Tp, _Alloc>::reference = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage&]’
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:110:27:   required from here
/usr/include/c++/11/ext/new_allocator.h:162:11: error: use of deleted function ‘lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage::TraceItemStorage()’
  162 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:9:
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:280:5: note: ‘lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage::TraceItemStorage()’ is implicitly deleted because the default definition would be ill-formed:
  280 |     TraceItemStorage() = default;
      |     ^~~~~~~~~~~~~~~~
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:278:17: error: union member ‘lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage::error’ with non-trivial ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
  278 |     std::string error;
      |                 ^~~~~
```
and
```
In file included from /usr/include/c++/11/optional:44,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/include/lldb/Target/Trace.h:12,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:13,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:9:
/usr/include/c++/11/bits/stl_construct.h: In instantiation of ‘void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*]’:
/usr/include/c++/11/bits/alloc_traits.h:848:15:   required from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator, std::allocator<_T2>&) [with _ForwardIterator = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage]’
/usr/include/c++/11/bits/stl_vector.h:680:15:   required from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Alloc = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>]’
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:253:62:   required from here
/usr/include/c++/11/bits/stl_construct.h:188:51: error: static assertion failed: value type is destructible
  188 |       static_assert(is_destructible<_Value_type>::value,
      |                                                   ^~~~~
/usr/include/c++/11/bits/stl_construct.h:188:51: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h:33,
                 from /usr/include/c++/11/bits/allocator.h:46,
                 from /usr/include/c++/11/unordered_map:40,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/include/lldb/Target/Trace.h:13,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:13,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:9:
/usr/include/c++/11/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::destroy(_Up*) [with _Up = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage]’:
/usr/include/c++/11/bits/alloc_traits.h:535:15:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::destroy(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*) [with _Up = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>]’
/usr/include/c++/11/bits/vector.tcc:488:28:   required from ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Alloc = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>; std::vector<_Tp, _Alloc>::iterator = std::vector<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>::iterator]’
/usr/include/c++/11/bits/vector.tcc:121:21:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Alloc = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>; std::vector<_Tp, _Alloc>::reference = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage&]’
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:110:27:   required from here
/usr/include/c++/11/ext/new_allocator.h:168:20: error: use of deleted function ‘lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage::~TraceItemStorage()’
  168 |         { __p->~_Up(); }
      |           ~~~~~~~~~^~
In file included from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:9:
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:281:5: note: ‘lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage::~TraceItemStorage()’ is implicitly deleted because the default definition would be ill-formed:
  281 |     ~TraceItemStorage() = default;
      |     ^
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:278:17: error: union member ‘lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage::error’ with non-trivial ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
  278 |     std::string error;
      |                 ^~~~~
In file included from /usr/include/c++/11/vector:66,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/llvm/include/llvm/ADT/DenseMap.h:25,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/llvm/include/llvm/Support/JSON.h:49,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/include/lldb/Target/Trace.h:15,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h:13,
                 from /afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:9:
/usr/include/c++/11/bits/stl_uninitialized.h: In instantiation of ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*>; _ForwardIterator = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*]’:
/usr/include/c++/11/bits/stl_uninitialized.h:333:37:   required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::move_iterator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*>; _ForwardIterator = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage]’
/usr/include/c++/11/bits/stl_uninitialized.h:355:2:   required from ‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*; _ForwardIterator = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage*; _Allocator = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>]’
/usr/include/c++/11/bits/vector.tcc:474:3:   required from ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Alloc = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>; std::vector<_Tp, _Alloc>::iterator = std::vector<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>::iterator]’
/usr/include/c++/11/bits/vector.tcc:121:21:   required from ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage; _Alloc = std::allocator<lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage>; std::vector<_Tp, _Alloc>::reference = lldb_private::trace_intel_pt::DecodedThread::TraceItemStorage&]’
/afs/cs.stanford.edu/u/nmosier/llvm/bugfix-lldb-intelpt/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:110:27:   required from here
/usr/include/c++/11/bits/stl_uninitialized.h:138:72: error: static assertion failed: result type must be constructible from value type of input range
  138 |       static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
      |                                                                        ^~~~~
/usr/include/c++/11/bits/stl_uninitialized.h:138:72: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
```


https://github.com/llvm/llvm-project/pull/77252


More information about the lldb-commits mailing list