1 /* OS ABI variant handling for GDB and gdbserver.
3 Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #include "gdbsupport/osabi.h"
22 /* Names associated with each osabi. */
26 /* The "pretty" name. */
30 /* The triplet regexp, or NULL if not known. */
35 /* This table matches the indices assigned to enum gdb_osabi. Keep
37 static const struct osabi_names gdb_osabi_names
[] =
39 #define GDB_OSABI_DEF_FIRST(Enum, Name, Regex) \
42 #define GDB_OSABI_DEF(Enum, Name, Regex) \
45 #define GDB_OSABI_DEF_LAST(Enum, Name, Regex) \
48 #include "gdbsupport/osabi.def"
50 #undef GDB_OSABI_DEF_LAST
52 #undef GDB_OSABI_DEF_FIRST
55 /* See gdbsupport/osabi.h. */
58 gdbarch_osabi_name (enum gdb_osabi osabi
)
60 if (osabi
>= GDB_OSABI_UNKNOWN
&& osabi
< GDB_OSABI_INVALID
)
61 return gdb_osabi_names
[osabi
].pretty
;
63 return gdb_osabi_names
[GDB_OSABI_INVALID
].pretty
;
66 /* See gdbsupport/osabi.h. */
69 osabi_from_tdesc_string (const char *name
)
73 for (i
= 0; i
< ARRAY_SIZE (gdb_osabi_names
); i
++)
74 if (strcmp (name
, gdb_osabi_names
[i
].pretty
) == 0)
76 /* See note above: the name table matches the indices assigned
78 enum gdb_osabi osabi
= (enum gdb_osabi
) i
;
80 if (osabi
== GDB_OSABI_INVALID
)
81 return GDB_OSABI_UNKNOWN
;
86 return GDB_OSABI_UNKNOWN
;
89 /* See gdbsupport/osabi.h. */
92 osabi_triplet_regexp (enum gdb_osabi osabi
)
94 if (osabi
>= GDB_OSABI_UNKNOWN
&& osabi
< GDB_OSABI_INVALID
)
95 return gdb_osabi_names
[osabi
].regexp
;
97 return gdb_osabi_names
[GDB_OSABI_INVALID
].regexp
;