1 /* Thread map type for GDB, the GNU debugger.
2 Copyright (C) 2019 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include <unordered_map>
28 using ptid_thread_map
= std::unordered_map
<ptid_t
, thread_info
*, hash_ptid
>;
30 struct all_thread_map_range_iterator
32 all_thread_map_range_iterator (ptid_thread_map::const_iterator iter
)
36 bool operator!= (const all_thread_map_range_iterator
&other
)
37 { return this->m_iter
!= other
.m_iter
; }
42 thread_info
*operator* ()
43 { return this->m_iter
->second
; }
46 typename
ptid_thread_map::const_iterator m_iter
;
49 struct all_thread_map_range
51 all_thread_map_range (const ptid_thread_map
&map
)
55 all_thread_map_range_iterator
begin ()
57 return all_thread_map_range_iterator (this->m_map
.begin ());
60 all_thread_map_range_iterator
end ()
62 return all_thread_map_range_iterator (this->m_map
.end ());
66 const ptid_thread_map
&m_map
;
69 struct non_exited_thread_map_range_iterator
71 non_exited_thread_map_range_iterator (typename
ptid_thread_map::const_iterator iter
,
72 typename
ptid_thread_map::const_iterator end
)
73 : m_iter (iter
), m_end (end
)
75 advante_to_next_matching ();
78 bool operator!= (const non_exited_thread_map_range_iterator
&other
)
79 { return this->m_iter
!= other
.m_iter
; }
84 advante_to_next_matching ();
87 thread_info
*operator* ()
88 { return this->m_iter
->second
; }
91 typename
ptid_thread_map::const_iterator m_iter
;
92 typename
ptid_thread_map::const_iterator m_end
;
94 void advante_to_next_matching ()
96 while (this->m_iter
!= this->m_end
97 && this->m_iter
->second
->state
== THREAD_EXITED
)
104 struct non_exited_thread_map_range
106 non_exited_thread_map_range (const ptid_thread_map
&map
)
110 non_exited_thread_map_range_iterator
begin()
112 return non_exited_thread_map_range_iterator (this->m_map
.begin (), this->m_map
.end ());
115 non_exited_thread_map_range_iterator
end()
117 return non_exited_thread_map_range_iterator (this->m_map
.end (), this->m_map
.end ());
121 const ptid_thread_map
&m_map
;