Breakpoints, don't skip prologue of ifunc resolvers with debug info
[deliverable/binutils-gdb.git] / gdb / common / gdb_vecs.h
1 /* Some commonly-used VEC types.
2
3 Copyright (C) 2012-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef GDB_VECS_H
21 #define GDB_VECS_H
22
23 #include "vec.h"
24
25 typedef const char *const_char_ptr;
26
27 DEF_VEC_P (const_char_ptr);
28
29 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
30
31 You may modify the returned strings. */
32
33 extern std::vector<gdb::unique_xmalloc_ptr<char>>
34 delim_string_to_char_ptr_vec (const char *str, char delimiter);
35
36 /* Like dirnames_to_char_ptr_vec, but append the directories to *VECP. */
37
38 extern void dirnames_to_char_ptr_vec_append
39 (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
40
41 /* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
42 elements in their original order. For empty string ("") DIRNAMES return
43 list of one empty string ("") element.
44
45 You may modify the returned strings. */
46
47 extern std::vector<gdb::unique_xmalloc_ptr<char>>
48 dirnames_to_char_ptr_vec (const char *dirnames);
49
50 /* Remove the element pointed by iterator IT from VEC, not preserving the order
51 of the remaining elements. Return the removed element. */
52
53 template <typename T>
54 T
55 unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
56 {
57 gdb_assert (it >= vec.begin () && it < vec.end ());
58
59 T removed = std::move (*it);
60 *it = std::move (vec.back ());
61 vec.pop_back ();
62
63 return removed;
64 }
65
66 /* Remove the element at position IX from VEC, not preserving the order of the
67 remaining elements. Return the removed element. */
68
69 template <typename T>
70 T
71 unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
72 {
73 gdb_assert (ix < vec.size ());
74
75 return unordered_remove (vec, vec.begin () + ix);
76 }
77
78 /* Remove the element at position IX from VEC, preserving the order the
79 remaining elements. Return the removed element. */
80
81 template <typename T>
82 T
83 ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
84 {
85 gdb_assert (ix < vec.size ());
86
87 T removed = std::move (vec[ix]);
88 vec.erase (vec.begin () + ix);
89
90 return removed;
91 }
92
93 #endif /* GDB_VECS_H */
This page took 0.03068 seconds and 4 git commands to generate.