1 /* DWARF stringify code 2 3 Copyright (C) 1994-2020 Free Software Foundation, Inc. 4 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. 11 12 This file is part of GDB. 13 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. 18 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. 23 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/>. */ 26 27 #include "defs.h" 28 #include "dwarf2.h" 29 #include "dwarf2/stringify.h" 30 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". */ 34 35 static const char * 36 dwarf_unknown (const char *str, unsigned v) 37 { 38 char *cell = get_print_cell (); 39 xsnprintf (cell, PRINT_CELL_SIZE, "DW_%s_<unknown: %u>", str, v); 40 return cell; 41 } 42 43 /* See stringify.h. */ 44 45 const char * 46 dwarf_tag_name (unsigned tag) 47 { 48 const char *name = get_DW_TAG_name (tag); 49 50 if (name == NULL) 51 return dwarf_unknown ("TAG", tag); 52 53 return name; 54 } 55 56 /* See stringify.h. */ 57 58 const char * 59 dwarf_attr_name (unsigned attr) 60 { 61 const char *name; 62 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 70 71 name = get_DW_AT_name (attr); 72 73 if (name == NULL) 74 return dwarf_unknown ("AT", attr); 75 76 return name; 77 } 78 79 /* See stringify.h. */ 80 81 const char * 82 dwarf_form_name (unsigned form) 83 { 84 const char *name = get_DW_FORM_name (form); 85 86 if (name == NULL) 87 return dwarf_unknown ("FORM", form); 88 89 return name; 90 } 91 92 /* See stringify.h. */ 93 94 const char * 95 dwarf_bool_name (unsigned mybool) 96 { 97 if (mybool) 98 return "TRUE"; 99 else 100 return "FALSE"; 101 } 102 103 /* See stringify.h. */ 104 105 const char * 106 dwarf_type_encoding_name (unsigned enc) 107 { 108 const char *name = get_DW_ATE_name (enc); 109 110 if (name == NULL) 111 return dwarf_unknown ("ATE", enc); 112 113 return name; 114 } 115