gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdbsupport / gdb_vecs.cc
CommitLineData
48faced0
DE
1/* Some commonly-used VEC types.
2
b811d2c2 3 Copyright (C) 2012-2020 Free Software Foundation, Inc.
48faced0
DE
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
727605ca 20#include "common-defs.h"
48faced0
DE
21#include "gdb_vecs.h"
22#include "host-defs.h"
23
749234e5 24/* Worker function to split character delimiter separated string of fields
e80aaf61 25 STR into a char pointer vector. */
48faced0 26
749234e5 27static void
e80aaf61
SM
28delim_string_to_char_ptr_vec_append
29 (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
30 char delimiter)
48faced0
DE
31{
32 do
33 {
34 size_t this_len;
e6a959d6
PA
35 const char *next_field;
36 char *this_field;
48faced0 37
749234e5
DE
38 next_field = strchr (str, delimiter);
39 if (next_field == NULL)
40 this_len = strlen (str);
48faced0
DE
41 else
42 {
749234e5
DE
43 this_len = next_field - str;
44 next_field++;
48faced0
DE
45 }
46
224c3ddb 47 this_field = (char *) xmalloc (this_len + 1);
749234e5
DE
48 memcpy (this_field, str, this_len);
49 this_field[this_len] = '\0';
e80aaf61 50 vecp->emplace_back (this_field);
48faced0 51
749234e5 52 str = next_field;
48faced0 53 }
749234e5
DE
54 while (str != NULL);
55}
56
e80aaf61 57/* See gdb_vecs.h. */
749234e5 58
e80aaf61 59std::vector<gdb::unique_xmalloc_ptr<char>>
749234e5
DE
60delim_string_to_char_ptr_vec (const char *str, char delimiter)
61{
e80aaf61 62 std::vector<gdb::unique_xmalloc_ptr<char>> retval;
749234e5
DE
63
64 delim_string_to_char_ptr_vec_append (&retval, str, delimiter);
65
66 return retval;
67}
68
e80aaf61 69/* See gdb_vecs.h. */
749234e5
DE
70
71void
e80aaf61
SM
72dirnames_to_char_ptr_vec_append
73 (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
749234e5
DE
74{
75 delim_string_to_char_ptr_vec_append (vecp, dirnames, DIRNAME_SEPARATOR);
48faced0
DE
76}
77
e80aaf61 78/* See gdb_vecs.h. */
48faced0 79
e80aaf61 80std::vector<gdb::unique_xmalloc_ptr<char>>
48faced0
DE
81dirnames_to_char_ptr_vec (const char *dirnames)
82{
e80aaf61 83 std::vector<gdb::unique_xmalloc_ptr<char>> retval;
48faced0
DE
84
85 dirnames_to_char_ptr_vec_append (&retval, dirnames);
86
87 return retval;
88}
This page took 0.563836 seconds and 4 git commands to generate.