gdb/testsuite: fix gdb.trace/signal.exp on x86
[binutils-gdb/blckswan.git] / gdb / dwarf2 / stringify.c
blobe0bd38daeb2cff81613b9a69835b4d9bd447183b
1 /* DWARF stringify code
3 Copyright (C) 1994-2022 Free Software Foundation, Inc.
5 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
6 Inc. with support from Florida State University (under contract
7 with the Ada Joint Program Office), and Silicon Graphics, Inc.
8 Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
9 based on Fred Fish's (Cygnus Support) implementation of DWARF 1
10 support.
12 This file is part of GDB.
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include "defs.h"
28 #include "dwarf2.h"
29 #include "dwarf2/stringify.h"
31 /* A convenience function that returns an "unknown" DWARF name,
32 including the value of V. STR is the name of the entity being
33 printed, e.g., "TAG". */
35 static const char *
36 dwarf_unknown (const char *str, unsigned v)
38 char *cell = get_print_cell ();
39 xsnprintf (cell, PRINT_CELL_SIZE, "DW_%s_<unknown: %u>", str, v);
40 return cell;
43 /* See stringify.h. */
45 const char *
46 dwarf_tag_name (unsigned tag)
48 const char *name = get_DW_TAG_name (tag);
50 if (name == NULL)
51 return dwarf_unknown ("TAG", tag);
53 return name;
56 /* See stringify.h. */
58 const char *
59 dwarf_attr_name (unsigned attr)
61 const char *name;
63 #ifdef MIPS /* collides with DW_AT_HP_block_index */
64 if (attr == DW_AT_MIPS_fde)
65 return "DW_AT_MIPS_fde";
66 #else
67 if (attr == DW_AT_HP_block_index)
68 return "DW_AT_HP_block_index";
69 #endif
71 name = get_DW_AT_name (attr);
73 if (name == NULL)
74 return dwarf_unknown ("AT", attr);
76 return name;
79 /* See stringify.h. */
81 const char *
82 dwarf_form_name (unsigned form)
84 const char *name = get_DW_FORM_name (form);
86 if (name == NULL)
87 return dwarf_unknown ("FORM", form);
89 return name;
92 /* See stringify.h. */
94 const char *
95 dwarf_bool_name (unsigned mybool)
97 if (mybool)
98 return "TRUE";
99 else
100 return "FALSE";
103 /* See stringify.h. */
105 const char *
106 dwarf_type_encoding_name (unsigned enc)
108 const char *name = get_DW_ATE_name (enc);
110 if (name == NULL)
111 return dwarf_unknown ("ATE", enc);
113 return name;
116 /* See stringify.h. */
118 const char *
119 dwarf_unit_type_name (int unit_type)
121 const char *name = get_DW_UT_name (unit_type);
123 if (name == nullptr)
124 return dwarf_unknown ("UT", unit_type);
126 return name;