xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_dump.c (revision 5ac3bc719ce6e70593039505b491894133237d12)
1 /*	$NetBSD: dwarf_dump.c,v 1.5 2024/03/03 17:37:30 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 2007 John Birrell (jb@freebsd.org)
5  * Copyright (c) 2009,2023 Kai Wang
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #include "_libdwarf.h"
31 
32 __RCSID("$NetBSD: dwarf_dump.c,v 1.5 2024/03/03 17:37:30 christos Exp $");
33 ELFTC_VCSID("Id: dwarf_dump.c 4012 2023-10-13 01:15:02Z kaiwang27");
34 
35 int
dwarf_get_ACCESS_name(unsigned access,const char ** s)36 dwarf_get_ACCESS_name(unsigned access, const char **s)
37 {
38 
39 	assert(s != NULL);
40 
41 	switch (access) {
42 	case DW_ACCESS_public:
43 		*s = "DW_ACCESS_public"; break;
44 	case DW_ACCESS_protected:
45 		*s = "DW_ACCESS_protected"; break;
46 	case DW_ACCESS_private:
47 		*s = "DW_ACCESS_private"; break;
48 	default:
49 		return (DW_DLV_NO_ENTRY);
50 	}
51 
52 	return (DW_DLV_OK);
53 }
54 
55 int
dwarf_get_AT_name(unsigned attr,const char ** s)56 dwarf_get_AT_name(unsigned attr, const char **s)
57 {
58 
59 	assert(s != NULL);
60 
61 	switch (attr) {
62 	case DW_AT_abstract_origin:
63 		*s = "DW_AT_abstract_origin"; break;
64 	case DW_AT_accessibility:
65 		*s = "DW_AT_accessibility"; break;
66 	case DW_AT_address_class:
67 		*s = "DW_AT_address_class"; break;
68 	case DW_AT_addr_base:
69 		*s = "DW_AT_addr_base"; break;
70 	case DW_AT_alignment:
71 		*s = "DW_AT_alignment"; break;
72 	case DW_AT_artificial:
73 		*s = "DW_AT_artificial"; break;
74 	case DW_AT_allocated:
75 		*s = "DW_AT_allocated"; break;
76 	case DW_AT_associated:
77 		*s = "DW_AT_associated"; break;
78 	case DW_AT_base_types:
79 		*s = "DW_AT_base_types"; break;
80 	case DW_AT_binary_scale:
81 		*s = "DW_AT_binary_scale"; break;
82 	case DW_AT_bit_offset:
83 		*s = "DW_AT_bit_offset"; break;
84 	case DW_AT_bit_size:
85 		*s = "DW_AT_bit_size"; break;
86 	case DW_AT_bit_stride:
87 		*s = "DW_AT_bit_stride"; break;
88 	case DW_AT_byte_size:
89 		*s = "DW_AT_byte_size"; break;
90 	case DW_AT_byte_stride:
91 		*s = "DW_AT_byte_stride"; break;
92 	case DW_AT_calling_convention:
93 		*s = "DW_AT_calling_convention"; break;
94 	case DW_AT_call_all_calls:
95 		*s = "DW_AT_call_all_calls"; break;
96 	case DW_AT_call_all_source_calls:
97 		*s = "DW_AT_call_all_source_calls"; break;
98 	case DW_AT_call_all_tail_calls:
99 		*s = "DW_AT_call_all_tail_calls"; break;
100 	case DW_AT_call_data_location:
101 		*s = "DW_AT_call_data_location"; break;
102 	case DW_AT_call_data_value:
103 		*s = "DW_AT_call_data_value"; break;
104 	case DW_AT_call_origin:
105 		*s = "DW_AT_call_origin"; break;
106 	case DW_AT_call_parameter:
107 		*s = "DW_AT_call_parameter"; break;
108 	case DW_AT_call_pc:
109 		*s = "DW_AT_call_pc"; break;
110 	case DW_AT_call_return_pc:
111 		*s = "DW_AT_call_return_pc"; break;
112 	case DW_AT_call_tail_call:
113 		*s = "DW_AT_call_tail_call"; break;
114 	case DW_AT_call_target:
115 		*s = "DW_AT_call_target"; break;
116 	case DW_AT_call_target_clobbered:
117 		*s = "DW_AT_call_target_clobbered"; break;
118 	case DW_AT_call_value:
119 		*s = "DW_AT_call_value"; break;
120 	case DW_AT_common_reference:
121 		*s = "DW_AT_common_reference"; break;
122 	case DW_AT_comp_dir:
123 		*s = "DW_AT_comp_dir"; break;
124 	case DW_AT_const_expr:
125 		*s = "DW_AT_const_expr"; break;
126 	case DW_AT_const_value:
127 		*s = "DW_AT_const_value"; break;
128 	case DW_AT_containing_type:
129 		*s = "DW_AT_containing_type"; break;
130 	case DW_AT_count:
131 		*s = "DW_AT_count"; break;
132 	case DW_AT_call_column:
133 		*s = "DW_AT_call_column"; break;
134 	case DW_AT_call_file:
135 		*s = "DW_AT_call_file"; break;
136 	case DW_AT_call_line:
137 		*s = "DW_AT_call_line"; break;
138 	case DW_AT_data_bit_offset:
139 		*s = "DW_AT_data_bit_offset"; break;
140 	case DW_AT_data_location:
141 		*s = "DW_AT_data_location"; break;
142 	case DW_AT_data_member_location:
143 		*s = "DW_AT_data_member_location"; break;
144 	case DW_AT_decl_column:
145 		*s = "DW_AT_decl_column"; break;
146 	case DW_AT_decl_file:
147 		*s = "DW_AT_decl_file"; break;
148 	case DW_AT_decl_line:
149 		*s = "DW_AT_decl_line"; break;
150 	case DW_AT_declaration:
151 		*s = "DW_AT_declaration"; break;
152 	case DW_AT_default_value:
153 		*s = "DW_AT_default_value"; break;
154 	case DW_AT_decimal_scale:
155 		*s = "DW_AT_decimal_scale"; break;
156 	case DW_AT_decimal_sign:
157 		*s = "DW_AT_decimal_sign"; break;
158 	case DW_AT_defaulted:
159 		*s = "DW_AT_defaulted"; break;
160 	case DW_AT_deleted:
161 		*s = "DW_AT_deleted"; break;
162 	case DW_AT_description:
163 		*s = "DW_AT_description"; break;
164 	case DW_AT_digit_count:
165 		*s = "DW_AT_digit_count"; break;
166 	case DW_AT_discr:
167 		*s = "DW_AT_discr"; break;
168 	case DW_AT_discr_list:
169 		*s = "DW_AT_discr_list"; break;
170 	case DW_AT_discr_value:
171 		*s = "DW_AT_discr_value"; break;
172 	case DW_AT_dwo_name:
173 		*s = "DW_AT_dwo_name"; break;
174 	case DW_AT_element_list:
175 		*s = "DW_AT_element_list"; break;
176 	case DW_AT_encoding:
177 		*s = "DW_AT_encoding"; break;
178 	case DW_AT_enum_class:
179 		*s = "DW_AT_enum_class"; break;
180 	case DW_AT_external:
181 		*s = "DW_AT_external"; break;
182 	case DW_AT_entry_pc:
183 		*s = "DW_AT_entry_pc"; break;
184 	case DW_AT_extension:
185 		*s = "DW_AT_extension"; break;
186 	case DW_AT_explicit:
187 		*s = "DW_AT_explicit"; break;
188 	case DW_AT_export_symbols:
189 		*s = "DW_AT_export_symbols"; break;
190 	case DW_AT_endianity:
191 		*s = "DW_AT_endianity"; break;
192 	case DW_AT_elemental:
193 		*s = "DW_AT_elemental"; break;
194 	case DW_AT_frame_base:
195 		*s = "DW_AT_frame_base"; break;
196 	case DW_AT_friend:
197 		*s = "DW_AT_friend"; break;
198 	case DW_AT_high_pc:
199 		*s = "DW_AT_high_pc"; break;
200 	case DW_AT_hi_user:
201 		*s = "DW_AT_hi_user"; break;
202 	case DW_AT_identifier_case:
203 		*s = "DW_AT_identifier_case"; break;
204 	case DW_AT_import:
205 		*s = "DW_AT_import"; break;
206 	case DW_AT_inline:
207 		*s = "DW_AT_inline"; break;
208 	case DW_AT_is_optional:
209 		*s = "DW_AT_is_optional"; break;
210 	case DW_AT_language:
211 		*s = "DW_AT_language"; break;
212 	case DW_AT_linkage_name:
213 		*s = "DW_AT_linkage_name"; break;
214 	case DW_AT_lo_user:
215 		*s = "DW_AT_lo_user"; break;
216 	case DW_AT_location:
217 		*s = "DW_AT_location"; break;
218 	case DW_AT_loclists_base:
219 		*s = "DW_AT_loclists_base"; break;
220 	case DW_AT_low_pc:
221 		*s = "DW_AT_low_pc"; break;
222 	case DW_AT_lower_bound:
223 		*s = "DW_AT_lower_bound"; break;
224 	case DW_AT_macros:
225 		*s = "DW_AT_macros"; break;
226 	case DW_AT_macro_info:
227 		*s = "DW_AT_macro_info"; break;
228 	case DW_AT_main_subprogram:
229 		*s = "DW_AT_main_subprogram"; break;
230 	case DW_AT_mutable:
231 		*s = "DW_AT_mutable"; break;
232 	case DW_AT_member:
233 		*s = "DW_AT_member"; break;
234 	case DW_AT_name:
235 		*s = "DW_AT_name"; break;
236 	case DW_AT_namelist_item:
237 		*s = "DW_AT_namelist_item"; break;
238 	case DW_AT_noreturn:
239 		*s = "DW_AT_noreturn"; break;
240 	case DW_AT_ordering:
241 		*s = "DW_AT_ordering"; break;
242 	case DW_AT_object_pointer:
243 		*s = "DW_AT_object_pointer"; break;
244 	case DW_AT_priority:
245 		*s = "DW_AT_priority"; break;
246 	case DW_AT_producer:
247 		*s = "DW_AT_producer"; break;
248 	case DW_AT_prototyped:
249 		*s = "DW_AT_prototyped"; break;
250 	case DW_AT_picture_string:
251 		*s = "DW_AT_picture_string"; break;
252 	case DW_AT_pure:
253 		*s = "DW_AT_pure"; break;
254 	case DW_AT_reference:
255 		*s = "DW_AT_reference"; break;
256 	case DW_AT_return_addr:
257 		*s = "DW_AT_return_addr"; break;
258 	case DW_AT_ranges:
259 		*s = "DW_AT_ranges"; break;
260 	case DW_AT_rank:
261 		*s = "DW_AT_rank"; break;
262 	case DW_AT_recursive:
263 		*s = "DW_AT_recursive"; break;
264 	case DW_AT_rnglists_base:
265 		*s = "DW_AT_rnglists_base"; break;
266 	case DW_AT_rvalue_reference:
267 		*s = "DW_AT_rvalue_reference"; break;
268 	case DW_AT_segment:
269 		*s = "DW_AT_segment"; break;
270 	case DW_AT_sibling:
271 		*s = "DW_AT_sibling"; break;
272 	case DW_AT_signature:
273 		*s = "DW_AT_signature"; break;
274 	case DW_AT_specification:
275 		*s = "DW_AT_specification"; break;
276 	case DW_AT_start_scope:
277 		*s = "DW_AT_start_scope"; break;
278 	case DW_AT_static_link:
279 		*s = "DW_AT_static_link"; break;
280 	case DW_AT_stmt_list:
281 		*s = "DW_AT_stmt_list"; break;
282 	case DW_AT_string_length:
283 		*s = "DW_AT_string_length"; break;
284 	case DW_AT_string_length_bit_size:
285 		*s = "DW_AT_string_length_bit_size"; break;
286 	case DW_AT_string_length_byte_size:
287 		*s = "DW_AT_string_length_byte_size"; break;
288 	case DW_AT_str_offsets_base:
289 		*s = "DW_AT_str_offsets_base"; break;
290 	case DW_AT_subscr_data:
291 		*s = "DW_AT_subscr_data"; break;
292 	case DW_AT_small:
293 		*s = "DW_AT_small"; break;
294 	case DW_AT_type:
295 		*s = "DW_AT_type"; break;
296 	case DW_AT_trampoline:
297 		*s = "DW_AT_trampoline"; break;
298 	case DW_AT_threads_scaled:
299 		*s = "DW_AT_threads_scaled"; break;
300 	case DW_AT_upper_bound:
301 		*s = "DW_AT_upper_bound"; break;
302 	case DW_AT_use_location:
303 		*s = "DW_AT_use_location"; break;
304 	case DW_AT_use_UTF8:
305 		*s = "DW_AT_use_UTF8"; break;
306 	case DW_AT_variable_parameter:
307 		*s = "DW_AT_variable_parameter"; break;
308 	case DW_AT_virtuality:
309 		*s = "DW_AT_virtuality"; break;
310 	case DW_AT_visibility:
311 		*s = "DW_AT_visibility"; break;
312 	case DW_AT_vtable_elem_location:
313 		*s = "DW_AT_vtable_elem_location"; break;
314 	case DW_AT_sf_names:
315 		*s = "DW_AT_sf_names"; break;
316 	case DW_AT_src_info:
317 		*s = "DW_AT_src_info"; break;
318 	case DW_AT_mac_info:
319 		*s = "DW_AT_mac_info"; break;
320 	case DW_AT_src_coords:
321 		*s = "DW_AT_src_coords"; break;
322 	case DW_AT_body_begin:
323 		*s = "DW_AT_body_begin"; break;
324 	case DW_AT_body_end:
325 		*s = "DW_AT_body_end"; break;
326 	case DW_AT_MIPS_fde:
327 		*s = "DW_AT_MIPS_fde"; break;
328 	case DW_AT_MIPS_loop_begin:
329 		*s = "DW_AT_MIPS_loop_begin"; break;
330 	case DW_AT_MIPS_tail_loop_begin:
331 		*s = "DW_AT_MIPS_tail_loop_begin"; break;
332 	case DW_AT_MIPS_epilog_begin:
333 		*s = "DW_AT_MIPS_epilog_begin"; break;
334 	case DW_AT_MIPS_loop_unroll_factor:
335 		*s = "DW_AT_MIPS_loop_unroll_factor"; break;
336 	case DW_AT_MIPS_software_pipeline_depth:
337 		*s = "DW_AT_MIPS_software_pipeline_depth"; break;
338 	case DW_AT_MIPS_linkage_name:
339 		*s = "DW_AT_MIPS_linkage_name"; break;
340 	case DW_AT_MIPS_stride:
341 		*s = "DW_AT_MIPS_stride"; break;
342 	case DW_AT_MIPS_abstract_name:
343 		*s = "DW_AT_MIPS_abstract_name"; break;
344 	case DW_AT_MIPS_clone_origin:
345 		*s = "DW_AT_MIPS_clone_origin"; break;
346 	case DW_AT_MIPS_has_inlines:
347 		*s = "DW_AT_MIPS_has_inlines"; break;
348 	case DW_AT_MIPS_stride_byte:
349 		*s = "DW_AT_MIPS_stride_byte"; break;
350 	case DW_AT_MIPS_stride_elem:
351 		*s = "DW_AT_MIPS_stride_elem"; break;
352 	case DW_AT_MIPS_ptr_dopetype:
353 		*s = "DW_AT_MIPS_ptr_dopetype"; break;
354 	case DW_AT_MIPS_allocatable_dopetype:
355 		*s = "DW_AT_MIPS_allocatable_dopetype"; break;
356 	case DW_AT_MIPS_assumed_shape_dopetype:
357 		*s = "DW_AT_MIPS_assumed_shape_dopetype"; break;
358 	case DW_AT_MIPS_assumed_size:
359 		*s = "DW_AT_MIPS_assumed_size"; break;
360 	case DW_AT_GNU_vector:
361 		*s = "DW_AT_GNU_vector"; break;
362 	case DW_AT_GNU_guarded_by:
363 		*s = "DW_AT_GNU_guarded_by"; break;
364 	case DW_AT_GNU_pt_guarded_by:
365 		*s = "DW_AT_GNU_pt_guarded_by"; break;
366 	case DW_AT_GNU_guarded:
367 		*s = "DW_AT_GNU_guarded"; break;
368 	case DW_AT_GNU_pt_guarded:
369 		*s = "DW_AT_GNU_pt_guarded"; break;
370 	case DW_AT_GNU_locks_excluded:
371 		*s = "DW_AT_GNU_locks_excluded"; break;
372 	case DW_AT_GNU_exclusive_locks_required:
373 		*s = "DW_AT_GNU_exclusive_locks_required"; break;
374 	case DW_AT_GNU_shared_locks_required:
375 		*s = "DW_AT_GNU_shared_locks_required"; break;
376 	case DW_AT_GNU_odr_signature:
377 		*s = "DW_AT_GNU_odr_signature"; break;
378 	case DW_AT_GNU_template_name:
379 		*s = "DW_AT_GNU_template_name"; break;
380 	case DW_AT_GNU_call_site_value:
381 		*s = "DW_AT_GNU_call_site_value"; break;
382 	case DW_AT_GNU_call_site_data_value:
383 		*s = "DW_AT_GNU_call_site_data_value"; break;
384 	case DW_AT_GNU_call_site_target:
385 		*s = "DW_AT_GNU_call_site_target"; break;
386 	case DW_AT_GNU_call_site_target_clobbered:
387 		*s = "DW_AT_GNU_call_site_target_clobbered"; break;
388 	case DW_AT_GNU_tail_call:
389 		*s = "DW_AT_GNU_tail_call"; break;
390 	case DW_AT_GNU_all_tail_call_sites:
391 		*s = "DW_AT_GNU_all_tail_call_sites"; break;
392 	case DW_AT_GNU_all_call_sites:
393 		*s = "DW_AT_GNU_all_call_sites"; break;
394 	case DW_AT_GNU_all_source_call_sites:
395 		*s = "DW_AT_GNU_all_source_call_sites"; break;
396 	case DW_AT_APPLE_optimized:
397 		*s = "DW_AT_APPLE_optimized"; break;
398 	case DW_AT_APPLE_flags:
399 		*s = "DW_AT_APPLE_flags"; break;
400 	case DW_AT_APPLE_isa:
401 		*s = "DW_AT_APPLE_isa"; break;
402 	case DW_AT_APPLE_block:
403 		*s = "DW_AT_APPLE_block"; break;
404 	case DW_AT_APPLE_major_runtime_vers:
405 		*s = "DW_AT_APPLE_major_runtime_vers"; break;
406 	case DW_AT_APPLE_runtime_class:
407 		*s = "DW_AT_APPLE_runtime_class"; break;
408 	case DW_AT_APPLE_omit_frame_ptr:
409 		*s = "DW_AT_APPLE_omit_frame_ptr"; break;
410 	case DW_AT_APPLE_property_name:
411 		*s = "DW_AT_APPLE_property_name"; break;
412 	case DW_AT_APPLE_property_getter:
413 		*s = "DW_AT_APPLE_property_getter"; break;
414 	case DW_AT_APPLE_property_setter:
415 		*s = "DW_AT_APPLE_property_setter"; break;
416 	case DW_AT_APPLE_property_attribute:
417 		*s = "DW_AT_APPLE_property_attribute"; break;
418 	case DW_AT_APPLE_objc_complete_type:
419 		*s = "DW_AT_APPLE_objc_complete_type"; break;
420 	case DW_AT_APPLE_property:
421 		*s = "DW_AT_APPLE_property"; break;
422 	default:
423 		return (DW_DLV_NO_ENTRY);
424 	}
425 
426 	return (DW_DLV_OK);
427 }
428 
429 int
dwarf_get_ATE_name(unsigned ate,const char ** s)430 dwarf_get_ATE_name(unsigned ate, const char **s)
431 {
432 
433 	assert(s != NULL);
434 
435 	switch(ate) {
436 	case DW_ATE_address:
437 		*s = "DW_ATE_address"; break;
438 	case DW_ATE_boolean:
439 		*s = "DW_ATE_boolean"; break;
440 	case DW_ATE_complex_float:
441 		*s = "DW_ATE_complex_float"; break;
442 	case DW_ATE_float:
443 		*s = "DW_ATE_float"; break;
444 	case DW_ATE_signed:
445 		*s = "DW_ATE_signed"; break;
446 	case DW_ATE_signed_char:
447 		*s = "DW_ATE_signed_char"; break;
448 	case DW_ATE_unsigned:
449 		*s = "DW_ATE_unsigned"; break;
450 	case DW_ATE_unsigned_char:
451 		*s = "DW_ATE_unsigned_char"; break;
452 	case DW_ATE_imaginary_float:
453 		*s = "DW_ATE_imaginary_float"; break;
454 	case DW_ATE_packed_decimal:
455 		*s = "DW_ATE_packed_decimal"; break;
456 	case DW_ATE_numeric_string:
457 		*s = "DW_ATE_numeric_string"; break;
458 	case DW_ATE_edited:
459 		*s = "DW_ATE_edited"; break;
460 	case DW_ATE_signed_fixed:
461 		*s = "DW_ATE_signed_fixed"; break;
462 	case DW_ATE_unsigned_fixed:
463 		*s = "DW_ATE_unsigned_fixed"; break;
464 	case DW_ATE_decimal_float:
465 		*s = "DW_ATE_decimal_float"; break;
466 	case DW_ATE_lo_user:
467 		*s = "DW_ATE_lo_user"; break;
468 	case DW_ATE_hi_user:
469 		*s = "DW_ATE_hi_user"; break;
470 	default:
471 		return (DW_DLV_NO_ENTRY);
472 	}
473 
474 	return (DW_DLV_OK);
475 }
476 
477 int
dwarf_get_CC_name(unsigned cc,const char ** s)478 dwarf_get_CC_name(unsigned cc, const char **s)
479 {
480 
481 	assert(s != NULL);
482 
483 	switch (cc) {
484 	case DW_CC_normal:
485 		*s = "DW_CC_normal"; break;
486 	case DW_CC_program:
487 		*s = "DW_CC_program"; break;
488 	case DW_CC_nocall:
489 		*s = "DW_CC_nocall"; break;
490 	case DW_CC_lo_user:
491 		*s = "DW_CC_lo_user"; break;
492 	case DW_CC_hi_user:
493 		*s = "DW_CC_hi_user"; break;
494 	default:
495 		return (DW_DLV_NO_ENTRY);
496 	}
497 
498 	return (DW_DLV_OK);
499 }
500 
501 int
dwarf_get_CFA_name(unsigned cfa,const char ** s)502 dwarf_get_CFA_name(unsigned cfa, const char **s)
503 {
504 
505 	assert(s != NULL);
506 
507 	switch (cfa) {
508 	case DW_CFA_advance_loc:
509 		*s = "DW_CFA_advance_loc"; break;
510 	case DW_CFA_offset:
511 		*s = "DW_CFA_offset"; break;
512 	case DW_CFA_restore:
513 		*s = "DW_CFA_restore"; break;
514 	case DW_CFA_nop:
515 		*s = "DW_CFA_nop"; break;
516 	case DW_CFA_set_loc:
517 		*s = "DW_CFA_set_loc"; break;
518 	case DW_CFA_advance_loc1:
519 		*s = "DW_CFA_advance_loc1"; break;
520 	case DW_CFA_advance_loc2:
521 		*s = "DW_CFA_advance_loc2"; break;
522 	case DW_CFA_advance_loc4:
523 		*s = "DW_CFA_advance_loc4"; break;
524 	case DW_CFA_offset_extended:
525 		*s = "DW_CFA_offset_extended"; break;
526 	case DW_CFA_restore_extended:
527 		*s = "DW_CFA_restore_extended"; break;
528 	case DW_CFA_undefined:
529 		*s = "DW_CFA_undefined"; break;
530 	case DW_CFA_same_value:
531 		*s = "DW_CFA_same_value"; break;
532 	case DW_CFA_register:
533 		*s = "DW_CFA_register"; break;
534 	case DW_CFA_remember_state:
535 		*s = "DW_CFA_remember_state"; break;
536 	case DW_CFA_restore_state:
537 		*s = "DW_CFA_restore_state"; break;
538 	case DW_CFA_def_cfa:
539 		*s = "DW_CFA_def_cfa"; break;
540 	case DW_CFA_def_cfa_register:
541 		*s = "DW_CFA_def_cfa_register"; break;
542 	case DW_CFA_def_cfa_offset:
543 		*s = "DW_CFA_def_cfa_offset"; break;
544 	case DW_CFA_def_cfa_expression:
545 		*s = "DW_CFA_def_cfa_expression"; break;
546 	case DW_CFA_expression:
547 		*s = "DW_CFA_expression"; break;
548 	case DW_CFA_offset_extended_sf:
549 		*s = "DW_CFA_offset_extended_sf"; break;
550 	case DW_CFA_def_cfa_sf:
551 		*s = "DW_CFA_def_cfa_sf"; break;
552 	case DW_CFA_def_cfa_offset_sf:
553 		*s = "DW_CFA_def_cfa_offset_sf"; break;
554 	case DW_CFA_val_offset:
555 		*s = "DW_CFA_val_offset"; break;
556 	case DW_CFA_val_offset_sf:
557 		*s = "DW_CFA_val_offset_sf"; break;
558 	case DW_CFA_val_expression:
559 		*s = "DW_CFA_val_expression"; break;
560 	case DW_CFA_lo_user:
561 		*s = "DW_CFA_lo_user"; break;
562 	case DW_CFA_high_user:
563 		*s = "DW_CFA_high_user"; break;
564 	default:
565 		return (DW_DLV_NO_ENTRY);
566 	}
567 
568 	return (DW_DLV_OK);
569 }
570 
571 int
dwarf_get_CHILDREN_name(unsigned children,const char ** s)572 dwarf_get_CHILDREN_name(unsigned children, const char **s)
573 {
574 
575 	assert(s != NULL);
576 
577 	switch (children) {
578 	case DW_CHILDREN_no:
579 		*s = "DW_CHILDREN_no"; break;
580 	case DW_CHILDREN_yes:
581 		*s = "DW_CHILDREN_yes"; break;
582 	default:
583 		return (DW_DLV_NO_ENTRY);
584 	}
585 
586 	return (DW_DLV_OK);
587 }
588 
589 int
dwarf_get_FORM_name(unsigned form,const char ** s)590 dwarf_get_FORM_name(unsigned form, const char **s)
591 {
592 
593 	assert(s != NULL);
594 
595 	switch (form) {
596 	case DW_FORM_addr:
597 		*s = "DW_FORM_addr"; break;
598 	case DW_FORM_addrx:
599 		*s = "DW_FORM_addrx"; break;
600 	case DW_FORM_addrx1:
601 		*s = "DW_FORM_addrx1"; break;
602 	case DW_FORM_addrx2:
603 		*s = "DW_FORM_addrx2"; break;
604 	case DW_FORM_addrx3:
605 		*s = "DW_FORM_addrx3"; break;
606 	case DW_FORM_addrx4:
607 		*s = "DW_FORM_addrx4"; break;
608 	case DW_FORM_block:
609 		*s = "DW_FORM_block"; break;
610 	case DW_FORM_block1:
611 		*s = "DW_FORM_block1"; break;
612 	case DW_FORM_block2:
613 		*s = "DW_FORM_block2"; break;
614 	case DW_FORM_block4:
615 		*s = "DW_FORM_block4"; break;
616 	case DW_FORM_data1:
617 		*s = "DW_FORM_data1"; break;
618 	case DW_FORM_data2:
619 		*s = "DW_FORM_data2"; break;
620 	case DW_FORM_data4:
621 		*s = "DW_FORM_data4"; break;
622 	case DW_FORM_data8:
623 		*s = "DW_FORM_data8"; break;
624 	case DW_FORM_data16:
625 		*s = "DW_FORM_data16"; break;
626 	case DW_FORM_exprloc:
627 		*s = "DW_FORM_exprloc"; break;
628 	case DW_FORM_flag:
629 		*s = "DW_FORM_flag"; break;
630 	case DW_FORM_flag_present:
631 		*s = "DW_FORM_flag_present"; break;
632 	case DW_FORM_implicit_const:
633 		*s = "DW_FORM_implicit_const"; break;
634 	case DW_FORM_indirect:
635 		*s = "DW_FORM_indirect"; break;
636 	case DW_FORM_line_strp:
637 		*s = "DW_FORM_line_strp"; break;
638 	case DW_FORM_loclistx:
639 		*s = "DW_FORM_loclistx"; break;
640 	case DW_FORM_ref1:
641 		*s = "DW_FORM_ref1"; break;
642 	case DW_FORM_ref2:
643 		*s = "DW_FORM_ref2"; break;
644 	case DW_FORM_ref4:
645 		*s = "DW_FORM_ref4"; break;
646 	case DW_FORM_ref8:
647 		*s = "DW_FORM_ref8"; break;
648 	case DW_FORM_ref_addr:
649 		*s = "DW_FORM_ref_addr"; break;
650 	case DW_FORM_ref_sig8:
651 		*s = "DW_FORM_ref_sig8"; break;
652 	case DW_FORM_ref_sup4:
653 		*s = "DW_FORM_ref_sup4"; break;
654 	case DW_FORM_ref_sup8:
655 		*s = "DW_FORM_ref_sup8"; break;
656 	case DW_FORM_ref_udata:
657 		*s = "DW_FORM_ref_udata"; break;
658 	case DW_FORM_rnglistx:
659 		*s = "DW_FORM_rnglistx"; break;
660 	case DW_FORM_sdata:
661 		*s = "DW_FORM_sdata"; break;
662 	case DW_FORM_sec_offset:
663 		*s = "DW_FORM_sec_offset"; break;
664 	case DW_FORM_string:
665 		*s = "DW_FORM_string"; break;
666 	case DW_FORM_strp:
667 		*s = "DW_FORM_strp"; break;
668 	case DW_FORM_strp_sup:
669 		*s = "DW_FORM_strp_sup"; break;
670 	case DW_FORM_strx:
671 		*s = "DW_FORM_strx"; break;
672 	case DW_FORM_strx1:
673 		*s = "DW_FORM_strx1"; break;
674 	case DW_FORM_strx2:
675 		*s = "DW_FORM_strx2"; break;
676 	case DW_FORM_strx3:
677 		*s = "DW_FORM_strx3"; break;
678 	case DW_FORM_strx4:
679 		*s = "DW_FORM_strx4"; break;
680 	case DW_FORM_udata:
681 		*s = "DW_FORM_udata"; break;
682 	default:
683 		return (DW_DLV_NO_ENTRY);
684 	}
685 
686 	return (DW_DLV_OK);
687 }
688 
689 int
dwarf_get_DS_name(unsigned ds,const char ** s)690 dwarf_get_DS_name(unsigned ds, const char **s)
691 {
692 
693 	assert(s != NULL);
694 
695 	switch (ds) {
696 	case DW_DS_unsigned:
697 		*s = "DW_DS_unsigned"; break;
698 	case DW_DS_leading_overpunch:
699 		*s = "DW_DS_leading_overpunch"; break;
700 	case DW_DS_trailing_overpunch:
701 		*s = "DW_DS_trailing_overpunch"; break;
702 	case DW_DS_leading_separate:
703 		*s = "DW_DS_leading_separate"; break;
704 	case DW_DS_trailing_separate:
705 		*s = "DW_DS_trailing_separate"; break;
706 	default:
707 		return (DW_DLV_NO_ENTRY);
708 	}
709 
710 	return (DW_DLV_OK);
711 }
712 
713 int
dwarf_get_DSC_name(unsigned dsc,const char ** s)714 dwarf_get_DSC_name(unsigned dsc, const char **s)
715 {
716 
717 	assert(s != NULL);
718 
719 	switch (dsc) {
720 	case DW_DSC_label:
721 		*s = "DW_DSC_label"; break;
722 	case DW_DSC_range:
723 		*s = "DW_DSC_range"; break;
724 	default:
725 		return (DW_DLV_NO_ENTRY);
726 	}
727 
728 	return (DW_DLV_OK);
729 }
730 
731 int
dwarf_get_EH_name(unsigned eh,const char ** s)732 dwarf_get_EH_name(unsigned eh, const char **s)
733 {
734 
735 	assert(s != NULL);
736 
737 	switch (eh) {
738 	case DW_EH_PE_absptr:
739 		*s = "DW_EH_PE_absptr"; break;
740 	case DW_EH_PE_uleb128:
741 		*s = "DW_EH_PE_uleb128"; break;
742 	case DW_EH_PE_udata2:
743 		*s = "DW_EH_PE_udata2"; break;
744 	case DW_EH_PE_udata4:
745 		*s = "DW_EH_PE_udata4"; break;
746 	case DW_EH_PE_udata8:
747 		*s = "DW_EH_PE_udata8"; break;
748 	case DW_EH_PE_sleb128:
749 		*s = "DW_EH_PE_sleb128"; break;
750 	case DW_EH_PE_sdata2:
751 		*s = "DW_EH_PE_sdata2"; break;
752 	case DW_EH_PE_sdata4:
753 		*s = "DW_EH_PE_sdata4"; break;
754 	case DW_EH_PE_sdata8:
755 		*s = "DW_EH_PE_sdata8"; break;
756 	case DW_EH_PE_pcrel:
757 		*s = "DW_EH_PE_pcrel"; break;
758 	case DW_EH_PE_textrel:
759 		*s = "DW_EH_PE_textrel"; break;
760 	case DW_EH_PE_datarel:
761 		*s = "DW_EH_PE_datarel"; break;
762 	case DW_EH_PE_funcrel:
763 		*s = "DW_EH_PE_funcrel"; break;
764 	case DW_EH_PE_aligned:
765 		*s = "DW_EH_PE_aligned"; break;
766 	case DW_EH_PE_omit:
767 		*s = "DW_EH_PE_omit"; break;
768 	default:
769 		return (DW_DLV_NO_ENTRY);
770 	}
771 
772 	return (DW_DLV_OK);
773 }
774 
775 int
dwarf_get_END_name(unsigned end,const char ** s)776 dwarf_get_END_name(unsigned end, const char **s)
777 {
778 
779 	assert(s != NULL);
780 
781 	switch (end) {
782 	case DW_END_default:
783 		*s = "DW_END_default"; break;
784 	case DW_END_big:
785 		*s = "DW_END_big"; break;
786 	case DW_END_little:
787 		*s = "DW_END_little"; break;
788 	case DW_END_lo_user:
789 		*s = "DW_END_lo_user"; break;
790 	case DW_END_high_user:
791 		*s = "DW_END_high_user"; break;
792 	default:
793 		return (DW_DLV_NO_ENTRY);
794 	}
795 
796 	return (DW_DLV_OK);
797 }
798 
799 int
dwarf_get_ID_name(unsigned id,const char ** s)800 dwarf_get_ID_name(unsigned id, const char **s)
801 {
802 
803 	assert(s != NULL);
804 
805 	switch (id) {
806 	case DW_ID_case_sensitive:
807 		*s = "DW_ID_case_sensitive"; break;
808 	case DW_ID_up_case:
809 		*s = "DW_ID_up_case"; break;
810 	case DW_ID_down_case:
811 		*s = "DW_ID_down_case"; break;
812 	case DW_ID_case_insensitive:
813 		*s = "DW_ID_case_insensitive"; break;
814 	default:
815 		return (DW_DLV_NO_ENTRY);
816 	}
817 
818 	return (DW_DLV_OK);
819 }
820 
821 int
dwarf_get_INL_name(unsigned inl,const char ** s)822 dwarf_get_INL_name(unsigned inl, const char **s)
823 {
824 
825 	assert(s != NULL);
826 
827 	switch (inl) {
828 	case DW_INL_not_inlined:
829 		*s = "DW_INL_not_inlined"; break;
830 	case DW_INL_inlined:
831 		*s = "DW_INL_inlined"; break;
832 	case DW_INL_declared_not_inlined:
833 		*s = "DW_INL_declared_not_inlined"; break;
834 	case DW_INL_declared_inlined:
835 		*s = "DW_INL_declared_inlined"; break;
836 	default:
837 		return (DW_DLV_NO_ENTRY);
838 	}
839 
840 	return (DW_DLV_OK);
841 }
842 
843 int
dwarf_get_LANG_name(unsigned lang,const char ** s)844 dwarf_get_LANG_name(unsigned lang, const char **s)
845 {
846 
847 	assert(s != NULL);
848 
849 	switch (lang) {
850 	case DW_LANG_C89:
851 		*s = "DW_LANG_C89"; break;
852 	case DW_LANG_C:
853 		*s = "DW_LANG_C"; break;
854 	case DW_LANG_Ada83:
855 		*s = "DW_LANG_Ada83"; break;
856 	case DW_LANG_C_plus_plus:
857 		*s = "DW_LANG_C_plus_plus"; break;
858 	case DW_LANG_Cobol74:
859 		*s = "DW_LANG_Cobol74"; break;
860 	case DW_LANG_Cobol85:
861 		*s = "DW_LANG_Cobol85"; break;
862 	case DW_LANG_Fortran77:
863 		*s = "DW_LANG_Fortran77"; break;
864 	case DW_LANG_Fortran90:
865 		*s = "DW_LANG_Fortran90"; break;
866 	case DW_LANG_Pascal83:
867 		*s = "DW_LANG_Pascal83"; break;
868 	case DW_LANG_Modula2:
869 		*s = "DW_LANG_Modula2"; break;
870 	case DW_LANG_Java:
871 		*s = "DW_LANG_Java"; break;
872 	case DW_LANG_C99:
873 		*s = "DW_LANG_C99"; break;
874 	case DW_LANG_Ada95:
875 		*s = "DW_LANG_Ada95"; break;
876 	case DW_LANG_Fortran95:
877 		*s = "DW_LANG_Fortran95"; break;
878 	case DW_LANG_PLI:
879 		*s = "DW_LANG_PLI"; break;
880 	case DW_LANG_ObjC:
881 		*s = "DW_LANG_ObjC"; break;
882 	case DW_LANG_ObjC_plus_plus:
883 		*s = "DW_LANG_ObjC_plus_plus"; break;
884 	case DW_LANG_UPC:
885 		*s = "DW_LANG_UPC"; break;
886 	case DW_LANG_D:
887 		*s = "DW_LANG_D"; break;
888 	case DW_LANG_Python:
889 		*s = "DW_LANG_Python"; break;
890 	case DW_LANG_OpenCL:
891 		*s = "DW_LANG_OpenCL"; break;
892 	case DW_LANG_Go:
893 		*s = "DW_LANG_Go"; break;
894 	case DW_LANG_Modula3:
895 		*s = "DW_LANG_Modula3"; break;
896 	case DW_LANG_Haskell:
897 		*s = "DW_LANG_Haskell"; break;
898 	case DW_LANG_C_plus_plus_03:
899 		*s = "DW_LANG_C_plus_plus_03"; break;
900 	case DW_LANG_C_plus_plus_11:
901 		*s = "DW_LANG_C_plus_plus_11"; break;
902 	case DW_LANG_OCaml:
903 		*s = "DW_LANG_OCaml"; break;
904 	case DW_LANG_Rust:
905 		*s = "DW_LANG_Rust"; break;
906 	case DW_LANG_C11:
907 		*s = "DW_LANG_C11"; break;
908 	case DW_LANG_Swift:
909 		*s = "DW_LANG_Swift"; break;
910 	case DW_LANG_Julia:
911 		*s = "DW_LANG_Julia"; break;
912 	case DW_LANG_Dylan:
913 		*s = "DW_LANG_Dylan"; break;
914 	case DW_LANG_C_plus_plus_14:
915 		*s = "DW_LANG_C_plus_plus_14"; break;
916 	case DW_LANG_Fortran03:
917 		*s = "DW_LANG_Fortran03"; break;
918 	case DW_LANG_Fortran08:
919 		*s = "DW_LANG_Fortran08"; break;
920 	case DW_LANG_RenderScript:
921 		*s = "DW_LANG_RenderScript"; break;
922 	case DW_LANG_BLISS:
923 		*s = "DW_LANG_BLISS"; break;
924 	case DW_LANG_lo_user:
925 		*s = "DW_LANG_lo_user"; break;
926 	case DW_LANG_Mips_Assembler:
927 		*s = "DW_LANG_Mips_Assembler"; break;
928 	case DW_LANG_hi_user:
929 		*s = "DW_LANG_hi_user"; break;
930 	default:
931 		return (DW_DLV_NO_ENTRY);
932 	}
933 
934 	return (DW_DLV_OK);
935 }
936 
937 int
dwarf_get_LNE_name(unsigned lne,const char ** s)938 dwarf_get_LNE_name(unsigned lne, const char **s)
939 {
940 
941 	assert(s != NULL);
942 
943 	switch (lne) {
944 	case DW_LNE_end_sequence:
945 		*s = "DW_LNE_end_sequence"; break;
946 	case DW_LNE_set_address:
947 		*s = "DW_LNE_set_address"; break;
948 	case DW_LNE_define_file:
949 		*s = "DW_LNE_define_file"; break;
950 	case DW_LNE_lo_user:
951 		*s = "DW_LNE_lo_user"; break;
952 	case DW_LNE_hi_user:
953 		*s = "DW_LNE_hi_user"; break;
954 	default:
955 		return (DW_DLV_NO_ENTRY);
956 	}
957 
958 	return (DW_DLV_OK);
959 }
960 
961 int
dwarf_get_LNS_name(unsigned lns,const char ** s)962 dwarf_get_LNS_name(unsigned lns, const char **s)
963 {
964 
965 	assert(s != NULL);
966 
967 	switch (lns) {
968 	case DW_LNS_copy:
969 		*s = "DW_LNS_copy"; break;
970 	case DW_LNS_advance_pc:
971 		*s = "DW_LNS_advance_pc"; break;
972 	case DW_LNS_advance_line:
973 		*s = "DW_LNS_advance_line"; break;
974 	case DW_LNS_set_file:
975 		*s = "DW_LNS_set_file"; break;
976 	case DW_LNS_set_column:
977 		*s = "DW_LNS_set_column"; break;
978 	case DW_LNS_negate_stmt:
979 		*s = "DW_LNS_negate_stmt"; break;
980 	case DW_LNS_set_basic_block:
981 		*s = "DW_LNS_set_basic_block"; break;
982 	case DW_LNS_const_add_pc:
983 		*s = "DW_LNS_const_add_pc"; break;
984 	case DW_LNS_fixed_advance_pc:
985 		*s = "DW_LNS_fixed_advance_pc"; break;
986 	case DW_LNS_set_prologue_end:
987 		*s = "DW_LNS_set_prologue_end"; break;
988 	case DW_LNS_set_epilogue_begin:
989 		*s = "DW_LNS_set_epilogue_begin"; break;
990 	case DW_LNS_set_isa:
991 		*s = "DW_LNS_set_isa"; break;
992 	default:
993 		return (DW_DLV_NO_ENTRY);
994 	}
995 
996 	return (DW_DLV_OK);
997 }
998 
999 int
dwarf_get_MACINFO_name(unsigned mi,const char ** s)1000 dwarf_get_MACINFO_name(unsigned mi, const char **s)
1001 {
1002 
1003 	assert(s != NULL);
1004 
1005 	switch (mi) {
1006 	case DW_MACINFO_define:
1007 		*s = "DW_MACINFO_define"; break;
1008 	case DW_MACINFO_undef:
1009 		*s = "DW_MACINFO_undef"; break;
1010 	case DW_MACINFO_start_file:
1011 		*s = "DW_MACINFO_start_file"; break;
1012 	case DW_MACINFO_end_file:
1013 		*s = "DW_MACINFO_end_file"; break;
1014 	case DW_MACINFO_vendor_ext:
1015 		*s = "DW_MACINFO_vendor_ext"; break;
1016 	default:
1017 		return (DW_DLV_NO_ENTRY);
1018 	}
1019 
1020 	return (DW_DLV_OK);
1021 }
1022 
1023 int
dwarf_get_OP_name(unsigned op,const char ** s)1024 dwarf_get_OP_name(unsigned op, const char **s)
1025 {
1026 
1027 	assert(s != NULL);
1028 
1029 	switch (op) {
1030 	case DW_OP_deref:
1031 		*s = "DW_OP_deref"; break;
1032 	case DW_OP_reg0:
1033 		*s = "DW_OP_reg0"; break;
1034 	case DW_OP_reg1:
1035 		*s = "DW_OP_reg1"; break;
1036 	case DW_OP_reg2:
1037 		*s = "DW_OP_reg2"; break;
1038 	case DW_OP_reg3:
1039 		*s = "DW_OP_reg3"; break;
1040 	case DW_OP_reg4:
1041 		*s = "DW_OP_reg4"; break;
1042 	case DW_OP_reg5:
1043 		*s = "DW_OP_reg5"; break;
1044 	case DW_OP_reg6:
1045 		*s = "DW_OP_reg6"; break;
1046 	case DW_OP_reg7:
1047 		*s = "DW_OP_reg7"; break;
1048 	case DW_OP_reg8:
1049 		*s = "DW_OP_reg8"; break;
1050 	case DW_OP_reg9:
1051 		*s = "DW_OP_reg9"; break;
1052 	case DW_OP_reg10:
1053 		*s = "DW_OP_reg10"; break;
1054 	case DW_OP_reg11:
1055 		*s = "DW_OP_reg11"; break;
1056 	case DW_OP_reg12:
1057 		*s = "DW_OP_reg12"; break;
1058 	case DW_OP_reg13:
1059 		*s = "DW_OP_reg13"; break;
1060 	case DW_OP_reg14:
1061 		*s = "DW_OP_reg14"; break;
1062 	case DW_OP_reg15:
1063 		*s = "DW_OP_reg15"; break;
1064 	case DW_OP_reg16:
1065 		*s = "DW_OP_reg16"; break;
1066 	case DW_OP_reg17:
1067 		*s = "DW_OP_reg17"; break;
1068 	case DW_OP_reg18:
1069 		*s = "DW_OP_reg18"; break;
1070 	case DW_OP_reg19:
1071 		*s = "DW_OP_reg19"; break;
1072 	case DW_OP_reg20:
1073 		*s = "DW_OP_reg20"; break;
1074 	case DW_OP_reg21:
1075 		*s = "DW_OP_reg21"; break;
1076 	case DW_OP_reg22:
1077 		*s = "DW_OP_reg22"; break;
1078 	case DW_OP_reg23:
1079 		*s = "DW_OP_reg23"; break;
1080 	case DW_OP_reg24:
1081 		*s = "DW_OP_reg24"; break;
1082 	case DW_OP_reg25:
1083 		*s = "DW_OP_reg25"; break;
1084 	case DW_OP_reg26:
1085 		*s = "DW_OP_reg26"; break;
1086 	case DW_OP_reg27:
1087 		*s = "DW_OP_reg27"; break;
1088 	case DW_OP_reg28:
1089 		*s = "DW_OP_reg28"; break;
1090 	case DW_OP_reg29:
1091 		*s = "DW_OP_reg29"; break;
1092 	case DW_OP_reg30:
1093 		*s = "DW_OP_reg30"; break;
1094 	case DW_OP_reg31:
1095 		*s = "DW_OP_reg31"; break;
1096 	case DW_OP_lit0:
1097 		*s = "DW_OP_lit0"; break;
1098 	case DW_OP_lit1:
1099 		*s = "DW_OP_lit1"; break;
1100 	case DW_OP_lit2:
1101 		*s = "DW_OP_lit2"; break;
1102 	case DW_OP_lit3:
1103 		*s = "DW_OP_lit3"; break;
1104 	case DW_OP_lit4:
1105 		*s = "DW_OP_lit4"; break;
1106 	case DW_OP_lit5:
1107 		*s = "DW_OP_lit5"; break;
1108 	case DW_OP_lit6:
1109 		*s = "DW_OP_lit6"; break;
1110 	case DW_OP_lit7:
1111 		*s = "DW_OP_lit7"; break;
1112 	case DW_OP_lit8:
1113 		*s = "DW_OP_lit8"; break;
1114 	case DW_OP_lit9:
1115 		*s = "DW_OP_lit9"; break;
1116 	case DW_OP_lit10:
1117 		*s = "DW_OP_lit10"; break;
1118 	case DW_OP_lit11:
1119 		*s = "DW_OP_lit11"; break;
1120 	case DW_OP_lit12:
1121 		*s = "DW_OP_lit12"; break;
1122 	case DW_OP_lit13:
1123 		*s = "DW_OP_lit13"; break;
1124 	case DW_OP_lit14:
1125 		*s = "DW_OP_lit14"; break;
1126 	case DW_OP_lit15:
1127 		*s = "DW_OP_lit15"; break;
1128 	case DW_OP_lit16:
1129 		*s = "DW_OP_lit16"; break;
1130 	case DW_OP_lit17:
1131 		*s = "DW_OP_lit17"; break;
1132 	case DW_OP_lit18:
1133 		*s = "DW_OP_lit18"; break;
1134 	case DW_OP_lit19:
1135 		*s = "DW_OP_lit19"; break;
1136 	case DW_OP_lit20:
1137 		*s = "DW_OP_lit20"; break;
1138 	case DW_OP_lit21:
1139 		*s = "DW_OP_lit21"; break;
1140 	case DW_OP_lit22:
1141 		*s = "DW_OP_lit22"; break;
1142 	case DW_OP_lit23:
1143 		*s = "DW_OP_lit23"; break;
1144 	case DW_OP_lit24:
1145 		*s = "DW_OP_lit24"; break;
1146 	case DW_OP_lit25:
1147 		*s = "DW_OP_lit25"; break;
1148 	case DW_OP_lit26:
1149 		*s = "DW_OP_lit26"; break;
1150 	case DW_OP_lit27:
1151 		*s = "DW_OP_lit27"; break;
1152 	case DW_OP_lit28:
1153 		*s = "DW_OP_lit28"; break;
1154 	case DW_OP_lit29:
1155 		*s = "DW_OP_lit29"; break;
1156 	case DW_OP_lit30:
1157 		*s = "DW_OP_lit30"; break;
1158 	case DW_OP_lit31:
1159 		*s = "DW_OP_lit31"; break;
1160 	case DW_OP_dup:
1161 		*s = "DW_OP_dup"; break;
1162 	case DW_OP_drop:
1163 		*s = "DW_OP_drop"; break;
1164 	case DW_OP_over:
1165 		*s = "DW_OP_over"; break;
1166 	case DW_OP_swap:
1167 		*s = "DW_OP_swap"; break;
1168 	case DW_OP_rot:
1169 		*s = "DW_OP_rot"; break;
1170 	case DW_OP_xderef:
1171 		*s = "DW_OP_xderef"; break;
1172 	case DW_OP_abs:
1173 		*s = "DW_OP_abs"; break;
1174 	case DW_OP_and:
1175 		*s = "DW_OP_and"; break;
1176 	case DW_OP_div:
1177 		*s = "DW_OP_div"; break;
1178 	case DW_OP_minus:
1179 		*s = "DW_OP_minus"; break;
1180 	case DW_OP_mod:
1181 		*s = "DW_OP_mod"; break;
1182 	case DW_OP_mul:
1183 		*s = "DW_OP_mul"; break;
1184 	case DW_OP_neg:
1185 		*s = "DW_OP_neg"; break;
1186 	case DW_OP_not:
1187 		*s = "DW_OP_not"; break;
1188 	case DW_OP_or:
1189 		*s = "DW_OP_or"; break;
1190 	case DW_OP_plus:
1191 		*s = "DW_OP_plus"; break;
1192 	case DW_OP_shl:
1193 		*s = "DW_OP_shl"; break;
1194 	case DW_OP_shr:
1195 		*s = "DW_OP_shr"; break;
1196 	case DW_OP_shra:
1197 		*s = "DW_OP_shra"; break;
1198 	case DW_OP_xor:
1199 		*s = "DW_OP_xor"; break;
1200 	case DW_OP_eq:
1201 		*s = "DW_OP_eq"; break;
1202 	case DW_OP_ge:
1203 		*s = "DW_OP_ge"; break;
1204 	case DW_OP_gt:
1205 		*s = "DW_OP_gt"; break;
1206 	case DW_OP_le:
1207 		*s = "DW_OP_le"; break;
1208 	case DW_OP_lt:
1209 		*s = "DW_OP_lt"; break;
1210 	case DW_OP_ne:
1211 		*s = "DW_OP_ne"; break;
1212 	case DW_OP_nop:
1213 		*s = "DW_OP_nop"; break;
1214 	case DW_OP_const1u:
1215 		*s = "DW_OP_const1u"; break;
1216 	case DW_OP_const1s:
1217 		*s = "DW_OP_const1s"; break;
1218 	case DW_OP_pick:
1219 		*s = "DW_OP_pick"; break;
1220 	case DW_OP_deref_size:
1221 		*s = "DW_OP_deref_size"; break;
1222 	case DW_OP_xderef_size:
1223 		*s = "DW_OP_xderef_size"; break;
1224 	case DW_OP_const2u:
1225 		*s = "DW_OP_const2u"; break;
1226 	case DW_OP_const2s:
1227 		*s = "DW_OP_const2s"; break;
1228 	case DW_OP_bra:
1229 		*s = "DW_OP_bra"; break;
1230 	case DW_OP_skip:
1231 		*s = "DW_OP_skip"; break;
1232 	case DW_OP_const4u:
1233 		*s = "DW_OP_const4u"; break;
1234 	case DW_OP_const4s:
1235 		*s = "DW_OP_const4s"; break;
1236 	case DW_OP_const8u:
1237 		*s = "DW_OP_const8u"; break;
1238 	case DW_OP_const8s:
1239 		*s = "DW_OP_const8s"; break;
1240 	case DW_OP_constu:
1241 		*s = "DW_OP_constu"; break;
1242 	case DW_OP_plus_uconst:
1243 		*s = "DW_OP_plus_uconst"; break;
1244 	case DW_OP_regx:
1245 		*s = "DW_OP_regx"; break;
1246 	case DW_OP_piece:
1247 		*s = "DW_OP_piece"; break;
1248 	case DW_OP_consts:
1249 		*s = "DW_OP_consts"; break;
1250 	case DW_OP_breg0:
1251 		*s = "DW_OP_breg0"; break;
1252 	case DW_OP_breg1:
1253 		*s = "DW_OP_breg1"; break;
1254 	case DW_OP_breg2:
1255 		*s = "DW_OP_breg2"; break;
1256 	case DW_OP_breg3:
1257 		*s = "DW_OP_breg3"; break;
1258 	case DW_OP_breg4:
1259 		*s = "DW_OP_breg4"; break;
1260 	case DW_OP_breg5:
1261 		*s = "DW_OP_breg5"; break;
1262 	case DW_OP_breg6:
1263 		*s = "DW_OP_breg6"; break;
1264 	case DW_OP_breg7:
1265 		*s = "DW_OP_breg7"; break;
1266 	case DW_OP_breg8:
1267 		*s = "DW_OP_breg8"; break;
1268 	case DW_OP_breg9:
1269 		*s = "DW_OP_breg9"; break;
1270 	case DW_OP_breg10:
1271 		*s = "DW_OP_breg10"; break;
1272 	case DW_OP_breg11:
1273 		*s = "DW_OP_breg11"; break;
1274 	case DW_OP_breg12:
1275 		*s = "DW_OP_breg12"; break;
1276 	case DW_OP_breg13:
1277 		*s = "DW_OP_breg13"; break;
1278 	case DW_OP_breg14:
1279 		*s = "DW_OP_breg14"; break;
1280 	case DW_OP_breg15:
1281 		*s = "DW_OP_breg15"; break;
1282 	case DW_OP_breg16:
1283 		*s = "DW_OP_breg16"; break;
1284 	case DW_OP_breg17:
1285 		*s = "DW_OP_breg17"; break;
1286 	case DW_OP_breg18:
1287 		*s = "DW_OP_breg18"; break;
1288 	case DW_OP_breg19:
1289 		*s = "DW_OP_breg19"; break;
1290 	case DW_OP_breg20:
1291 		*s = "DW_OP_breg20"; break;
1292 	case DW_OP_breg21:
1293 		*s = "DW_OP_breg21"; break;
1294 	case DW_OP_breg22:
1295 		*s = "DW_OP_breg22"; break;
1296 	case DW_OP_breg23:
1297 		*s = "DW_OP_breg23"; break;
1298 	case DW_OP_breg24:
1299 		*s = "DW_OP_breg24"; break;
1300 	case DW_OP_breg25:
1301 		*s = "DW_OP_breg25"; break;
1302 	case DW_OP_breg26:
1303 		*s = "DW_OP_breg26"; break;
1304 	case DW_OP_breg27:
1305 		*s = "DW_OP_breg27"; break;
1306 	case DW_OP_breg28:
1307 		*s = "DW_OP_breg28"; break;
1308 	case DW_OP_breg29:
1309 		*s = "DW_OP_breg29"; break;
1310 	case DW_OP_breg30:
1311 		*s = "DW_OP_breg30"; break;
1312 	case DW_OP_breg31:
1313 		*s = "DW_OP_breg31"; break;
1314 	case DW_OP_fbreg:
1315 		*s = "DW_OP_fbreg"; break;
1316 	case DW_OP_bregx:
1317 		*s = "DW_OP_bregx"; break;
1318 	case DW_OP_addr:
1319 		*s = "DW_OP_addr"; break;
1320 	case DW_OP_push_object_address:
1321 		*s = "DW_OP_push_object_address"; break;
1322 	case DW_OP_call2:
1323 		*s = "DW_OP_call2"; break;
1324 	case DW_OP_call4:
1325 		*s = "DW_OP_call4"; break;
1326 	case DW_OP_call_ref:
1327 		*s = "DW_OP_call_ref"; break;
1328 	case DW_OP_form_tls_address:
1329 		*s = "DW_OP_form_tls_address"; break;
1330 	case DW_OP_call_frame_cfa:
1331 		*s = "DW_OP_call_frame_cfa"; break;
1332 	case DW_OP_bit_piece:
1333 		*s = "DW_OP_bit_piece"; break;
1334 	case DW_OP_implicit_value:
1335 		*s = "DW_OP_implicit_value"; break;
1336 	case DW_OP_stack_value:
1337 		*s = "DW_OP_stack_value"; break;
1338 	case DW_OP_GNU_push_tls_address:
1339 		*s = "DW_OP_GNU_push_tls_address"; break;
1340 	case DW_OP_GNU_uninit:
1341 		*s = "DW_OP_GNU_uninit"; break;
1342 	case DW_OP_GNU_encoded_addr:
1343 		*s = "DW_OP_GNU_encoded_addr"; break;
1344 	case DW_OP_GNU_implicit_pointer:
1345 		*s = "DW_OP_GNU_implicit_pointer"; break;
1346 	case DW_OP_GNU_entry_value:
1347 		*s = "DW_OP_GNU_entry_value"; break;
1348 	case DW_OP_GNU_const_type:
1349 		*s = "DW_OP_GNU_const_type"; break;
1350 	case DW_OP_GNU_regval_type:
1351 		*s = "DW_OP_GNU_regval_type"; break;
1352 	case DW_OP_GNU_deref_type:
1353 		*s = "DW_OP_GNU_deref_type"; break;
1354 	case DW_OP_GNU_convert:
1355 		*s = "DW_OP_GNU_convert"; break;
1356 	case DW_OP_GNU_reinterpret:
1357 		*s = "DW_OP_GNU_reinterpret"; break;
1358 	case DW_OP_GNU_parameter_ref:
1359 		*s = "DW_OP_GNU_parameter_ref"; break;
1360 	case DW_OP_GNU_addr_index:
1361 		*s = "DW_OP_GNU_addr_index"; break;
1362 	case DW_OP_GNU_const_index:
1363 		*s = "DW_OP_GNU_const_index"; break;
1364 	default:
1365 		return (DW_DLV_NO_ENTRY);
1366 	}
1367 
1368 	return (DW_DLV_OK);
1369 }
1370 
1371 int
dwarf_get_ORD_name(unsigned ord,const char ** s)1372 dwarf_get_ORD_name(unsigned ord, const char **s)
1373 {
1374 
1375 	assert(s != NULL);
1376 
1377 	switch (ord) {
1378 	case DW_ORD_row_major:
1379 		*s = "DW_ORD_row_major"; break;
1380 	case DW_ORD_col_major:
1381 		*s = "DW_ORD_col_major"; break;
1382 	default:
1383 		return (DW_DLV_NO_ENTRY);
1384 	}
1385 
1386 	return (DW_DLV_OK);
1387 }
1388 
1389 int
dwarf_get_TAG_name(unsigned tag,const char ** s)1390 dwarf_get_TAG_name(unsigned tag, const char **s)
1391 {
1392 
1393 	assert(s != NULL);
1394 
1395 	switch (tag) {
1396 	case DW_TAG_access_declaration:
1397 		*s = "DW_TAG_access_declaration"; break;
1398 	case DW_TAG_array_type:
1399 		*s = "DW_TAG_array_type"; break;
1400 	case DW_TAG_atomic_type:
1401 		*s = "DW_TAG_atomic_type"; break;
1402 	case DW_TAG_base_type:
1403 		*s = "DW_TAG_base_type"; break;
1404 	case DW_TAG_call_site:
1405 		*s = "DW_TAG_call_site"; break;
1406 	case DW_TAG_call_site_parameter:
1407 		*s = "DW_TAG_call_site_parameter"; break;
1408 	case DW_TAG_catch_block:
1409 		*s = "DW_TAG_catch_block"; break;
1410 	case DW_TAG_class_type:
1411 		*s = "DW_TAG_class_type"; break;
1412 	case DW_TAG_coarray_type:
1413 		*s = "DW_TAG_coarray_type"; break;
1414 	case DW_TAG_common_block:
1415 		*s = "DW_TAG_common_block"; break;
1416 	case DW_TAG_common_inclusion:
1417 		*s = "DW_TAG_common_inclusion"; break;
1418 	case DW_TAG_compile_unit:
1419 		*s = "DW_TAG_compile_unit"; break;
1420 	case DW_TAG_condition:
1421 		*s = "DW_TAG_condition"; break;
1422 	case DW_TAG_const_type:
1423 		*s = "DW_TAG_const_type"; break;
1424 	case DW_TAG_constant:
1425 		*s = "DW_TAG_constant"; break;
1426 	case DW_TAG_dwarf_procedure:
1427 		*s = "DW_TAG_dwarf_procedure"; break;
1428 	case DW_TAG_dynamic_type:
1429 		*s = "DW_TAG_dynamic_type"; break;
1430 	case DW_TAG_entry_point:
1431 		*s = "DW_TAG_entry_point"; break;
1432 	case DW_TAG_enumeration_type:
1433 		*s = "DW_TAG_enumeration_type"; break;
1434 	case DW_TAG_enumerator:
1435 		*s = "DW_TAG_enumerator"; break;
1436 	case DW_TAG_formal_parameter:
1437 		*s = "DW_TAG_formal_parameter"; break;
1438 	case DW_TAG_friend:
1439 		*s = "DW_TAG_friend"; break;
1440 	case DW_TAG_generic_subrange:
1441 		*s = "DW_TAG_generic_subrange"; break;
1442 	case DW_TAG_immutable_type:
1443 		*s = "DW_TAG_immutable_type"; break;
1444 	case DW_TAG_imported_declaration:
1445 		*s = "DW_TAG_imported_declaration"; break;
1446 	case DW_TAG_imported_module:
1447 		*s = "DW_TAG_imported_module"; break;
1448 	case DW_TAG_imported_unit:
1449 		*s = "DW_TAG_imported_unit"; break;
1450 	case DW_TAG_inheritance:
1451 		*s = "DW_TAG_inheritance"; break;
1452 	case DW_TAG_inlined_subroutine:
1453 		*s = "DW_TAG_inlined_subroutine"; break;
1454 	case DW_TAG_interface_type:
1455 		*s = "DW_TAG_interface_type"; break;
1456 	case DW_TAG_label:
1457 		*s = "DW_TAG_label"; break;
1458 	case DW_TAG_lexical_block:
1459 		*s = "DW_TAG_lexical_block"; break;
1460 	case DW_TAG_member:
1461 		*s = "DW_TAG_member"; break;
1462 	case DW_TAG_module:
1463 		*s = "DW_TAG_module"; break;
1464 	case DW_TAG_namelist:
1465 		*s = "DW_TAG_namelist"; break;
1466 	case DW_TAG_namelist_item:
1467 		*s = "DW_TAG_namelist_item"; break;
1468 	case DW_TAG_namespace:
1469 		*s = "DW_TAG_namespace"; break;
1470 	case DW_TAG_packed_type:
1471 		*s = "DW_TAG_packed_type"; break;
1472 	case DW_TAG_partial_unit:
1473 		*s = "DW_TAG_partial_unit"; break;
1474 	case DW_TAG_pointer_type:
1475 		*s = "DW_TAG_pointer_type"; break;
1476 	case DW_TAG_ptr_to_member_type:
1477 		*s = "DW_TAG_ptr_to_member_type"; break;
1478 	case DW_TAG_reference_type:
1479 		*s = "DW_TAG_reference_type"; break;
1480 	case DW_TAG_restrict_type:
1481 		*s = "DW_TAG_restrict_type"; break;
1482 	case DW_TAG_rvalue_reference_type:
1483 		*s = "DW_TAG_rvalue_reference_type"; break;
1484 	case DW_TAG_set_type:
1485 		*s = "DW_TAG_set_type"; break;
1486 	case DW_TAG_shared_type:
1487 		*s = "DW_TAG_shared_type"; break;
1488 	case DW_TAG_skeleton_unit:
1489 		*s = "DW_TAG_skeleton_unit"; break;
1490 	case DW_TAG_string_type:
1491 		*s = "DW_TAG_string_type"; break;
1492 	case DW_TAG_structure_type:
1493 		*s = "DW_TAG_structure_type"; break;
1494 	case DW_TAG_subprogram:
1495 		*s = "DW_TAG_subprogram"; break;
1496 	case DW_TAG_subrange_type:
1497 		*s = "DW_TAG_subrange_type"; break;
1498 	case DW_TAG_subroutine_type:
1499 		*s = "DW_TAG_subroutine_type"; break;
1500 	case DW_TAG_template_alias:
1501 		*s = "DW_TAG_template_alias"; break;
1502 	case DW_TAG_template_type_parameter:
1503 		*s = "DW_TAG_template_type_parameter"; break;
1504 	case DW_TAG_template_value_parameter:
1505 		*s = "DW_TAG_template_value_parameter"; break;
1506 	case DW_TAG_thrown_type:
1507 		*s = "DW_TAG_thrown_type"; break;
1508 	case DW_TAG_try_block:
1509 		*s = "DW_TAG_try_block"; break;
1510 	case DW_TAG_type_unit:
1511 		*s = "DW_TAG_type_unit"; break;
1512 	case DW_TAG_typedef:
1513 		*s = "DW_TAG_typedef"; break;
1514 	case DW_TAG_union_type:
1515 		*s = "DW_TAG_union_type"; break;
1516 	case DW_TAG_unspecified_parameters:
1517 		*s = "DW_TAG_unspecified_parameters"; break;
1518 	case DW_TAG_unspecified_type:
1519 		*s = "DW_TAG_unspecified_type"; break;
1520 	case DW_TAG_variable:
1521 		*s = "DW_TAG_variable"; break;
1522 	case DW_TAG_variant:
1523 		*s = "DW_TAG_variant"; break;
1524 	case DW_TAG_variant_part:
1525 		*s = "DW_TAG_variant_part"; break;
1526 	case DW_TAG_volatile_type:
1527 		*s = "DW_TAG_volatile_type"; break;
1528 	case DW_TAG_with_stmt:
1529 		*s = "DW_TAG_with_stmt"; break;
1530 	case DW_TAG_format_label:
1531 		*s = "DW_TAG_format_label"; break;
1532 	case DW_TAG_function_template:
1533 		*s = "DW_TAG_function_template"; break;
1534 	case DW_TAG_class_template:
1535 		*s = "DW_TAG_class_template"; break;
1536 	case DW_TAG_GNU_BINCL:
1537 		*s = "DW_TAG_GNU_BINCL"; break;
1538 	case DW_TAG_GNU_EINCL:
1539 		*s = "DW_TAG_GNU_EINCL"; break;
1540 	case DW_TAG_GNU_template_template_param:
1541 		*s = "DW_TAG_GNU_template_template_param"; break;
1542 	case DW_TAG_GNU_template_parameter_pack:
1543 		*s = "DW_TAG_GNU_template_parameter_pack"; break;
1544 	case DW_TAG_GNU_formal_parameter_pack:
1545 		*s = "DW_TAG_GNU_formal_parameter_pack"; break;
1546 	case DW_TAG_GNU_call_site:
1547 		*s = "DW_TAG_GNU_call_site"; break;
1548 	case DW_TAG_GNU_call_site_parameter:
1549 		*s = "DW_TAG_GNU_call_site_parameter"; break;
1550 	default:
1551 		return (DW_DLV_NO_ENTRY);
1552 	}
1553 
1554 	return (DW_DLV_OK);
1555 }
1556 
1557 int
dwarf_get_UT_name(unsigned ut,const char ** s)1558 dwarf_get_UT_name(unsigned ut, const char **s)
1559 {
1560 
1561 	assert(s != NULL);
1562 
1563 	switch (ut) {
1564 	case DW_UT_compile:
1565 		*s = "DW_UT_compile"; break;
1566 	case DW_UT_type:
1567 		*s = "DW_UT_type"; break;
1568 	case DW_UT_partial:
1569 		*s = "DW_UT_partial"; break;
1570 	case DW_UT_skeleton:
1571 		*s = "DW_UT_skeleton"; break;
1572 	case DW_UT_split_compile:
1573 		*s = "DW_UT_split_compile"; break;
1574 	case DW_UT_split_type:
1575 		*s = "DW_UT_split_type"; break;
1576 	case DW_UT_lo_user:
1577 		*s = "DW_UT_lo_user"; break;
1578 	case DW_UT_hi_user:
1579 		*s = "DW_UT_hi_user"; break;
1580 	default:
1581 		return (DW_DLV_NO_ENTRY);
1582 	}
1583 
1584 	return (DW_DLV_OK);
1585 }
1586 
1587 int
dwarf_get_VIRTUALITY_name(unsigned vir,const char ** s)1588 dwarf_get_VIRTUALITY_name(unsigned vir, const char **s)
1589 {
1590 
1591 	assert(s != NULL);
1592 
1593 	switch (vir) {
1594 	case DW_VIRTUALITY_none:
1595 		*s = "DW_VIRTUALITY_none"; break;
1596 	case DW_VIRTUALITY_virtual:
1597 		*s = "DW_VIRTUALITY_virtual"; break;
1598 	case DW_VIRTUALITY_pure_virtual:
1599 		*s = "DW_VIRTUALITY_pure_virtual"; break;
1600 	default:
1601 		return (DW_DLV_NO_ENTRY);
1602 	}
1603 
1604 	return (DW_DLV_OK);
1605 }
1606 
1607 int
dwarf_get_VIS_name(unsigned vis,const char ** s)1608 dwarf_get_VIS_name(unsigned vis, const char **s)
1609 {
1610 
1611 	assert(s != NULL);
1612 
1613 	switch (vis) {
1614 	case DW_VIS_local:
1615 		*s = "DW_VIS_local"; break;
1616 	case DW_VIS_exported:
1617 		*s = "DW_VIS_exported"; break;
1618 	case DW_VIS_qualified:
1619 		*s = "DW_VIS_qualified"; break;
1620 	default:
1621 		return (DW_DLV_NO_ENTRY);
1622 	}
1623 
1624 	return (DW_DLV_OK);
1625 }
1626