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