1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2013, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6
7 #include "TagNames.h"
8
9 #include "Dwarf.h"
10
11
12 struct tag_name_info {
13 uint16 tag;
14 const char* name;
15 };
16
17
18 #undef ENTRY
19 #define ENTRY(name) { DW_TAG_##name, "DW_TAG_" #name }
20
21 static const tag_name_info kTagNameInfos[] = {
22 ENTRY(array_type),
23 ENTRY(class_type),
24 ENTRY(entry_point),
25 ENTRY(enumeration_type),
26 ENTRY(formal_parameter),
27 ENTRY(imported_declaration),
28 ENTRY(label),
29 ENTRY(lexical_block),
30 ENTRY(member),
31 ENTRY(pointer_type),
32 ENTRY(reference_type),
33 ENTRY(compile_unit),
34 ENTRY(string_type),
35 ENTRY(structure_type),
36 ENTRY(subroutine_type),
37 ENTRY(typedef),
38 ENTRY(union_type),
39 ENTRY(unspecified_parameters),
40 ENTRY(variant),
41 ENTRY(common_block),
42 ENTRY(common_inclusion),
43 ENTRY(inheritance),
44 ENTRY(inlined_subroutine),
45 ENTRY(module),
46 ENTRY(ptr_to_member_type),
47 ENTRY(set_type),
48 ENTRY(subrange_type),
49 ENTRY(with_stmt),
50 ENTRY(access_declaration),
51 ENTRY(base_type),
52 ENTRY(catch_block),
53 ENTRY(const_type),
54 ENTRY(constant),
55 ENTRY(enumerator),
56 ENTRY(file_type),
57 ENTRY(friend),
58 ENTRY(namelist),
59 ENTRY(namelist_item),
60 ENTRY(packed_type),
61 ENTRY(subprogram),
62 ENTRY(template_type_parameter),
63 ENTRY(template_value_parameter),
64 ENTRY(thrown_type),
65 ENTRY(try_block),
66 ENTRY(variant_part),
67 ENTRY(variable),
68 ENTRY(volatile_type),
69 ENTRY(dwarf_procedure),
70 ENTRY(restrict_type),
71 ENTRY(interface_type),
72 ENTRY(namespace),
73 ENTRY(imported_module),
74 ENTRY(unspecified_type),
75 ENTRY(partial_unit),
76 ENTRY(imported_unit),
77 ENTRY(condition),
78 ENTRY(shared_type),
79 ENTRY(type_unit),
80 ENTRY(rvalue_reference_type),
81 ENTRY(template_alias),
82 ENTRY(coarray_type),
83 ENTRY(generic_subrange),
84 ENTRY(dynamic_type),
85 ENTRY(atomic_type),
86 ENTRY(call_site),
87 ENTRY(call_site_parameter),
88 ENTRY(skeleton_unit),
89 ENTRY(immutable_type),
90 ENTRY(GNU_template_parameter_pack),
91 ENTRY(GNU_formal_parameter_pack),
92 ENTRY(GNU_call_site),
93 ENTRY(GNU_call_site_parameter),
94 {}
95 };
96
97
98 static const uint32 kTagNameInfoCount = DW_TAG_immutable_type + 5;
99 static const char* sTagNames[kTagNameInfoCount];
100
101 static struct InitTagNames {
InitTagNamesInitTagNames102 InitTagNames()
103 {
104 for (uint32 i = 0; kTagNameInfos[i].name != NULL; i++) {
105 const tag_name_info& info = kTagNameInfos[i];
106 if (info.tag <= DW_TAG_immutable_type)
107 sTagNames[info.tag] = info.name;
108 else {
109 sTagNames[DW_TAG_immutable_type + 1 + (info.tag
110 - DW_TAG_GNU_template_parameter_pack)] = info.name;
111 }
112 }
113 }
114 } sInitTagNames;
115
116
117 const char*
get_entry_tag_name(uint16 tag)118 get_entry_tag_name(uint16 tag)
119 {
120 if (tag <= DW_TAG_immutable_type)
121 return sTagNames[tag];
122 else if (tag >= DW_TAG_GNU_template_parameter_pack
123 && tag <= DW_TAG_GNU_call_site_parameter) {
124 return sTagNames[DW_TAG_immutable_type + 1 + (tag
125 - DW_TAG_GNU_template_parameter_pack)];
126 }
127
128 return NULL;
129 }
130