Coverage Report

Created: 2025-07-11 06:46

/src/elfutils/libdw/dwarf_default_lower_bound.c
Line
Count
Source (jump to first uncovered line)
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
dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
41
0
{
42
0
  switch (lang)
43
0
    {
44
0
    case DW_LANG_C:
45
0
    case DW_LANG_C89:
46
0
    case DW_LANG_C99:
47
0
    case DW_LANG_C11:
48
0
    case DW_LANG_C_plus_plus:
49
0
    case DW_LANG_C_plus_plus_03:
50
0
    case DW_LANG_C_plus_plus_11:
51
0
    case DW_LANG_C_plus_plus_14:
52
0
    case DW_LANG_ObjC:
53
0
    case DW_LANG_ObjC_plus_plus:
54
0
    case DW_LANG_Java:
55
0
    case DW_LANG_D:
56
0
    case DW_LANG_Python:
57
0
    case DW_LANG_UPC:
58
0
    case DW_LANG_OpenCL:
59
0
    case DW_LANG_Go:
60
0
    case DW_LANG_Haskell:
61
0
    case DW_LANG_OCaml:
62
0
    case DW_LANG_Rust:
63
0
    case DW_LANG_Swift:
64
0
    case DW_LANG_Dylan:
65
0
    case DW_LANG_RenderScript:
66
0
    case DW_LANG_BLISS:
67
0
    case DW_LANG_Kotlin:
68
0
    case DW_LANG_Zig:
69
0
    case DW_LANG_Crystal:
70
0
    case DW_LANG_C_plus_plus_17:
71
0
    case DW_LANG_C_plus_plus_20:
72
0
    case DW_LANG_C17:
73
0
    case DW_LANG_HIP:
74
0
    case DW_LANG_Assembly:
75
0
    case DW_LANG_C_sharp:
76
0
    case DW_LANG_Mojo:
77
0
    case DW_LANG_GLSL:
78
0
    case DW_LANG_GLSL_ES:
79
0
    case DW_LANG_HLSL:
80
0
    case DW_LANG_OpenCL_CPP:
81
0
    case DW_LANG_CPP_for_OpenCL:
82
0
    case DW_LANG_SYCL:
83
0
    case DW_LANG_C_plus_plus_23:
84
0
    case DW_LANG_Odin:
85
0
    case DW_LANG_P4:
86
0
    case DW_LANG_Metal:
87
0
    case DW_LANG_C23:
88
0
    case DW_LANG_Ruby:
89
0
    case DW_LANG_Move:
90
0
    case DW_LANG_Hylo:
91
0
    case DW_LANG_V:
92
0
    case DW_LANG_Nim:
93
0
      *result = 0;
94
0
      return 0;
95
96
0
    case DW_LANG_Ada83:
97
0
    case DW_LANG_Ada95:
98
0
    case DW_LANG_Cobol74:
99
0
    case DW_LANG_Cobol85:
100
0
    case DW_LANG_Fortran77:
101
0
    case DW_LANG_Fortran90:
102
0
    case DW_LANG_Fortran95:
103
0
    case DW_LANG_Fortran03:
104
0
    case DW_LANG_Fortran08:
105
0
    case DW_LANG_Pascal83:
106
0
    case DW_LANG_Modula2:
107
0
    case DW_LANG_Modula3:
108
0
    case DW_LANG_PLI:
109
0
    case DW_LANG_Julia:
110
0
    case DW_LANG_Fortran18:
111
0
    case DW_LANG_Ada2005:
112
0
    case DW_LANG_Ada2012:
113
0
    case DW_LANG_Fortran23:
114
0
    case DW_LANG_Algol68:
115
0
      *result = 1;
116
0
      return 0;
117
118
    /* Special case vendor Assembly variant.  */
119
0
    case DW_LANG_Mips_Assembler:
120
0
      *result = 0;
121
0
      return 0;
122
123
0
    default:
124
0
      __libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE);
125
0
      return -1;
126
0
    }
127
0
}
128
INTDEF (dwarf_default_lower_bound)
129
130
/* Determine default lower bound from language, as per the DWARF6
131
   https://dwarfstd.org/languages-v6.html table.  */
132
int
133
dwarf_language_lower_bound (Dwarf_Word lang, Dwarf_Sword *result)
134
0
{
135
0
  switch (lang)
136
0
    {
137
0
    case DW_LNAME_BLISS:
138
0
    case DW_LNAME_C:
139
0
    case DW_LNAME_C_plus_plus:
140
0
    case DW_LNAME_Crystal:
141
0
    case DW_LNAME_D:
142
0
    case DW_LNAME_Dylan:
143
0
    case DW_LNAME_Go:
144
0
    case DW_LNAME_Haskell:
145
0
    case DW_LNAME_Java:
146
0
    case DW_LNAME_Kotlin:
147
0
    case DW_LNAME_ObjC:
148
0
    case DW_LNAME_ObjC_plus_plus:
149
0
    case DW_LNAME_OCaml:
150
0
    case DW_LNAME_OpenCL_C:
151
0
    case DW_LNAME_Python:
152
0
    case DW_LNAME_RenderScript:
153
0
    case DW_LNAME_Rust:
154
0
    case DW_LNAME_Swift:
155
0
    case DW_LNAME_UPC:
156
0
    case DW_LNAME_Zig:
157
0
    case DW_LNAME_Assembly:
158
0
    case DW_LNAME_C_sharp:
159
0
    case DW_LNAME_Mojo:
160
0
    case DW_LNAME_GLSL:
161
0
    case DW_LNAME_GLSL_ES:
162
0
    case DW_LNAME_HLSL:
163
0
    case DW_LNAME_OpenCL_CPP:
164
0
    case DW_LNAME_CPP_for_OpenCL:
165
0
    case DW_LNAME_SYCL:
166
0
    case DW_LNAME_Ruby:
167
0
    case DW_LNAME_Move:
168
0
    case DW_LNAME_Hylo:
169
0
    case DW_LNAME_HIP:
170
0
    case DW_LNAME_Odin:
171
0
    case DW_LNAME_P4:
172
0
    case DW_LNAME_Metal:
173
0
    case DW_LNAME_V:
174
0
    case DW_LNAME_Nim:
175
0
      *result = 0;
176
0
      return 0;
177
178
0
    case DW_LNAME_Ada:
179
0
    case DW_LNAME_Cobol:
180
0
    case DW_LNAME_Fortran:
181
0
    case DW_LNAME_Julia:
182
0
    case DW_LNAME_Modula2:
183
0
    case DW_LNAME_Modula3:
184
0
    case DW_LNAME_Pascal:
185
0
    case DW_LNAME_PLI:
186
0
    case DW_LNAME_Algol68:
187
0
      *result = 1;
188
0
      return 0;
189
190
0
    default:
191
0
      __libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE);
192
0
      return -1;
193
0
    }
194
0
}
195
INTDEF (dwarf_language_lower_bound)