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