LLVM 20.0.0git
Dwarf.h
Go to the documentation of this file.
1//===-- llvm/BinaryFormat/Dwarf.h ---Dwarf Constants-------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// This file contains constants used for implementing Dwarf
11/// debug support.
12///
13/// For details on the Dwarf specfication see the latest DWARF Debugging
14/// Information Format standard document on http://www.dwarfstd.org. This
15/// file often includes support for non-released standard features.
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_BINARYFORMAT_DWARF_H
20#define LLVM_BINARYFORMAT_DWARF_H
21
25#include "llvm/Support/Format.h"
28
29#include <limits>
30
31namespace llvm {
32class StringRef;
33
34namespace dwarf {
35
36//===----------------------------------------------------------------------===//
37// DWARF constants as gleaned from the DWARF Debugging Information Format V.5
38// reference manual http://www.dwarfstd.org/.
39//
40
41// Do not mix the following two enumerations sets. DW_TAG_invalid changes the
42// enumeration base type.
43
45 /// LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
46 /// \{
47 DW_TAG_invalid = ~0U, ///< Tag for invalid results.
48 DW_VIRTUALITY_invalid = ~0U, ///< Virtuality for invalid results.
49 DW_MACINFO_invalid = ~0U, ///< Macinfo type for invalid results.
50 /// \}
51
52 /// Special values for an initial length field.
53 /// \{
54 DW_LENGTH_lo_reserved = 0xfffffff0, ///< Lower bound of the reserved range.
55 DW_LENGTH_DWARF64 = 0xffffffff, ///< Indicator of 64-bit DWARF format.
56 DW_LENGTH_hi_reserved = 0xffffffff, ///< Upper bound of the reserved range.
57 /// \}
58
59 /// Other constants.
60 /// \{
61 DWARF_VERSION = 4, ///< Default dwarf version we output.
62 DW_PUBTYPES_VERSION = 2, ///< Section version number for .debug_pubtypes.
63 DW_PUBNAMES_VERSION = 2, ///< Section version number for .debug_pubnames.
64 DW_ARANGES_VERSION = 2, ///< Section version number for .debug_aranges.
65 /// \}
66
67 /// Identifiers we use to distinguish vendor extensions.
68 /// \{
69 DWARF_VENDOR_DWARF = 0, ///< Defined in v2 or later of the DWARF standard.
87 ///\}
88};
89
90/// Constants that define the DWARF format as 32 or 64 bit.
92
93/// Special ID values that distinguish a CIE from a FDE in DWARF CFI.
94/// Not inside an enum because a 64-bit value is needed.
95/// @{
96const uint32_t DW_CIE_ID = UINT32_MAX;
98/// @}
99
100/// Identifier of an invalid DIE offset in the .debug_info section.
101const uint32_t DW_INVALID_OFFSET = UINT32_MAX;
102
103enum Tag : uint16_t {
104#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) DW_TAG_##NAME = ID,
105#include "llvm/BinaryFormat/Dwarf.def"
108 DW_TAG_user_base = 0x1000 ///< Recommended base for user tags.
110
111inline bool isType(Tag T) {
112 switch (T) {
113 default:
114 return false;
115#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR, KIND) \
116 case DW_TAG_##NAME: \
117 return (KIND == DW_KIND_TYPE);
118#include "llvm/BinaryFormat/Dwarf.def"
119 }
120}
121
122/// Attributes.
124#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) DW_AT_##NAME = ID,
125#include "llvm/BinaryFormat/Dwarf.def"
128};
129
131#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) DW_FORM_##NAME = ID,
132#include "llvm/BinaryFormat/Dwarf.def"
133 DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF.
134};
135
137#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
138 DW_OP_##NAME = ID,
139#include "llvm/BinaryFormat/Dwarf.def"
142 DW_OP_LLVM_fragment = 0x1000, ///< Only used in LLVM metadata.
143 DW_OP_LLVM_convert = 0x1001, ///< Only used in LLVM metadata.
144 DW_OP_LLVM_tag_offset = 0x1002, ///< Only used in LLVM metadata.
145 DW_OP_LLVM_entry_value = 0x1003, ///< Only used in LLVM metadata.
146 DW_OP_LLVM_implicit_pointer = 0x1004, ///< Only used in LLVM metadata.
147 DW_OP_LLVM_arg = 0x1005, ///< Only used in LLVM metadata.
148 DW_OP_LLVM_extract_bits_sext = 0x1006, ///< Only used in LLVM metadata.
149 DW_OP_LLVM_extract_bits_zext = 0x1007, ///< Only used in LLVM metadata.
150};
151
153#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) DW_OP_LLVM_##NAME = ID,
154#include "llvm/BinaryFormat/Dwarf.def"
155};
156
158#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) DW_ATE_##NAME = ID,
159#include "llvm/BinaryFormat/Dwarf.def"
161 DW_ATE_hi_user = 0xff
163
165 // Decimal sign attribute values
172
174 // Endianity attribute values
175#define HANDLE_DW_END(ID, NAME) DW_END_##NAME = ID,
176#include "llvm/BinaryFormat/Dwarf.def"
178 DW_END_hi_user = 0xff
180
182 // Accessibility codes
185 DW_ACCESS_private = 0x03
187
189 // Visibility codes
192 DW_VIS_qualified = 0x03
194
196#define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
197#include "llvm/BinaryFormat/Dwarf.def"
198 DW_VIRTUALITY_max = 0x02
200
202#define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID,
203#include "llvm/BinaryFormat/Dwarf.def"
204 DW_DEFAULTED_max = 0x02
206
208#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
209 DW_LANG_##NAME = ID,
210#include "llvm/BinaryFormat/Dwarf.def"
212 DW_LANG_hi_user = 0xffff
214
216#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) DW_LNAME_##NAME = ID,
217#include "llvm/BinaryFormat/Dwarf.def"
218};
219
220/// Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
221/// If the version number doesn't exactly match a known version it is
222/// rounded up to the next-highest known version number.
223inline std::optional<SourceLanguage> toDW_LANG(SourceLanguageName name,
224 uint32_t version) {
225 switch (name) {
226 case DW_LNAME_Ada: // YYYY
227 if (version <= 1983)
228 return DW_LANG_Ada83;
229 if (version <= 1995)
230 return DW_LANG_Ada95;
231 if (version <= 2005)
232 return DW_LANG_Ada2005;
233 if (version <= 2012)
234 return DW_LANG_Ada2012;
235 return {};
236 case DW_LNAME_BLISS:
237 return DW_LANG_BLISS;
238 case DW_LNAME_C: // YYYYMM, K&R 000000
239 if (version == 0)
240 return DW_LANG_C;
241 if (version <= 198912)
242 return DW_LANG_C89;
243 if (version <= 199901)
244 return DW_LANG_C99;
245 if (version <= 201112)
246 return DW_LANG_C11;
247 if (version <= 201710)
248 return DW_LANG_C17;
249 return {};
250 case DW_LNAME_C_plus_plus: // YYYYMM
251 if (version == 0)
252 return DW_LANG_C_plus_plus;
253 if (version <= 199711)
254 return DW_LANG_C_plus_plus;
255 if (version <= 200310)
256 return DW_LANG_C_plus_plus_03;
257 if (version <= 201103)
258 return DW_LANG_C_plus_plus_11;
259 if (version <= 201402)
260 return DW_LANG_C_plus_plus_14;
261 if (version <= 201703)
262 return DW_LANG_C_plus_plus_17;
263 if (version <= 202002)
264 return DW_LANG_C_plus_plus_20;
265 return {};
266 case DW_LNAME_Cobol: // YYYY
267 if (version <= 1974)
268 return DW_LANG_Cobol74;
269 if (version <= 1985)
270 return DW_LANG_Cobol85;
271 return {};
272 case DW_LNAME_Crystal:
273 return DW_LANG_Crystal;
274 case DW_LNAME_D:
275 return DW_LANG_D;
276 case DW_LNAME_Dylan:
277 return DW_LANG_Dylan;
278 case DW_LNAME_Fortran: // YYYY
279 if (version <= 1977)
280 return DW_LANG_Fortran77;
281 if (version <= 1990)
282 return DW_LANG_Fortran90;
283 if (version <= 1995)
284 return DW_LANG_Fortran95;
285 if (version <= 2003)
286 return DW_LANG_Fortran03;
287 if (version <= 2008)
288 return DW_LANG_Fortran08;
289 if (version <= 2018)
290 return DW_LANG_Fortran18;
291 return {};
292 case DW_LNAME_Go:
293 return DW_LANG_Go;
294 case DW_LNAME_Haskell:
295 return DW_LANG_Haskell;
296 // case DW_LNAME_HIP:
297 // return DW_LANG_HIP;
298 case DW_LNAME_Java:
299 return DW_LANG_Java;
300 case DW_LNAME_Julia:
301 return DW_LANG_Julia;
302 case DW_LNAME_Kotlin:
303 return DW_LANG_Kotlin;
304 case DW_LNAME_Modula2:
305 return DW_LANG_Modula2;
306 case DW_LNAME_Modula3:
307 return DW_LANG_Modula3;
308 case DW_LNAME_ObjC:
309 return DW_LANG_ObjC;
310 case DW_LNAME_ObjC_plus_plus:
311 return DW_LANG_ObjC_plus_plus;
312 case DW_LNAME_OCaml:
313 return DW_LANG_OCaml;
314 case DW_LNAME_OpenCL_C:
315 return DW_LANG_OpenCL;
316 case DW_LNAME_Pascal:
317 return DW_LANG_Pascal83;
318 case DW_LNAME_PLI:
319 return DW_LANG_PLI;
320 case DW_LNAME_Python:
321 return DW_LANG_Python;
322 case DW_LNAME_RenderScript:
323 return DW_LANG_RenderScript;
324 case DW_LNAME_Rust:
325 return DW_LANG_Rust;
326 case DW_LNAME_Swift:
327 return DW_LANG_Swift;
328 case DW_LNAME_UPC:
329 return DW_LANG_UPC;
330 case DW_LNAME_Zig:
331 return DW_LANG_Zig;
332 case DW_LNAME_Assembly:
333 return DW_LANG_Assembly;
334 case DW_LNAME_C_sharp:
335 return DW_LANG_C_sharp;
336 case DW_LNAME_Mojo:
337 return DW_LANG_Mojo;
338 case DW_LNAME_GLSL:
339 return DW_LANG_GLSL;
340 case DW_LNAME_GLSL_ES:
341 return DW_LANG_GLSL_ES;
342 case DW_LNAME_HLSL:
343 return DW_LANG_HLSL;
344 case DW_LNAME_OpenCL_CPP:
345 return DW_LANG_OpenCL_CPP;
346 case DW_LNAME_CPP_for_OpenCL:
347 return {};
348 case DW_LNAME_SYCL:
349 return DW_LANG_SYCL;
350 case DW_LNAME_Ruby:
351 return DW_LANG_Ruby;
352 case DW_LNAME_Move:
353 return DW_LANG_Move;
354 case DW_LNAME_Hylo:
355 return DW_LANG_Hylo;
356 case DW_LNAME_Metal:
357 return DW_LANG_Metal;
358 }
359 return {};
360}
361
362/// Convert a DWARF 5 DW_LANG to a DWARF 6 pair of language name and version.
363inline std::optional<std::pair<SourceLanguageName, uint32_t>>
365 switch (language) {
366 case DW_LANG_Ada83:
367 return {{DW_LNAME_Ada, 1983}};
368 case DW_LANG_Ada95:
369 return {{DW_LNAME_Ada, 1995}};
370 case DW_LANG_Ada2005:
371 return {{DW_LNAME_Ada, 2005}};
372 case DW_LANG_Ada2012:
373 return {{DW_LNAME_Ada, 2012}};
374 case DW_LANG_BLISS:
375 return {{DW_LNAME_BLISS, 0}};
376 case DW_LANG_C:
377 return {{DW_LNAME_C, 0}};
378 case DW_LANG_C89:
379 return {{DW_LNAME_C, 198912}};
380 case DW_LANG_C99:
381 return {{DW_LNAME_C, 199901}};
382 case DW_LANG_C11:
383 return {{DW_LNAME_C, 201112}};
384 case DW_LANG_C17:
385 return {{DW_LNAME_C, 201712}};
386 case DW_LANG_C_plus_plus:
387 return {{DW_LNAME_C_plus_plus, 0}};
388 case DW_LANG_C_plus_plus_03:
389 return {{DW_LNAME_C_plus_plus, 200310}};
390 case DW_LANG_C_plus_plus_11:
391 return {{DW_LNAME_C_plus_plus, 201103}};
392 case DW_LANG_C_plus_plus_14:
393 return {{DW_LNAME_C_plus_plus, 201402}};
394 case DW_LANG_C_plus_plus_17:
395 return {{DW_LNAME_C_plus_plus, 201703}};
396 case DW_LANG_C_plus_plus_20:
397 return {{DW_LNAME_C_plus_plus, 202002}};
398 case DW_LANG_Cobol74:
399 return {{DW_LNAME_Cobol, 1974}};
400 case DW_LANG_Cobol85:
401 return {{DW_LNAME_Cobol, 1985}};
402 case DW_LANG_Crystal:
403 return {{DW_LNAME_Crystal, 0}};
404 case DW_LANG_D:
405 return {{DW_LNAME_D, 0}};
406 case DW_LANG_Dylan:
407 return {{DW_LNAME_Dylan, 0}};
408 case DW_LANG_Fortran77:
409 return {{DW_LNAME_Fortran, 1977}};
410 case DW_LANG_Fortran90:
411 return {{DW_LNAME_Fortran, 1990}};
412 case DW_LANG_Fortran95:
413 return {{DW_LNAME_Fortran, 1995}};
414 case DW_LANG_Fortran03:
415 return {{DW_LNAME_Fortran, 2003}};
416 case DW_LANG_Fortran08:
417 return {{DW_LNAME_Fortran, 2008}};
418 case DW_LANG_Fortran18:
419 return {{DW_LNAME_Fortran, 2018}};
420 case DW_LANG_Go:
421 return {{DW_LNAME_Go, 0}};
422 case DW_LANG_Haskell:
423 return {{DW_LNAME_Haskell, 0}};
424 case DW_LANG_HIP:
425 return {}; // return {{DW_LNAME_HIP, 0}};
426 case DW_LANG_Java:
427 return {{DW_LNAME_Java, 0}};
428 case DW_LANG_Julia:
429 return {{DW_LNAME_Julia, 0}};
430 case DW_LANG_Kotlin:
431 return {{DW_LNAME_Kotlin, 0}};
432 case DW_LANG_Modula2:
433 return {{DW_LNAME_Modula2, 0}};
434 case DW_LANG_Modula3:
435 return {{DW_LNAME_Modula3, 0}};
436 case DW_LANG_ObjC:
437 return {{DW_LNAME_ObjC, 0}};
438 case DW_LANG_ObjC_plus_plus:
439 return {{DW_LNAME_ObjC_plus_plus, 0}};
440 case DW_LANG_OCaml:
441 return {{DW_LNAME_OCaml, 0}};
442 case DW_LANG_OpenCL:
443 return {{DW_LNAME_OpenCL_C, 0}};
444 case DW_LANG_Pascal83:
445 return {{DW_LNAME_Pascal, 1983}};
446 case DW_LANG_PLI:
447 return {{DW_LNAME_PLI, 0}};
448 case DW_LANG_Python:
449 return {{DW_LNAME_Python, 0}};
450 case DW_LANG_RenderScript:
451 case DW_LANG_GOOGLE_RenderScript:
452 return {{DW_LNAME_RenderScript, 0}};
453 case DW_LANG_Rust:
454 return {{DW_LNAME_Rust, 0}};
455 case DW_LANG_Swift:
456 return {{DW_LNAME_Swift, 0}};
457 case DW_LANG_UPC:
458 return {{DW_LNAME_UPC, 0}};
459 case DW_LANG_Zig:
460 return {{DW_LNAME_Zig, 0}};
461 case DW_LANG_Assembly:
462 case DW_LANG_Mips_Assembler:
463 return {{DW_LNAME_Assembly, 0}};
464 case DW_LANG_C_sharp:
465 return {{DW_LNAME_C_sharp, 0}};
466 case DW_LANG_Mojo:
467 return {{DW_LNAME_Mojo, 0}};
468 case DW_LANG_GLSL:
469 return {{DW_LNAME_GLSL, 0}};
470 case DW_LANG_GLSL_ES:
471 return {{DW_LNAME_GLSL_ES, 0}};
472 case DW_LANG_HLSL:
473 return {{DW_LNAME_HLSL, 0}};
474 case DW_LANG_OpenCL_CPP:
475 return {{DW_LNAME_OpenCL_CPP, 0}};
476 case DW_LANG_SYCL:
477 return {{DW_LNAME_SYCL, 0}};
478 case DW_LANG_Ruby:
479 return {{DW_LNAME_Ruby, 0}};
480 case DW_LANG_Move:
481 return {{DW_LNAME_Move, 0}};
482 case DW_LANG_Hylo:
483 return {{DW_LNAME_Hylo, 0}};
484 case DW_LANG_Metal:
485 return {{DW_LNAME_Metal, 0}};
486 case DW_LANG_BORLAND_Delphi:
487 case DW_LANG_CPP_for_OpenCL:
488 case DW_LANG_lo_user:
489 case DW_LANG_hi_user:
490 return {};
491 }
492 return {};
493}
494
496
498 bool result = false;
499 // Deliberately enumerate all the language options so we get a warning when
500 // new language options are added (-Wswitch) that'll hopefully help keep this
501 // switch up-to-date when new C++ versions are added.
502 switch (S) {
503 case DW_LANG_C_plus_plus:
504 case DW_LANG_C_plus_plus_03:
505 case DW_LANG_C_plus_plus_11:
506 case DW_LANG_C_plus_plus_14:
507 case DW_LANG_C_plus_plus_17:
508 case DW_LANG_C_plus_plus_20:
509 result = true;
510 break;
511 case DW_LANG_C89:
512 case DW_LANG_C:
513 case DW_LANG_Ada83:
514 case DW_LANG_Cobol74:
515 case DW_LANG_Cobol85:
516 case DW_LANG_Fortran77:
517 case DW_LANG_Fortran90:
518 case DW_LANG_Pascal83:
519 case DW_LANG_Modula2:
520 case DW_LANG_Java:
521 case DW_LANG_C99:
522 case DW_LANG_Ada95:
523 case DW_LANG_Fortran95:
524 case DW_LANG_PLI:
525 case DW_LANG_ObjC:
526 case DW_LANG_ObjC_plus_plus:
527 case DW_LANG_UPC:
528 case DW_LANG_D:
529 case DW_LANG_Python:
530 case DW_LANG_OpenCL:
531 case DW_LANG_Go:
532 case DW_LANG_Modula3:
533 case DW_LANG_Haskell:
534 case DW_LANG_OCaml:
535 case DW_LANG_Rust:
536 case DW_LANG_C11:
537 case DW_LANG_Swift:
538 case DW_LANG_Julia:
539 case DW_LANG_Dylan:
540 case DW_LANG_Fortran03:
541 case DW_LANG_Fortran08:
542 case DW_LANG_RenderScript:
543 case DW_LANG_BLISS:
544 case DW_LANG_Mips_Assembler:
545 case DW_LANG_GOOGLE_RenderScript:
546 case DW_LANG_BORLAND_Delphi:
547 case DW_LANG_lo_user:
548 case DW_LANG_hi_user:
549 case DW_LANG_Kotlin:
550 case DW_LANG_Zig:
551 case DW_LANG_Crystal:
552 case DW_LANG_C17:
553 case DW_LANG_Fortran18:
554 case DW_LANG_Ada2005:
555 case DW_LANG_Ada2012:
556 case DW_LANG_HIP:
557 case DW_LANG_Assembly:
558 case DW_LANG_C_sharp:
559 case DW_LANG_Mojo:
560 case DW_LANG_GLSL:
561 case DW_LANG_GLSL_ES:
562 case DW_LANG_HLSL:
563 case DW_LANG_OpenCL_CPP:
564 case DW_LANG_CPP_for_OpenCL:
565 case DW_LANG_SYCL:
566 case DW_LANG_Ruby:
567 case DW_LANG_Move:
568 case DW_LANG_Hylo:
569 case DW_LANG_Metal:
570 result = false;
571 break;
572 }
573
574 return result;
575}
576
577inline bool isFortran(SourceLanguage S) {
578 bool result = false;
579 // Deliberately enumerate all the language options so we get a warning when
580 // new language options are added (-Wswitch) that'll hopefully help keep this
581 // switch up-to-date when new Fortran versions are added.
582 switch (S) {
583 case DW_LANG_Fortran77:
584 case DW_LANG_Fortran90:
585 case DW_LANG_Fortran95:
586 case DW_LANG_Fortran03:
587 case DW_LANG_Fortran08:
588 case DW_LANG_Fortran18:
589 result = true;
590 break;
591 case DW_LANG_C89:
592 case DW_LANG_C:
593 case DW_LANG_Ada83:
594 case DW_LANG_C_plus_plus:
595 case DW_LANG_Cobol74:
596 case DW_LANG_Cobol85:
597 case DW_LANG_Pascal83:
598 case DW_LANG_Modula2:
599 case DW_LANG_Java:
600 case DW_LANG_C99:
601 case DW_LANG_Ada95:
602 case DW_LANG_PLI:
603 case DW_LANG_ObjC:
604 case DW_LANG_ObjC_plus_plus:
605 case DW_LANG_UPC:
606 case DW_LANG_D:
607 case DW_LANG_Python:
608 case DW_LANG_OpenCL:
609 case DW_LANG_Go:
610 case DW_LANG_Modula3:
611 case DW_LANG_Haskell:
612 case DW_LANG_C_plus_plus_03:
613 case DW_LANG_C_plus_plus_11:
614 case DW_LANG_OCaml:
615 case DW_LANG_Rust:
616 case DW_LANG_C11:
617 case DW_LANG_Swift:
618 case DW_LANG_Julia:
619 case DW_LANG_Dylan:
620 case DW_LANG_C_plus_plus_14:
621 case DW_LANG_RenderScript:
622 case DW_LANG_BLISS:
623 case DW_LANG_Mips_Assembler:
624 case DW_LANG_GOOGLE_RenderScript:
625 case DW_LANG_BORLAND_Delphi:
626 case DW_LANG_lo_user:
627 case DW_LANG_hi_user:
628 case DW_LANG_Kotlin:
629 case DW_LANG_Zig:
630 case DW_LANG_Crystal:
631 case DW_LANG_C_plus_plus_17:
632 case DW_LANG_C_plus_plus_20:
633 case DW_LANG_C17:
634 case DW_LANG_Ada2005:
635 case DW_LANG_Ada2012:
636 case DW_LANG_HIP:
637 case DW_LANG_Assembly:
638 case DW_LANG_C_sharp:
639 case DW_LANG_Mojo:
640 case DW_LANG_GLSL:
641 case DW_LANG_GLSL_ES:
642 case DW_LANG_HLSL:
643 case DW_LANG_OpenCL_CPP:
644 case DW_LANG_CPP_for_OpenCL:
645 case DW_LANG_SYCL:
646 case DW_LANG_Ruby:
647 case DW_LANG_Move:
648 case DW_LANG_Hylo:
649 case DW_LANG_Metal:
650 result = false;
651 break;
652 }
653
654 return result;
655}
656
657inline bool isC(SourceLanguage S) {
658 // Deliberately enumerate all the language options so we get a warning when
659 // new language options are added (-Wswitch) that'll hopefully help keep this
660 // switch up-to-date when new C++ versions are added.
661 switch (S) {
662 case DW_LANG_C11:
663 case DW_LANG_C17:
664 case DW_LANG_C89:
665 case DW_LANG_C99:
666 case DW_LANG_C:
667 case DW_LANG_ObjC:
668 return true;
669 case DW_LANG_C_plus_plus:
670 case DW_LANG_C_plus_plus_03:
671 case DW_LANG_C_plus_plus_11:
672 case DW_LANG_C_plus_plus_14:
673 case DW_LANG_C_plus_plus_17:
674 case DW_LANG_C_plus_plus_20:
675 case DW_LANG_Ada83:
676 case DW_LANG_Cobol74:
677 case DW_LANG_Cobol85:
678 case DW_LANG_Fortran77:
679 case DW_LANG_Fortran90:
680 case DW_LANG_Pascal83:
681 case DW_LANG_Modula2:
682 case DW_LANG_Java:
683 case DW_LANG_Ada95:
684 case DW_LANG_Fortran95:
685 case DW_LANG_PLI:
686 case DW_LANG_ObjC_plus_plus:
687 case DW_LANG_UPC:
688 case DW_LANG_D:
689 case DW_LANG_Python:
690 case DW_LANG_OpenCL:
691 case DW_LANG_Go:
692 case DW_LANG_Modula3:
693 case DW_LANG_Haskell:
694 case DW_LANG_OCaml:
695 case DW_LANG_Rust:
696 case DW_LANG_Swift:
697 case DW_LANG_Julia:
698 case DW_LANG_Dylan:
699 case DW_LANG_Fortran03:
700 case DW_LANG_Fortran08:
701 case DW_LANG_RenderScript:
702 case DW_LANG_BLISS:
703 case DW_LANG_Mips_Assembler:
704 case DW_LANG_GOOGLE_RenderScript:
705 case DW_LANG_BORLAND_Delphi:
706 case DW_LANG_lo_user:
707 case DW_LANG_hi_user:
708 case DW_LANG_Kotlin:
709 case DW_LANG_Zig:
710 case DW_LANG_Crystal:
711 case DW_LANG_Fortran18:
712 case DW_LANG_Ada2005:
713 case DW_LANG_Ada2012:
714 case DW_LANG_HIP:
715 case DW_LANG_Assembly:
716 case DW_LANG_C_sharp:
717 case DW_LANG_Mojo:
718 case DW_LANG_GLSL:
719 case DW_LANG_GLSL_ES:
720 case DW_LANG_HLSL:
721 case DW_LANG_OpenCL_CPP:
722 case DW_LANG_CPP_for_OpenCL:
723 case DW_LANG_SYCL:
724 case DW_LANG_Ruby:
725 case DW_LANG_Move:
726 case DW_LANG_Hylo:
727 case DW_LANG_Metal:
728 return false;
729 }
730 llvm_unreachable("Unknown language kind.");
731}
732
734 return isFortran(S) ? DW_ATE_signed : DW_ATE_unsigned;
735}
736
738 // Identifier case codes
744
746// Calling convention codes
747#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
748#include "llvm/BinaryFormat/Dwarf.def"
750 DW_CC_hi_user = 0xff
752
754 // Inline codes
760
762 // Array ordering
764 DW_ORD_col_major = 0x01
766
768 // Discriminant descriptor values
770 DW_DSC_range = 0x01
772
773/// Line Number Standard Opcode Encodings.
775#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
776#include "llvm/BinaryFormat/Dwarf.def"
777};
778
779/// Line Number Extended Opcode Encodings.
781#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
782#include "llvm/BinaryFormat/Dwarf.def"
784 DW_LNE_hi_user = 0xff
786
788#define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID,
789#include "llvm/BinaryFormat/Dwarf.def"
792};
793
795 // Macinfo Type Encodings
802
803/// DWARF v5 macro information entry type encodings.
805#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
806#include "llvm/BinaryFormat/Dwarf.def"
808 DW_MACRO_hi_user = 0xff
810
811/// GNU .debug_macro macro information entry type encodings.
813#define HANDLE_DW_MACRO_GNU(ID, NAME) DW_MACRO_GNU_##NAME = ID,
814#include "llvm/BinaryFormat/Dwarf.def"
818
819/// DWARF v5 range list entry encoding values.
821#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
822#include "llvm/BinaryFormat/Dwarf.def"
823};
824
825/// DWARF v5 loc list entry encoding values.
827#define HANDLE_DW_LLE(ID, NAME) DW_LLE_##NAME = ID,
828#include "llvm/BinaryFormat/Dwarf.def"
829};
830
831/// Call frame instruction encodings.
833#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
834#define HANDLE_DW_CFA_PRED(ID, NAME, ARCH) DW_CFA_##NAME = ID,
835#include "llvm/BinaryFormat/Dwarf.def"
837
839 DW_CFA_hi_user = 0x3f
841
843 // Children flag
846
863 DW_EH_PE_indirect = 0x80
865
866/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
867/// Keep this list in sync with clang's DeclObjCCommon.h
868/// ObjCPropertyAttribute::Kind!
870#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
871#include "llvm/BinaryFormat/Dwarf.def"
872};
873
874/// Constants for unit types in DWARF v5.
875enum UnitType : unsigned char {
876#define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID,
877#include "llvm/BinaryFormat/Dwarf.def"
879 DW_UT_hi_user = 0xff
881
882enum Index {
883#define HANDLE_DW_IDX(ID, NAME) DW_IDX_##NAME = ID,
884#include "llvm/BinaryFormat/Dwarf.def"
886 DW_IDX_hi_user = 0x3fff
888
890 switch (UnitType) {
891 case DW_UT_compile:
892 case DW_UT_type:
893 case DW_UT_partial:
894 case DW_UT_skeleton:
895 case DW_UT_split_compile:
896 case DW_UT_split_type:
897 return true;
898 default:
899 return false;
900 }
901}
902
903inline bool isUnitType(dwarf::Tag T) {
904 switch (T) {
905 case DW_TAG_compile_unit:
906 case DW_TAG_type_unit:
907 case DW_TAG_partial_unit:
908 case DW_TAG_skeleton_unit:
909 return true;
910 default:
911 return false;
912 }
913}
914
915// Constants for the DWARF v5 Accelerator Table Proposal
917 // Data layout descriptors.
918 DW_ATOM_null = 0u, /// Marker as the end of a list of atoms.
919 DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
920 DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
921 // item in question.
922 DW_ATOM_die_tag = 3u, // A tag entry.
923 DW_ATOM_type_flags = 4u, // Set of flags for a type.
924
925 DW_ATOM_type_type_flags = 5u, // Dsymutil type extension.
926 DW_ATOM_qual_name_hash = 6u, // Dsymutil qualified hash extension.
927
928 // DW_ATOM_type_flags values.
929
930 // Always set for C++, only set for ObjC if this is the @implementation for a
931 // class.
933
934 // Hash functions.
935
936 // Daniel J. Bernstein hash.
939
940// Return a suggested bucket count for the DWARF v5 Accelerator Table.
942 if (UniqueHashCount > 1024)
943 return UniqueHashCount / 4;
944 if (UniqueHashCount > 16)
945 return UniqueHashCount / 2;
946 return std::max<uint32_t>(UniqueHashCount, 1);
947}
948
949// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
960
962
963/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
964///
965/// All these functions map their argument's value back to the
966/// corresponding enumerator name or return an empty StringRef if the value
967/// isn't known.
968///
969/// @{
970StringRef TagString(unsigned Tag);
971StringRef ChildrenString(unsigned Children);
973StringRef FormEncodingString(unsigned Encoding);
974StringRef OperationEncodingString(unsigned Encoding);
975StringRef SubOperationEncodingString(unsigned OpEncoding,
976 unsigned SubOpEncoding);
977StringRef AttributeEncodingString(unsigned Encoding);
978StringRef DecimalSignString(unsigned Sign);
981StringRef DefaultedMemberString(unsigned DefaultedEncodings);
982StringRef VisibilityString(unsigned Visibility);
983StringRef VirtualityString(unsigned Virtuality);
984StringRef LanguageString(unsigned Language);
985StringRef CaseString(unsigned Case);
986StringRef ConventionString(unsigned Convention);
987StringRef InlineCodeString(unsigned Code);
988StringRef ArrayOrderString(unsigned Order);
989StringRef LNStandardString(unsigned Standard);
990StringRef LNExtendedString(unsigned Encoding);
991StringRef MacinfoString(unsigned Encoding);
992StringRef MacroString(unsigned Encoding);
993StringRef GnuMacroString(unsigned Encoding);
994StringRef RangeListEncodingString(unsigned Encoding);
995StringRef LocListEncodingString(unsigned Encoding);
996StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch);
998StringRef UnitTypeString(unsigned);
999StringRef AtomTypeString(unsigned Atom);
1002StringRef IndexString(unsigned Idx);
1004StringRef FormatString(bool IsDWARF64);
1005StringRef RLEString(unsigned RLE);
1006/// @}
1007
1008/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
1009///
1010/// These functions map their strings back to the corresponding enumeration
1011/// value or return 0 if there is none, except for these exceptions:
1012///
1013/// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
1014/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
1015/// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
1016///
1017/// @{
1018unsigned getTag(StringRef TagString);
1020unsigned getSubOperationEncoding(unsigned OpEncoding,
1025unsigned getAttributeEncoding(StringRef EncodingString);
1028/// @}
1029
1030/// \defgroup DwarfConstantsVersioning Dwarf version for constants
1031///
1032/// For constants defined by DWARF, returns the DWARF version when the constant
1033/// was first defined. For vendor extensions, if there is a version-related
1034/// policy for when to emit it, returns a version number for that policy.
1035/// Otherwise returns 0.
1036///
1037/// @{
1038unsigned TagVersion(Tag T);
1039unsigned AttributeVersion(Attribute A);
1040unsigned FormVersion(Form F);
1041unsigned OperationVersion(LocationAtom O);
1044/// @}
1045
1046/// \defgroup DwarfConstantsVendor Dwarf "vendor" for constants
1047///
1048/// These functions return an identifier describing "who" defined the constant,
1049/// either the DWARF standard itself or the vendor who defined the extension.
1050///
1051/// @{
1052unsigned TagVendor(Tag T);
1053unsigned AttributeVendor(Attribute A);
1054unsigned FormVendor(Form F);
1055unsigned OperationVendor(LocationAtom O);
1057unsigned LanguageVendor(SourceLanguage L);
1058/// @}
1059
1060/// The number of operands for the given LocationAtom.
1061std::optional<unsigned> OperationOperands(LocationAtom O);
1062
1063/// The arity of the given LocationAtom. This is the number of elements on the
1064/// stack this operation operates on. Returns -1 if the arity is variable (e.g.
1065/// depending on the argument) or unknown.
1066std::optional<unsigned> OperationArity(LocationAtom O);
1067
1068std::optional<unsigned> LanguageLowerBound(SourceLanguage L);
1069
1070/// The size of a reference determined by the DWARF 32/64-bit format.
1072 switch (Format) {
1074 return 4;
1076 return 8;
1077 }
1078 llvm_unreachable("Invalid Format value");
1079}
1080
1081/// A helper struct providing information about the byte size of DW_FORM
1082/// values that vary in size depending on the DWARF version, address byte
1083/// size, or DWARF32/DWARF64.
1088 /// True if DWARF v2 output generally uses relocations for references
1089 /// to other .debug_* sections.
1091
1092 /// The definition of the size of form DW_FORM_ref_addr depends on the
1093 /// version. In DWARF v2 it's the size of an address; after that, it's the
1094 /// size of a reference.
1096 if (Version == 2)
1097 return AddrSize;
1098 return getDwarfOffsetByteSize();
1099 }
1100
1101 /// The size of a reference is determined by the DWARF 32/64-bit format.
1104 }
1105
1106 explicit operator bool() const { return Version && AddrSize; }
1107};
1108
1109/// Get the byte size of the unit length field depending on the DWARF format.
1111 switch (Format) {
1113 return 4;
1115 return 12;
1116 }
1117 llvm_unreachable("Invalid Format value");
1118}
1119
1120/// Get the fixed byte size for a given form.
1121///
1122/// If the form has a fixed byte size, then an Optional with a value will be
1123/// returned. If the form is always encoded using a variable length storage
1124/// format (ULEB or SLEB numbers or blocks) then std::nullopt will be returned.
1125///
1126/// \param Form DWARF form to get the fixed byte size for.
1127/// \param Params DWARF parameters to help interpret forms.
1128/// \returns std::optional<uint8_t> value with the fixed byte size or
1129/// std::nullopt if \p Form doesn't have a fixed byte size.
1130std::optional<uint8_t> getFixedFormByteSize(dwarf::Form Form,
1131 FormParams Params);
1132
1133/// Tells whether the specified form is defined in the specified version,
1134/// or is an extension if extensions are allowed.
1135bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk = true);
1136
1137/// Returns the symbolic string representing Val when used as a value
1138/// for attribute Attr.
1139StringRef AttributeValueString(uint16_t Attr, unsigned Val);
1140
1141/// Returns the symbolic string representing Val when used as a value
1142/// for atom Atom.
1143StringRef AtomValueString(uint16_t Atom, unsigned Val);
1144
1145/// Describes an entry of the various gnu_pub* debug sections.
1146///
1147/// The gnu_pub* kind looks like:
1148///
1149/// 0-3 reserved
1150/// 4-6 symbol kind
1151/// 7 0 == global, 1 == static
1152///
1153/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
1154/// offset of the cu within the debug_info section stored in those 24 bits.
1159 : Kind(Kind), Linkage(Linkage) {}
1163 : Kind(
1164 static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> KIND_OFFSET)),
1165 Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
1166 LINKAGE_OFFSET)) {}
1167 uint8_t toBits() const {
1168 return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET;
1169 }
1170
1171private:
1172 enum {
1173 KIND_OFFSET = 4,
1174 KIND_MASK = 7 << KIND_OFFSET,
1175 LINKAGE_OFFSET = 7,
1176 LINKAGE_MASK = 1 << LINKAGE_OFFSET
1177 };
1178};
1179
1180template <typename Enum> struct EnumTraits : public std::false_type {};
1181
1182template <> struct EnumTraits<Attribute> : public std::true_type {
1183 static constexpr char Type[3] = "AT";
1184 static constexpr StringRef (*StringFn)(unsigned) = &AttributeString;
1185};
1186
1187template <> struct EnumTraits<Form> : public std::true_type {
1188 static constexpr char Type[5] = "FORM";
1189 static constexpr StringRef (*StringFn)(unsigned) = &FormEncodingString;
1190};
1191
1192template <> struct EnumTraits<Index> : public std::true_type {
1193 static constexpr char Type[4] = "IDX";
1194 static constexpr StringRef (*StringFn)(unsigned) = &IndexString;
1195};
1196
1197template <> struct EnumTraits<Tag> : public std::true_type {
1198 static constexpr char Type[4] = "TAG";
1199 static constexpr StringRef (*StringFn)(unsigned) = &TagString;
1200};
1201
1202template <> struct EnumTraits<LineNumberOps> : public std::true_type {
1203 static constexpr char Type[4] = "LNS";
1204 static constexpr StringRef (*StringFn)(unsigned) = &LNStandardString;
1205};
1206
1207template <> struct EnumTraits<LocationAtom> : public std::true_type {
1208 static constexpr char Type[3] = "OP";
1209 static constexpr StringRef (*StringFn)(unsigned) = &OperationEncodingString;
1210};
1211
1213 return std::numeric_limits<uint64_t>::max() >> (8 - AddressByteSize) * 8;
1214}
1215
1216} // End of namespace dwarf
1217
1218/// Dwarf constants format_provider
1219///
1220/// Specialization of the format_provider template for dwarf enums. Unlike the
1221/// dumping functions above, these format unknown enumerator values as
1222/// DW_TYPE_unknown_1234 (e.g. DW_TAG_unknown_ffff).
1223template <typename Enum>
1224struct format_provider<Enum, std::enable_if_t<dwarf::EnumTraits<Enum>::value>> {
1225 static void format(const Enum &E, raw_ostream &OS, StringRef Style) {
1227 if (Str.empty()) {
1228 OS << "DW_" << dwarf::EnumTraits<Enum>::Type << "_unknown_"
1229 << llvm::format("%x", E);
1230 } else
1231 OS << Str;
1232 }
1233};
1234} // End of namespace llvm
1235
1236#endif
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DXIL Finalize Linkage
DXIL Resource Access
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define F(x, y, z)
Definition: MD5.cpp:55
static const char * name
Definition: SMEABIPass.cpp:46
endianness Endian
raw_pwrite_stream & OS
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
StringRef LNExtendedString(unsigned Encoding)
Definition: Dwarf.cpp:523
StringRef RangeListEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:591
StringRef CaseString(unsigned Case)
Definition: Dwarf.cpp:456
StringRef VisibilityString(unsigned Visibility)
Definition: Dwarf.cpp:362
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition: Dwarf.cpp:706
StringRef AttributeString(unsigned Attribute)
Definition: Dwarf.cpp:72
StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch)
Definition: Dwarf.cpp:613
StringRef FormEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:105
StringRef ArrayOrderString(unsigned Order)
Definition: Dwarf.cpp:502
StringRef MacroString(unsigned Encoding)
Definition: Dwarf.cpp:563
StringRef LocListEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:602
StringRef IndexString(unsigned Idx)
Definition: Dwarf.cpp:760
StringRef RLEString(unsigned RLE)
Definition: Dwarf.cpp:882
StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
Definition: Dwarf.cpp:202
StringRef LanguageString(unsigned Language)
Definition: Dwarf.cpp:393
StringRef DecimalSignString(unsigned Sign)
Definition: Dwarf.cpp:304
StringRef VirtualityString(unsigned Virtuality)
Definition: Dwarf.cpp:374
StringRef AttributeEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:263
StringRef ChildrenString(unsigned Children)
Definition: Dwarf.cpp:62
StringRef ApplePropertyString(unsigned)
Definition: Dwarf.cpp:642
StringRef AtomTypeString(unsigned Atom)
Definition: Dwarf.cpp:664
StringRef FormatString(DwarfFormat Format)
Definition: Dwarf.cpp:868
StringRef GnuMacroString(unsigned Encoding)
Definition: Dwarf.cpp:574
StringRef EndianityString(unsigned Endian)
Definition: Dwarf.cpp:320
StringRef ConventionString(unsigned Convention)
Definition: Dwarf.cpp:470
StringRef MacinfoString(unsigned Encoding)
Definition: Dwarf.cpp:534
StringRef OperationEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:138
StringRef UnitTypeString(unsigned)
Definition: Dwarf.cpp:653
StringRef InlineCodeString(unsigned Code)
Definition: Dwarf.cpp:488
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition: Dwarf.cpp:683
StringRef TagString(unsigned Tag)
Definition: Dwarf.cpp:21
StringRef LNStandardString(unsigned Standard)
Definition: Dwarf.cpp:512
StringRef AccessibilityString(unsigned Access)
Definition: Dwarf.cpp:336
StringRef DefaultedMemberString(unsigned DefaultedEncodings)
Definition: Dwarf.cpp:349
unsigned getSubOperationEncoding(unsigned OpEncoding, StringRef SubOperationEncodingString)
Definition: Dwarf.cpp:209
unsigned getOperationEncoding(StringRef OperationEncodingString)
Definition: Dwarf.cpp:165
unsigned getAttributeEncoding(StringRef EncodingString)
Definition: Dwarf.cpp:274
unsigned getTag(StringRef TagString)
Definition: Dwarf.cpp:32
unsigned getCallingConvention(StringRef LanguageString)
Definition: Dwarf.cpp:481
unsigned getLanguage(StringRef LanguageString)
Definition: Dwarf.cpp:404
unsigned getVirtuality(StringRef VirtualityString)
Definition: Dwarf.cpp:385
unsigned getMacro(StringRef MacroString)
Definition: Dwarf.cpp:585
unsigned getMacinfo(StringRef MacinfoString)
Definition: Dwarf.cpp:553
unsigned AttributeEncodingVendor(TypeKind E)
Definition: Dwarf.cpp:293
unsigned FormVendor(Form F)
Definition: Dwarf.cpp:127
unsigned AttributeVendor(Attribute A)
Definition: Dwarf.cpp:94
unsigned OperationVendor(LocationAtom O)
Definition: Dwarf.cpp:252
unsigned TagVendor(Tag T)
Definition: Dwarf.cpp:51
unsigned LanguageVendor(SourceLanguage L)
Definition: Dwarf.cpp:423
unsigned OperationVersion(LocationAtom O)
Definition: Dwarf.cpp:215
unsigned AttributeVersion(Attribute A)
Definition: Dwarf.cpp:83
unsigned LanguageVersion(SourceLanguage L)
Definition: Dwarf.cpp:412
unsigned AttributeEncodingVersion(TypeKind E)
Definition: Dwarf.cpp:282
unsigned TagVersion(Tag T)
Definition: Dwarf.cpp:40
unsigned FormVersion(Form F)
Definition: Dwarf.cpp:116
#define UINT64_MAX
Definition: DataTypes.h:77
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
InlineAttribute
Definition: Dwarf.h:753
@ DW_INL_not_inlined
Definition: Dwarf.h:755
@ DW_INL_declared_not_inlined
Definition: Dwarf.h:757
@ DW_INL_inlined
Definition: Dwarf.h:756
@ DW_INL_declared_inlined
Definition: Dwarf.h:758
const uint32_t DW_CIE_ID
Special ID values that distinguish a CIE from a FDE in DWARF CFI.
Definition: Dwarf.h:96
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
Definition: Dwarf.h:1110
AccessAttribute
Definition: Dwarf.h:181
@ DW_ACCESS_private
Definition: Dwarf.h:185
@ DW_ACCESS_protected
Definition: Dwarf.h:184
@ DW_ACCESS_public
Definition: Dwarf.h:183
MacroEntryType
DWARF v5 macro information entry type encodings.
Definition: Dwarf.h:804
@ DW_MACRO_lo_user
Definition: Dwarf.h:807
@ DW_MACRO_hi_user
Definition: Dwarf.h:808
Attribute
Attributes.
Definition: Dwarf.h:123
@ DW_AT_hi_user
Definition: Dwarf.h:127
@ DW_AT_lo_user
Definition: Dwarf.h:126
std::optional< unsigned > LanguageLowerBound(SourceLanguage L)
Definition: Dwarf.cpp:435
LineNumberEntryFormat
Definition: Dwarf.h:787
@ DW_LNCT_lo_user
Definition: Dwarf.h:790
@ DW_LNCT_hi_user
Definition: Dwarf.h:791
StringRef AtomValueString(uint16_t Atom, unsigned Val)
Returns the symbolic string representing Val when used as a value for atom Atom.
Definition: Dwarf.cpp:749
DefaultedMemberAttribute
Definition: Dwarf.h:201
@ DW_DEFAULTED_max
Definition: Dwarf.h:204
SourceLanguageName
Definition: Dwarf.h:215
const uint64_t DW64_CIE_ID
Definition: Dwarf.h:97
std::optional< unsigned > OperationArity(LocationAtom O)
The arity of the given LocationAtom.
Definition: Dwarf.cpp:239
VisibilityAttribute
Definition: Dwarf.h:188
@ DW_VIS_local
Definition: Dwarf.h:190
@ DW_VIS_exported
Definition: Dwarf.h:191
@ DW_VIS_qualified
Definition: Dwarf.h:192
LlvmUserLocationAtom
Definition: Dwarf.h:152
ArrayDimensionOrdering
Definition: Dwarf.h:761
@ DW_ORD_row_major
Definition: Dwarf.h:763
@ DW_ORD_col_major
Definition: Dwarf.h:764
CallingConvention
Definition: Dwarf.h:745
@ DW_CC_lo_user
Definition: Dwarf.h:749
@ DW_CC_hi_user
Definition: Dwarf.h:750
LineNumberOps
Line Number Standard Opcode Encodings.
Definition: Dwarf.h:774
@ DW_ATE_hi_user
Definition: Dwarf.h:161
@ DW_ATE_lo_user
Definition: Dwarf.h:160
ApplePropertyAttributes
Constants for the DW_APPLE_PROPERTY_attributes attribute.
Definition: Dwarf.h:869
LoclistEntries
DWARF v5 loc list entry encoding values.
Definition: Dwarf.h:826
bool isFortran(SourceLanguage S)
Definition: Dwarf.h:577
bool isUnitType(uint8_t UnitType)
Definition: Dwarf.h:889
@ DW_IDX_lo_user
Definition: Dwarf.h:885
@ DW_IDX_hi_user
Definition: Dwarf.h:886
GnuMacroEntryType
GNU .debug_macro macro information entry type encodings.
Definition: Dwarf.h:812
@ DW_MACRO_GNU_lo_user
Definition: Dwarf.h:815
@ DW_MACRO_GNU_hi_user
Definition: Dwarf.h:816
UnitType
Constants for unit types in DWARF v5.
Definition: Dwarf.h:875
@ DW_UT_lo_user
Definition: Dwarf.h:878
@ DW_UT_hi_user
Definition: Dwarf.h:879
@ DW_FORM_lo_user
Not specified by DWARF.
Definition: Dwarf.h:133
EndianityEncoding
Definition: Dwarf.h:173
@ DW_END_lo_user
Definition: Dwarf.h:177
@ DW_END_hi_user
Definition: Dwarf.h:178
bool isType(Tag T)
Definition: Dwarf.h:111
LocationAtom
Definition: Dwarf.h:136
@ DW_OP_LLVM_entry_value
Only used in LLVM metadata.
Definition: Dwarf.h:145
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
Definition: Dwarf.h:146
@ DW_OP_LLVM_extract_bits_zext
Only used in LLVM metadata.
Definition: Dwarf.h:149
@ DW_OP_lo_user
Definition: Dwarf.h:140
@ DW_OP_hi_user
Definition: Dwarf.h:141
@ DW_OP_LLVM_tag_offset
Only used in LLVM metadata.
Definition: Dwarf.h:144
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
Definition: Dwarf.h:142
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
Definition: Dwarf.h:147
@ DW_OP_LLVM_convert
Only used in LLVM metadata.
Definition: Dwarf.h:143
@ DW_OP_LLVM_extract_bits_sext
Only used in LLVM metadata.
Definition: Dwarf.h:148
SourceLanguage
Definition: Dwarf.h:207
@ DW_LANG_lo_user
Definition: Dwarf.h:211
@ DW_LANG_hi_user
Definition: Dwarf.h:212
CaseSensitivity
Definition: Dwarf.h:737
@ DW_ID_down_case
Definition: Dwarf.h:741
@ DW_ID_case_insensitive
Definition: Dwarf.h:742
@ DW_ID_case_sensitive
Definition: Dwarf.h:739
@ DW_ID_up_case
Definition: Dwarf.h:740
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:91
@ DWARF64
Definition: Dwarf.h:91
@ DWARF32
Definition: Dwarf.h:91
bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk=true)
Tells whether the specified form is defined in the specified version, or is an extension if extension...
Definition: Dwarf.cpp:859
std::optional< SourceLanguage > toDW_LANG(SourceLanguageName name, uint32_t version)
Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
Definition: Dwarf.h:223
MacinfoRecordType
Definition: Dwarf.h:794
@ DW_MACINFO_undef
Definition: Dwarf.h:797
@ DW_MACINFO_start_file
Definition: Dwarf.h:798
@ DW_MACINFO_end_file
Definition: Dwarf.h:799
@ DW_MACINFO_define
Definition: Dwarf.h:796
@ DW_MACINFO_vendor_ext
Definition: Dwarf.h:800
const uint32_t DW_INVALID_OFFSET
Identifier of an invalid DIE offset in the .debug_info section.
Definition: Dwarf.h:101
RnglistEntries
DWARF v5 range list entry encoding values.
Definition: Dwarf.h:820
std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
Definition: Dwarf.cpp:771
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:1071
VirtualityAttribute
Definition: Dwarf.h:195
@ DW_VIRTUALITY_max
Definition: Dwarf.h:198
GDBIndexEntryKind
Definition: Dwarf.h:950
@ GIEK_NONE
Definition: Dwarf.h:951
@ GIEK_UNUSED7
Definition: Dwarf.h:958
@ GIEK_TYPE
Definition: Dwarf.h:952
@ GIEK_UNUSED6
Definition: Dwarf.h:957
@ GIEK_OTHER
Definition: Dwarf.h:955
@ GIEK_FUNCTION
Definition: Dwarf.h:954
@ GIEK_UNUSED5
Definition: Dwarf.h:956
@ GIEK_VARIABLE
Definition: Dwarf.h:953
LineNumberExtendedOps
Line Number Extended Opcode Encodings.
Definition: Dwarf.h:780
@ DW_LNE_hi_user
Definition: Dwarf.h:784
@ DW_LNE_lo_user
Definition: Dwarf.h:783
bool isCPlusPlus(SourceLanguage S)
Definition: Dwarf.h:497
@ DW_EH_PE_textrel
Definition: Dwarf.h:859
@ DW_CHILDREN_no
Definition: Dwarf.h:844
@ DW_EH_PE_datarel
Definition: Dwarf.h:860
@ DW_EH_PE_pcrel
Definition: Dwarf.h:858
@ DW_EH_PE_signed
Definition: Dwarf.h:857
@ DW_CHILDREN_yes
Definition: Dwarf.h:845
@ DW_EH_PE_sdata4
Definition: Dwarf.h:855
@ DW_EH_PE_funcrel
Definition: Dwarf.h:861
@ DW_EH_PE_aligned
Definition: Dwarf.h:862
@ DW_EH_PE_udata2
Definition: Dwarf.h:850
@ DW_EH_PE_sdata8
Definition: Dwarf.h:856
@ DW_EH_PE_absptr
Definition: Dwarf.h:847
@ DW_EH_PE_sdata2
Definition: Dwarf.h:854
@ DW_EH_PE_udata4
Definition: Dwarf.h:851
@ DW_EH_PE_udata8
Definition: Dwarf.h:852
@ DW_EH_PE_uleb128
Definition: Dwarf.h:849
@ DW_EH_PE_indirect
Definition: Dwarf.h:863
@ DW_EH_PE_sleb128
Definition: Dwarf.h:853
@ DW_EH_PE_omit
Definition: Dwarf.h:848
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
Definition: Dwarf.h:733
StringRef AttributeValueString(uint16_t Attr, unsigned Val)
Returns the symbolic string representing Val when used as a value for attribute Attr.
Definition: Dwarf.cpp:716
DiscriminantList
Definition: Dwarf.h:767
@ DW_DSC_range
Definition: Dwarf.h:770
@ DW_DSC_label
Definition: Dwarf.h:769
std::optional< unsigned > OperationOperands(LocationAtom O)
The number of operands for the given LocationAtom.
Definition: Dwarf.cpp:226
@ DW_TAG_user_base
Recommended base for user tags.
Definition: Dwarf.h:108
@ DW_TAG_hi_user
Definition: Dwarf.h:107
@ DW_TAG_lo_user
Definition: Dwarf.h:106
CallFrameInfo
Call frame instruction encodings.
Definition: Dwarf.h:832
@ DW_CFA_hi_user
Definition: Dwarf.h:839
@ DW_CFA_extended
Definition: Dwarf.h:836
@ DW_CFA_lo_user
Definition: Dwarf.h:838
DecimalSignEncoding
Definition: Dwarf.h:164
@ DW_DS_leading_separate
Definition: Dwarf.h:169
@ DW_DS_trailing_separate
Definition: Dwarf.h:170
@ DW_DS_trailing_overpunch
Definition: Dwarf.h:168
@ DW_DS_leading_overpunch
Definition: Dwarf.h:167
@ DW_DS_unsigned
Definition: Dwarf.h:166
uint32_t getDebugNamesBucketCount(uint32_t UniqueHashCount)
Definition: Dwarf.h:941
uint64_t computeTombstoneAddress(uint8_t AddressByteSize)
Definition: Dwarf.h:1212
llvm::StringRef LanguageDescription(SourceLanguageName name)
Definition: Dwarf.cpp:446
AcceleratorTable
Definition: Dwarf.h:916
@ DW_ATOM_type_flags
Definition: Dwarf.h:923
@ DW_ATOM_null
Definition: Dwarf.h:918
@ DW_ATOM_die_tag
Definition: Dwarf.h:922
@ DW_FLAG_type_implementation
Definition: Dwarf.h:932
@ DW_ATOM_qual_name_hash
Definition: Dwarf.h:926
@ DW_ATOM_die_offset
Marker as the end of a list of atoms.
Definition: Dwarf.h:919
@ DW_ATOM_type_type_flags
Definition: Dwarf.h:925
@ DW_ATOM_cu_offset
Definition: Dwarf.h:920
@ DW_hash_function_djb
Definition: Dwarf.h:937
bool isC(SourceLanguage S)
Definition: Dwarf.h:657
LLVMConstants
Definition: Dwarf.h:44
@ DWARF_VENDOR_COMPAQ
Definition: Dwarf.h:78
@ DWARF_VENDOR_LLVM
Definition: Dwarf.h:74
@ DWARF_VENDOR_WASM
Definition: Dwarf.h:76
@ DW_ARANGES_VERSION
Section version number for .debug_aranges.
Definition: Dwarf.h:64
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
Definition: Dwarf.h:63
@ DWARF_VENDOR_APPLE
Definition: Dwarf.h:70
@ DWARF_VERSION
Other constants.
Definition: Dwarf.h:61
@ DWARF_VENDOR_ALTIUM
Definition: Dwarf.h:77
@ DWARF_VENDOR_IBM
Definition: Dwarf.h:82
@ DWARF_VENDOR_GO
Definition: Dwarf.h:80
@ DWARF_VENDOR_SUN
Definition: Dwarf.h:85
@ DW_TAG_invalid
LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
Definition: Dwarf.h:47
@ DWARF_VENDOR_PGI
Definition: Dwarf.h:84
@ DWARF_VENDOR_HP
Definition: Dwarf.h:81
@ DWARF_VENDOR_INTEL
Definition: Dwarf.h:83
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
Definition: Dwarf.h:54
@ DW_MACINFO_invalid
Macinfo type for invalid results.
Definition: Dwarf.h:49
@ DWARF_VENDOR_UPC
Definition: Dwarf.h:86
@ DWARF_VENDOR_GNU
Definition: Dwarf.h:72
@ DW_VIRTUALITY_invalid
Virtuality for invalid results.
Definition: Dwarf.h:48
@ DW_LENGTH_hi_reserved
Upper bound of the reserved range.
Definition: Dwarf.h:56
@ DWARF_VENDOR_GOOGLE
Definition: Dwarf.h:73
@ DWARF_VENDOR_BORLAND
Definition: Dwarf.h:71
@ DWARF_VENDOR_GHS
Definition: Dwarf.h:79
@ DWARF_VENDOR_MIPS
Definition: Dwarf.h:75
@ DW_PUBTYPES_VERSION
Section version number for .debug_pubtypes.
Definition: Dwarf.h:62
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
Definition: Dwarf.h:55
@ DWARF_VENDOR_DWARF
Identifiers we use to distinguish vendor extensions.
Definition: Dwarf.h:69
GDBIndexEntryLinkage
Definition: Dwarf.h:961
@ GIEL_EXTERNAL
Definition: Dwarf.h:961
@ GIEL_STATIC
Definition: Dwarf.h:961
std::optional< std::pair< SourceLanguageName, uint32_t > > toDW_LNAME(SourceLanguage language)
Convert a DWARF 5 DW_LANG to a DWARF 6 pair of language name and version.
Definition: Dwarf.h:364
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:125
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:1084
bool DwarfUsesRelocationsAcrossSections
True if DWARF v2 output generally uses relocations for references to other .debug_* sections.
Definition: Dwarf.h:1090
DwarfFormat Format
Definition: Dwarf.h:1087
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition: Dwarf.h:1102
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition: Dwarf.h:1095
Describes an entry of the various gnu_pub* debug sections.
Definition: Dwarf.h:1155
PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
Definition: Dwarf.h:1158
PubIndexEntryDescriptor(uint8_t Value)
Definition: Dwarf.h:1162
PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
Definition: Dwarf.h:1160
GDBIndexEntryLinkage Linkage
Definition: Dwarf.h:1157
static void format(const Enum &E, raw_ostream &OS, StringRef Style)
Definition: Dwarf.h:1225