diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-15 14:49:32 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-12 20:46:52 -0400 |
commit | 8b6a69b2f37fd1370aa823320f9dc3fd482e1e78 (patch) | |
tree | aadd270b49270314c5c60f4e25ae1dd6ce74c9a4 /gdbsupport | |
parent | 08bdefb58b78621f50b30f64170e2cdc31c1b2cf (diff) | |
download | gdb-8b6a69b2f37fd1370aa823320f9dc3fd482e1e78.zip gdb-8b6a69b2f37fd1370aa823320f9dc3fd482e1e78.tar.gz gdb-8b6a69b2f37fd1370aa823320f9dc3fd482e1e78.tar.bz2 |
gdb: use intrusive list for step-over chain
The threads that need a step-over are currently linked using an
hand-written intrusive doubly-linked list, so that seems a very good
candidate for intrusive_list, convert it.
For this, we have a use case of appending a list to another one (in
start_step_over). Based on the std::list and Boost APIs, add a splice
method. However, only support splicing the other list at the end of the
`this` list, since that's all we need.
Add explicit default assignment operators to
reference_to_pointer_iterator, which are otherwise implicitly deleted.
This is needed because to define thread_step_over_list_safe_iterator, we
wrap reference_to_pointer_iterator inside a basic_safe_iterator, and
basic_safe_iterator needs to be able to copy-assign the wrapped
iterator. The move-assignment operator is therefore not needed, only
the copy-assignment operator is. But for completeness, add both.
Change-Id: I31b2ff67c7b78251314646b31887ef1dfebe510c
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/intrusive_list.h | 27 | ||||
-rw-r--r-- | gdbsupport/reference-to-pointer-iterator.h | 3 |
2 files changed, 30 insertions, 0 deletions
diff --git a/gdbsupport/intrusive_list.h b/gdbsupport/intrusive_list.h index 8d49ce4..58aa68f 100644 --- a/gdbsupport/intrusive_list.h +++ b/gdbsupport/intrusive_list.h @@ -350,6 +350,33 @@ public: pos_node->prev = &elem; } + /* Move elements from LIST at the end of the current list. */ + void splice (intrusive_list &&other) + { + if (other.empty ()) + return; + + if (this->empty ()) + { + *this = std::move (other); + return; + } + + /* [A ... B] + [C ... D] */ + T *b_elem = m_back; + node_type *b_node = as_node (b_elem); + T *c_elem = other.m_front; + node_type *c_node = as_node (c_elem); + T *d_elem = other.m_back; + + b_node->next = c_elem; + c_node->prev = b_elem; + m_back = d_elem; + + other.m_front = nullptr; + other.m_back = nullptr; + } + void pop_front () { gdb_assert (!this->empty ()); diff --git a/gdbsupport/reference-to-pointer-iterator.h b/gdbsupport/reference-to-pointer-iterator.h index 7303fa4..9210426 100644 --- a/gdbsupport/reference-to-pointer-iterator.h +++ b/gdbsupport/reference-to-pointer-iterator.h @@ -56,6 +56,9 @@ struct reference_to_pointer_iterator reference_to_pointer_iterator (const reference_to_pointer_iterator &) = default; reference_to_pointer_iterator (reference_to_pointer_iterator &&) = default; + reference_to_pointer_iterator &operator= (const reference_to_pointer_iterator &) = default; + reference_to_pointer_iterator &operator= (reference_to_pointer_iterator &&) = default; + value_type operator* () const { return &*m_it; } |