Branch data Line data Source code
1 : : /* Get the default subrange lower bound for a given language. 2 : : Copyright (C) 2016 Red Hat, Inc. 3 : : Copyright (C) 2024, 2025 Mark J. Wielaard <mark@klomp.org> 4 : : This file is part of elfutils. 5 : : 6 : : This file is free software; you can redistribute it and/or modify 7 : : it under the terms of either 8 : : 9 : : * the GNU Lesser General Public License as published by the Free 10 : : Software Foundation; either version 3 of the License, or (at 11 : : your option) any later version 12 : : 13 : : or 14 : : 15 : : * the GNU General Public License as published by the Free 16 : : Software Foundation; either version 2 of the License, or (at 17 : : your option) any later version 18 : : 19 : : or both in parallel, as here. 20 : : 21 : : elfutils is distributed in the hope that it will be useful, but 22 : : WITHOUT ANY WARRANTY; without even the implied warranty of 23 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 : : General Public License for more details. 25 : : 26 : : You should have received copies of the GNU General Public License and 27 : : the GNU Lesser General Public License along with this program. If 28 : : not, see <http://www.gnu.org/licenses/>. */ 29 : : 30 : : #ifdef HAVE_CONFIG_H 31 : : # include <config.h> 32 : : #endif 33 : : 34 : : #include <dwarf.h> 35 : : #include "libdwP.h" 36 : : 37 : : /* Determine default lower bound from language, as per the DWARF5 38 : : "Subrange Type Entries" table. */ 39 : : int 40 : 69 : dwarf_default_lower_bound (int lang, Dwarf_Sword *result) 41 : : { 42 [ + + + + ]: 69 : switch (lang) 43 : : { 44 : 48 : case DW_LANG_C: 45 : : case DW_LANG_C89: 46 : : case DW_LANG_C99: 47 : : case DW_LANG_C11: 48 : : case DW_LANG_C_plus_plus: 49 : : case DW_LANG_C_plus_plus_03: 50 : : case DW_LANG_C_plus_plus_11: 51 : : case DW_LANG_C_plus_plus_14: 52 : : case DW_LANG_ObjC: 53 : : case DW_LANG_ObjC_plus_plus: 54 : : case DW_LANG_Java: 55 : : case DW_LANG_D: 56 : : case DW_LANG_Python: 57 : : case DW_LANG_UPC: 58 : : case DW_LANG_OpenCL: 59 : : case DW_LANG_Go: 60 : : case DW_LANG_Haskell: 61 : : case DW_LANG_OCaml: 62 : : case DW_LANG_Rust: 63 : : case DW_LANG_Swift: 64 : : case DW_LANG_Dylan: 65 : : case DW_LANG_RenderScript: 66 : : case DW_LANG_BLISS: 67 : : case DW_LANG_Kotlin: 68 : : case DW_LANG_Zig: 69 : : case DW_LANG_Crystal: 70 : : case DW_LANG_C_plus_plus_17: 71 : : case DW_LANG_C_plus_plus_20: 72 : : case DW_LANG_C17: 73 : : case DW_LANG_HIP: 74 : : case DW_LANG_Assembly: 75 : : case DW_LANG_C_sharp: 76 : : case DW_LANG_Mojo: 77 : : case DW_LANG_GLSL: 78 : : case DW_LANG_GLSL_ES: 79 : : case DW_LANG_HLSL: 80 : : case DW_LANG_OpenCL_CPP: 81 : : case DW_LANG_CPP_for_OpenCL: 82 : : case DW_LANG_SYCL: 83 : : case DW_LANG_C_plus_plus_23: 84 : : case DW_LANG_Odin: 85 : : case DW_LANG_P4: 86 : : case DW_LANG_Metal: 87 : : case DW_LANG_C23: 88 : : case DW_LANG_Ruby: 89 : : case DW_LANG_Move: 90 : : case DW_LANG_Hylo: 91 : : case DW_LANG_V: 92 : 48 : *result = 0; 93 : 48 : return 0; 94 : : 95 : 19 : case DW_LANG_Ada83: 96 : : case DW_LANG_Ada95: 97 : : case DW_LANG_Cobol74: 98 : : case DW_LANG_Cobol85: 99 : : case DW_LANG_Fortran77: 100 : : case DW_LANG_Fortran90: 101 : : case DW_LANG_Fortran95: 102 : : case DW_LANG_Fortran03: 103 : : case DW_LANG_Fortran08: 104 : : case DW_LANG_Pascal83: 105 : : case DW_LANG_Modula2: 106 : : case DW_LANG_Modula3: 107 : : case DW_LANG_PLI: 108 : : case DW_LANG_Julia: 109 : : case DW_LANG_Fortran18: 110 : : case DW_LANG_Ada2005: 111 : : case DW_LANG_Ada2012: 112 : : case DW_LANG_Fortran23: 113 : : case DW_LANG_Algol68: 114 : 19 : *result = 1; 115 : 19 : return 0; 116 : : 117 : : /* Special case vendor Assembly variant. */ 118 : 1 : case DW_LANG_Mips_Assembler: 119 : 1 : *result = 0; 120 : 1 : return 0; 121 : : 122 : 1 : default: 123 : 1 : __libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE); 124 : 1 : return -1; 125 : : } 126 : : } 127 : : INTDEF (dwarf_default_lower_bound) 128 : : 129 : : /* Determine default lower bound from language, as per the DWARF6 130 : : https://dwarfstd.org/languages-v6.html table. */ 131 : : int 132 : 274 : dwarf_language_lower_bound (Dwarf_Word lang, Dwarf_Sword *result) 133 : : { 134 [ + + + ]: 274 : switch (lang) 135 : : { 136 : 264 : case DW_LNAME_BLISS: 137 : : case DW_LNAME_C: 138 : : case DW_LNAME_C_plus_plus: 139 : : case DW_LNAME_Crystal: 140 : : case DW_LNAME_D: 141 : : case DW_LNAME_Dylan: 142 : : case DW_LNAME_Go: 143 : : case DW_LNAME_Haskell: 144 : : case DW_LNAME_Java: 145 : : case DW_LNAME_Kotlin: 146 : : case DW_LNAME_ObjC: 147 : : case DW_LNAME_ObjC_plus_plus: 148 : : case DW_LNAME_OCaml: 149 : : case DW_LNAME_OpenCL_C: 150 : : case DW_LNAME_Python: 151 : : case DW_LNAME_RenderScript: 152 : : case DW_LNAME_Rust: 153 : : case DW_LNAME_Swift: 154 : : case DW_LNAME_UPC: 155 : : case DW_LNAME_Zig: 156 : : case DW_LNAME_Assembly: 157 : : case DW_LNAME_C_sharp: 158 : : case DW_LNAME_Mojo: 159 : : case DW_LNAME_GLSL: 160 : : case DW_LNAME_GLSL_ES: 161 : : case DW_LNAME_HLSL: 162 : : case DW_LNAME_OpenCL_CPP: 163 : : case DW_LNAME_CPP_for_OpenCL: 164 : : case DW_LNAME_SYCL: 165 : : case DW_LNAME_Ruby: 166 : : case DW_LNAME_Move: 167 : : case DW_LNAME_Hylo: 168 : : case DW_LNAME_HIP: 169 : : case DW_LNAME_Odin: 170 : : case DW_LNAME_P4: 171 : : case DW_LNAME_Metal: 172 : : case DW_LNAME_V: 173 : 264 : *result = 0; 174 : 264 : return 0; 175 : : 176 : 9 : case DW_LNAME_Ada: 177 : : case DW_LNAME_Cobol: 178 : : case DW_LNAME_Fortran: 179 : : case DW_LNAME_Julia: 180 : : case DW_LNAME_Modula2: 181 : : case DW_LNAME_Modula3: 182 : : case DW_LNAME_Pascal: 183 : : case DW_LNAME_PLI: 184 : : case DW_LNAME_Algol68: 185 : 9 : *result = 1; 186 : 9 : return 0; 187 : : 188 : 1 : default: 189 : 1 : __libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE); 190 : 1 : return -1; 191 : : } 192 : : } 193 : : INTDEF (dwarf_language_lower_bound)