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
503/// Returns a version-independent language name.
505
506/// Returns a language name corresponding to the specified version.
507/// If the version is not recognized for the specified language, returns
508/// the version-independent name.
511
513 bool result = false;
514 // Deliberately enumerate all the language options so we get a warning when
515 // new language options are added (-Wswitch) that'll hopefully help keep this
516 // switch up-to-date when new C++ versions are added.
517 switch (S) {
518 case DW_LANG_C_plus_plus:
519 case DW_LANG_C_plus_plus_03:
520 case DW_LANG_C_plus_plus_11:
521 case DW_LANG_C_plus_plus_14:
522 case DW_LANG_C_plus_plus_17:
523 case DW_LANG_C_plus_plus_20:
524 result = true;
525 break;
526 case DW_LANG_C89:
527 case DW_LANG_C:
528 case DW_LANG_Ada83:
529 case DW_LANG_Cobol74:
530 case DW_LANG_Cobol85:
531 case DW_LANG_Fortran77:
532 case DW_LANG_Fortran90:
533 case DW_LANG_Pascal83:
534 case DW_LANG_Modula2:
535 case DW_LANG_Java:
536 case DW_LANG_C99:
537 case DW_LANG_Ada95:
538 case DW_LANG_Fortran95:
539 case DW_LANG_PLI:
540 case DW_LANG_ObjC:
541 case DW_LANG_ObjC_plus_plus:
542 case DW_LANG_UPC:
543 case DW_LANG_D:
544 case DW_LANG_Python:
545 case DW_LANG_OpenCL:
546 case DW_LANG_Go:
547 case DW_LANG_Modula3:
548 case DW_LANG_Haskell:
549 case DW_LANG_OCaml:
550 case DW_LANG_Rust:
551 case DW_LANG_C11:
552 case DW_LANG_Swift:
553 case DW_LANG_Julia:
554 case DW_LANG_Dylan:
555 case DW_LANG_Fortran03:
556 case DW_LANG_Fortran08:
557 case DW_LANG_RenderScript:
558 case DW_LANG_BLISS:
559 case DW_LANG_Mips_Assembler:
560 case DW_LANG_GOOGLE_RenderScript:
561 case DW_LANG_BORLAND_Delphi:
562 case DW_LANG_lo_user:
563 case DW_LANG_hi_user:
564 case DW_LANG_Kotlin:
565 case DW_LANG_Zig:
566 case DW_LANG_Crystal:
567 case DW_LANG_C17:
568 case DW_LANG_Fortran18:
569 case DW_LANG_Ada2005:
570 case DW_LANG_Ada2012:
571 case DW_LANG_HIP:
572 case DW_LANG_Assembly:
573 case DW_LANG_C_sharp:
574 case DW_LANG_Mojo:
575 case DW_LANG_GLSL:
576 case DW_LANG_GLSL_ES:
577 case DW_LANG_HLSL:
578 case DW_LANG_OpenCL_CPP:
579 case DW_LANG_CPP_for_OpenCL:
580 case DW_LANG_SYCL:
581 case DW_LANG_Ruby:
582 case DW_LANG_Move:
583 case DW_LANG_Hylo:
584 case DW_LANG_Metal:
585 result = false;
586 break;
587 }
588
589 return result;
590}
591
592inline bool isFortran(SourceLanguage S) {
593 bool result = false;
594 // Deliberately enumerate all the language options so we get a warning when
595 // new language options are added (-Wswitch) that'll hopefully help keep this
596 // switch up-to-date when new Fortran versions are added.
597 switch (S) {
598 case DW_LANG_Fortran77:
599 case DW_LANG_Fortran90:
600 case DW_LANG_Fortran95:
601 case DW_LANG_Fortran03:
602 case DW_LANG_Fortran08:
603 case DW_LANG_Fortran18:
604 result = true;
605 break;
606 case DW_LANG_C89:
607 case DW_LANG_C:
608 case DW_LANG_Ada83:
609 case DW_LANG_C_plus_plus:
610 case DW_LANG_Cobol74:
611 case DW_LANG_Cobol85:
612 case DW_LANG_Pascal83:
613 case DW_LANG_Modula2:
614 case DW_LANG_Java:
615 case DW_LANG_C99:
616 case DW_LANG_Ada95:
617 case DW_LANG_PLI:
618 case DW_LANG_ObjC:
619 case DW_LANG_ObjC_plus_plus:
620 case DW_LANG_UPC:
621 case DW_LANG_D:
622 case DW_LANG_Python:
623 case DW_LANG_OpenCL:
624 case DW_LANG_Go:
625 case DW_LANG_Modula3:
626 case DW_LANG_Haskell:
627 case DW_LANG_C_plus_plus_03:
628 case DW_LANG_C_plus_plus_11:
629 case DW_LANG_OCaml:
630 case DW_LANG_Rust:
631 case DW_LANG_C11:
632 case DW_LANG_Swift:
633 case DW_LANG_Julia:
634 case DW_LANG_Dylan:
635 case DW_LANG_C_plus_plus_14:
636 case DW_LANG_RenderScript:
637 case DW_LANG_BLISS:
638 case DW_LANG_Mips_Assembler:
639 case DW_LANG_GOOGLE_RenderScript:
640 case DW_LANG_BORLAND_Delphi:
641 case DW_LANG_lo_user:
642 case DW_LANG_hi_user:
643 case DW_LANG_Kotlin:
644 case DW_LANG_Zig:
645 case DW_LANG_Crystal:
646 case DW_LANG_C_plus_plus_17:
647 case DW_LANG_C_plus_plus_20:
648 case DW_LANG_C17:
649 case DW_LANG_Ada2005:
650 case DW_LANG_Ada2012:
651 case DW_LANG_HIP:
652 case DW_LANG_Assembly:
653 case DW_LANG_C_sharp:
654 case DW_LANG_Mojo:
655 case DW_LANG_GLSL:
656 case DW_LANG_GLSL_ES:
657 case DW_LANG_HLSL:
658 case DW_LANG_OpenCL_CPP:
659 case DW_LANG_CPP_for_OpenCL:
660 case DW_LANG_SYCL:
661 case DW_LANG_Ruby:
662 case DW_LANG_Move:
663 case DW_LANG_Hylo:
664 case DW_LANG_Metal:
665 result = false;
666 break;
667 }
668
669 return result;
670}
671
672inline bool isC(SourceLanguage S) {
673 // Deliberately enumerate all the language options so we get a warning when
674 // new language options are added (-Wswitch) that'll hopefully help keep this
675 // switch up-to-date when new C++ versions are added.
676 switch (S) {
677 case DW_LANG_C11:
678 case DW_LANG_C17:
679 case DW_LANG_C89:
680 case DW_LANG_C99:
681 case DW_LANG_C:
682 case DW_LANG_ObjC:
683 return true;
684 case DW_LANG_C_plus_plus:
685 case DW_LANG_C_plus_plus_03:
686 case DW_LANG_C_plus_plus_11:
687 case DW_LANG_C_plus_plus_14:
688 case DW_LANG_C_plus_plus_17:
689 case DW_LANG_C_plus_plus_20:
690 case DW_LANG_Ada83:
691 case DW_LANG_Cobol74:
692 case DW_LANG_Cobol85:
693 case DW_LANG_Fortran77:
694 case DW_LANG_Fortran90:
695 case DW_LANG_Pascal83:
696 case DW_LANG_Modula2:
697 case DW_LANG_Java:
698 case DW_LANG_Ada95:
699 case DW_LANG_Fortran95:
700 case DW_LANG_PLI:
701 case DW_LANG_ObjC_plus_plus:
702 case DW_LANG_UPC:
703 case DW_LANG_D:
704 case DW_LANG_Python:
705 case DW_LANG_OpenCL:
706 case DW_LANG_Go:
707 case DW_LANG_Modula3:
708 case DW_LANG_Haskell:
709 case DW_LANG_OCaml:
710 case DW_LANG_Rust:
711 case DW_LANG_Swift:
712 case DW_LANG_Julia:
713 case DW_LANG_Dylan:
714 case DW_LANG_Fortran03:
715 case DW_LANG_Fortran08:
716 case DW_LANG_RenderScript:
717 case DW_LANG_BLISS:
718 case DW_LANG_Mips_Assembler:
719 case DW_LANG_GOOGLE_RenderScript:
720 case DW_LANG_BORLAND_Delphi:
721 case DW_LANG_lo_user:
722 case DW_LANG_hi_user:
723 case DW_LANG_Kotlin:
724 case DW_LANG_Zig:
725 case DW_LANG_Crystal:
726 case DW_LANG_Fortran18:
727 case DW_LANG_Ada2005:
728 case DW_LANG_Ada2012:
729 case DW_LANG_HIP:
730 case DW_LANG_Assembly:
731 case DW_LANG_C_sharp:
732 case DW_LANG_Mojo:
733 case DW_LANG_GLSL:
734 case DW_LANG_GLSL_ES:
735 case DW_LANG_HLSL:
736 case DW_LANG_OpenCL_CPP:
737 case DW_LANG_CPP_for_OpenCL:
738 case DW_LANG_SYCL:
739 case DW_LANG_Ruby:
740 case DW_LANG_Move:
741 case DW_LANG_Hylo:
742 case DW_LANG_Metal:
743 return false;
744 }
745 llvm_unreachable("Unknown language kind.");
746}
747
749 return isFortran(S) ? DW_ATE_signed : DW_ATE_unsigned;
750}
751
753 // Identifier case codes
758};
759
761// Calling convention codes
762#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
763#include "llvm/BinaryFormat/Dwarf.def"
766};
767
769#define HANDLE_DW_ASPACE(ID, NAME) DW_ASPACE_LLVM_##NAME = ID,
770#define HANDLE_DW_ASPACE_PRED(ID, NAME, PRED) DW_ASPACE_LLVM_##NAME = ID,
771#include "llvm/BinaryFormat/Dwarf.def"
772};
773
781
783 // Array ordering
786};
787
789 // Discriminant descriptor values
792};
793
794/// Line Number Standard Opcode Encodings.
796#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
797#include "llvm/BinaryFormat/Dwarf.def"
798};
799
800/// Line Number Extended Opcode Encodings.
802#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
803#include "llvm/BinaryFormat/Dwarf.def"
806};
807
809#define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID,
810#include "llvm/BinaryFormat/Dwarf.def"
813};
814
823
824/// DWARF v5 macro information entry type encodings.
826#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
827#include "llvm/BinaryFormat/Dwarf.def"
830};
831
832/// GNU .debug_macro macro information entry type encodings.
834#define HANDLE_DW_MACRO_GNU(ID, NAME) DW_MACRO_GNU_##NAME = ID,
835#include "llvm/BinaryFormat/Dwarf.def"
838};
839
840/// DWARF v5 range list entry encoding values.
842#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
843#include "llvm/BinaryFormat/Dwarf.def"
844};
845
846/// DWARF v5 loc list entry encoding values.
848#define HANDLE_DW_LLE(ID, NAME) DW_LLE_##NAME = ID,
849#include "llvm/BinaryFormat/Dwarf.def"
850};
851
852/// Call frame instruction encodings.
854#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
855#define HANDLE_DW_CFA_PRED(ID, NAME, ARCH) DW_CFA_##NAME = ID,
856#include "llvm/BinaryFormat/Dwarf.def"
858
861};
862
886
887/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
888/// Keep this list in sync with clang's DeclObjCCommon.h
889/// ObjCPropertyAttribute::Kind!
891#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
892#include "llvm/BinaryFormat/Dwarf.def"
893};
894
895/// Constants for unit types in DWARF v5.
896enum UnitType : unsigned char {
897#define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID,
898#include "llvm/BinaryFormat/Dwarf.def"
901};
902
903enum Index {
904#define HANDLE_DW_IDX(ID, NAME) DW_IDX_##NAME = ID,
905#include "llvm/BinaryFormat/Dwarf.def"
908};
909
911 switch (UnitType) {
912 case DW_UT_compile:
913 case DW_UT_type:
914 case DW_UT_partial:
915 case DW_UT_skeleton:
916 case DW_UT_split_compile:
917 case DW_UT_split_type:
918 return true;
919 default:
920 return false;
921 }
922}
923
924inline bool isUnitType(dwarf::Tag T) {
925 switch (T) {
926 case DW_TAG_compile_unit:
927 case DW_TAG_type_unit:
928 case DW_TAG_partial_unit:
929 case DW_TAG_skeleton_unit:
930 return true;
931 default:
932 return false;
933 }
934}
935
936// Constants for the DWARF v5 Accelerator Table Proposal
938 // Data layout descriptors.
939 DW_ATOM_null = 0u, /// Marker as the end of a list of atoms.
940 DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
941 DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
942 // item in question.
943 DW_ATOM_die_tag = 3u, // A tag entry.
944 DW_ATOM_type_flags = 4u, // Set of flags for a type.
945
946 DW_ATOM_type_type_flags = 5u, // Dsymutil type extension.
947 DW_ATOM_qual_name_hash = 6u, // Dsymutil qualified hash extension.
948
949 // DW_ATOM_type_flags values.
950
951 // Always set for C++, only set for ObjC if this is the @implementation for a
952 // class.
954
955 // Hash functions.
956
957 // Daniel J. Bernstein hash.
959};
960
961// Return a suggested bucket count for the DWARF v5 Accelerator Table.
963 if (UniqueHashCount > 1024)
964 return UniqueHashCount / 4;
965 if (UniqueHashCount > 16)
966 return UniqueHashCount / 2;
967 return std::max<uint32_t>(UniqueHashCount, 1);
968}
969
970// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
981
983
984/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
985///
986/// All these functions map their argument's value back to the
987/// corresponding enumerator name or return an empty StringRef if the value
988/// isn't known.
989///
990/// @{
992LLVM_ABI StringRef ChildrenString(unsigned Children);
994LLVM_ABI StringRef FormEncodingString(unsigned Encoding);
997 unsigned SubOpEncoding);
1000LLVM_ABI StringRef EndianityString(unsigned Endian);
1002LLVM_ABI StringRef DefaultedMemberString(unsigned DefaultedEncodings);
1003LLVM_ABI StringRef VisibilityString(unsigned Visibility);
1004LLVM_ABI StringRef VirtualityString(unsigned Virtuality);
1005LLVM_ABI StringRef EnumKindString(unsigned EnumKind);
1006LLVM_ABI StringRef LanguageString(unsigned Language);
1008LLVM_ABI StringRef CaseString(unsigned Case);
1009LLVM_ABI StringRef ConventionString(unsigned Convention);
1010LLVM_ABI StringRef InlineCodeString(unsigned Code);
1011LLVM_ABI StringRef ArrayOrderString(unsigned Order);
1012LLVM_ABI StringRef LNStandardString(unsigned Standard);
1013LLVM_ABI StringRef LNExtendedString(unsigned Encoding);
1014LLVM_ABI StringRef MacinfoString(unsigned Encoding);
1015LLVM_ABI StringRef MacroString(unsigned Encoding);
1016LLVM_ABI StringRef GnuMacroString(unsigned Encoding);
1017LLVM_ABI StringRef RangeListEncodingString(unsigned Encoding);
1018LLVM_ABI StringRef LocListEncodingString(unsigned Encoding);
1019LLVM_ABI StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch);
1022LLVM_ABI StringRef AtomTypeString(unsigned Atom);
1023LLVM_ABI StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
1025LLVM_ABI StringRef IndexString(unsigned Idx);
1027LLVM_ABI StringRef FormatString(bool IsDWARF64);
1028LLVM_ABI StringRef RLEString(unsigned RLE);
1029LLVM_ABI StringRef AddressSpaceString(unsigned AS, const llvm::Triple &TT);
1030/// @}
1031
1032/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
1033///
1034/// These functions map their strings back to the corresponding enumeration
1035/// value or return 0 if there is none, except for these exceptions:
1036///
1037/// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
1038/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
1039/// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
1040///
1041/// @{
1044LLVM_ABI unsigned getSubOperationEncoding(unsigned OpEncoding,
1051LLVM_ABI unsigned getAttributeEncoding(StringRef EncodingString);
1054/// @}
1055
1056/// \defgroup DwarfConstantsVersioning Dwarf version for constants
1057///
1058/// For constants defined by DWARF, returns the DWARF version when the constant
1059/// was first defined. For vendor extensions, if there is a version-related
1060/// policy for when to emit it, returns a version number for that policy.
1061/// Otherwise returns 0.
1062///
1063/// @{
1064LLVM_ABI unsigned TagVersion(Tag T);
1066LLVM_ABI unsigned FormVersion(Form F);
1067LLVM_ABI unsigned OperationVersion(LocationAtom O);
1068LLVM_ABI unsigned AttributeEncodingVersion(TypeKind E);
1070/// @}
1071
1072/// \defgroup DwarfConstantsVendor Dwarf "vendor" for constants
1073///
1074/// These functions return an identifier describing "who" defined the constant,
1075/// either the DWARF standard itself or the vendor who defined the extension.
1076///
1077/// @{
1078LLVM_ABI unsigned TagVendor(Tag T);
1080LLVM_ABI unsigned FormVendor(Form F);
1081LLVM_ABI unsigned OperationVendor(LocationAtom O);
1082LLVM_ABI unsigned AttributeEncodingVendor(TypeKind E);
1084/// @}
1085
1086/// The number of operands for the given LocationAtom.
1087LLVM_ABI std::optional<unsigned> OperationOperands(LocationAtom O);
1088
1089/// The arity of the given LocationAtom. This is the number of elements on the
1090/// stack this operation operates on. Returns -1 if the arity is variable (e.g.
1091/// depending on the argument) or unknown.
1092LLVM_ABI std::optional<unsigned> OperationArity(LocationAtom O);
1093
1094LLVM_ABI std::optional<unsigned> LanguageLowerBound(SourceLanguage L);
1095
1096/// The size of a reference determined by the DWARF 32/64-bit format.
1098 switch (Format) {
1100 return 4;
1102 return 8;
1103 }
1104 llvm_unreachable("Invalid Format value");
1105}
1106
1107/// A helper struct providing information about the byte size of DW_FORM
1108/// values that vary in size depending on the DWARF version, address byte
1109/// size, or DWARF32/DWARF64.
1114 /// True if DWARF v2 output generally uses relocations for references
1115 /// to other .debug_* sections.
1117
1118 /// The definition of the size of form DW_FORM_ref_addr depends on the
1119 /// version. In DWARF v2 it's the size of an address; after that, it's the
1120 /// size of a reference.
1122 if (Version == 2)
1123 return AddrSize;
1124 return getDwarfOffsetByteSize();
1125 }
1126
1127 /// The size of a reference is determined by the DWARF 32/64-bit format.
1131
1132 explicit operator bool() const { return Version && AddrSize; }
1133};
1134
1135/// Get the byte size of the unit length field depending on the DWARF format.
1137 switch (Format) {
1139 return 4;
1141 return 12;
1142 }
1143 llvm_unreachable("Invalid Format value");
1144}
1145
1146/// Get the fixed byte size for a given form.
1147///
1148/// If the form has a fixed byte size, then an Optional with a value will be
1149/// returned. If the form is always encoded using a variable length storage
1150/// format (ULEB or SLEB numbers or blocks) then std::nullopt will be returned.
1151///
1152/// \param Form DWARF form to get the fixed byte size for.
1153/// \param Params DWARF parameters to help interpret forms.
1154/// \returns std::optional<uint8_t> value with the fixed byte size or
1155/// std::nullopt if \p Form doesn't have a fixed byte size.
1156LLVM_ABI std::optional<uint8_t> getFixedFormByteSize(dwarf::Form Form,
1157 FormParams Params);
1158
1159/// Tells whether the specified form is defined in the specified version,
1160/// or is an extension if extensions are allowed.
1161LLVM_ABI bool isValidFormForVersion(Form F, unsigned Version,
1162 bool ExtensionsOk = true);
1163
1164/// Returns the symbolic string representing Val when used as a value
1165/// for attribute Attr.
1167
1168/// Returns the symbolic string representing Val when used as a value
1169/// for atom Atom.
1170LLVM_ABI StringRef AtomValueString(uint16_t Atom, unsigned Val);
1171
1172/// Describes an entry of the various gnu_pub* debug sections.
1173///
1174/// The gnu_pub* kind looks like:
1175///
1176/// 0-3 reserved
1177/// 4-6 symbol kind
1178/// 7 0 == global, 1 == static
1179///
1180/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
1181/// offset of the cu within the debug_info section stored in those 24 bits.
1190 : Kind(
1191 static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> KIND_OFFSET)),
1192 Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
1193 LINKAGE_OFFSET)) {}
1194 uint8_t toBits() const {
1195 return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET;
1196 }
1197
1198private:
1199 enum {
1200 KIND_OFFSET = 4,
1201 KIND_MASK = 7 << KIND_OFFSET,
1202 LINKAGE_OFFSET = 7,
1203 LINKAGE_MASK = 1 << LINKAGE_OFFSET
1204 };
1205};
1206
1207template <typename Enum> struct EnumTraits : public std::false_type {};
1208
1209template <> struct EnumTraits<Attribute> : public std::true_type {
1210 static constexpr char Type[3] = "AT";
1212};
1213
1214template <> struct EnumTraits<Form> : public std::true_type {
1215 static constexpr char Type[5] = "FORM";
1217};
1218
1219template <> struct EnumTraits<Index> : public std::true_type {
1220 static constexpr char Type[4] = "IDX";
1222};
1223
1224template <> struct EnumTraits<Tag> : public std::true_type {
1225 static constexpr char Type[4] = "TAG";
1227};
1228
1229template <> struct EnumTraits<LineNumberOps> : public std::true_type {
1230 static constexpr char Type[4] = "LNS";
1232};
1233
1234template <> struct EnumTraits<LocationAtom> : public std::true_type {
1235 static constexpr char Type[3] = "OP";
1237};
1238
1240 return std::numeric_limits<uint64_t>::max() >> (8 - AddressByteSize) * 8;
1241}
1242
1243} // End of namespace dwarf
1244
1245/// Dwarf constants format_provider
1246///
1247/// Specialization of the format_provider template for dwarf enums. Unlike the
1248/// dumping functions above, these format unknown enumerator values as
1249/// DW_TYPE_unknown_1234 (e.g. DW_TAG_unknown_ffff).
1250template <typename Enum>
1251struct format_provider<Enum, std::enable_if_t<dwarf::EnumTraits<Enum>::value>> {
1252 static void format(const Enum &E, raw_ostream &OS, StringRef Style) {
1254 if (Str.empty()) {
1255 OS << "DW_" << dwarf::EnumTraits<Enum>::Type << "_unknown_"
1256 << llvm::format("%x", E);
1257 } else
1258 OS << Str;
1259 }
1260};
1261} // End of namespace llvm
1262
1263#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:673
LLVM_ABI StringRef RangeListEncodingString(unsigned Encoding)
Definition Dwarf.cpp:741
LLVM_ABI StringRef CaseString(unsigned Case)
Definition Dwarf.cpp:606
LLVM_ABI StringRef SourceLanguageNameString(SourceLanguageName Lang)
Definition Dwarf.cpp:586
LLVM_ABI StringRef VisibilityString(unsigned Visibility)
Definition Dwarf.cpp:362
LLVM_ABI StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition Dwarf.cpp:856
LLVM_ABI StringRef AttributeString(unsigned Attribute)
Definition Dwarf.cpp:72
LLVM_ABI StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch)
Definition Dwarf.cpp:763
LLVM_ABI StringRef FormEncodingString(unsigned Encoding)
Definition Dwarf.cpp:105
LLVM_ABI StringRef ArrayOrderString(unsigned Order)
Definition Dwarf.cpp:652
LLVM_ABI StringRef MacroString(unsigned Encoding)
Definition Dwarf.cpp:713
LLVM_ABI StringRef EnumKindString(unsigned EnumKind)
Definition Dwarf.cpp:393
LLVM_ABI StringRef LocListEncodingString(unsigned Encoding)
Definition Dwarf.cpp:752
LLVM_ABI StringRef IndexString(unsigned Idx)
Definition Dwarf.cpp:912
LLVM_ABI StringRef RLEString(unsigned RLE)
Definition Dwarf.cpp:1034
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:1045
LLVM_ABI StringRef ChildrenString(unsigned Children)
Definition Dwarf.cpp:62
LLVM_ABI StringRef ApplePropertyString(unsigned)
Definition Dwarf.cpp:792
LLVM_ABI StringRef AtomTypeString(unsigned Atom)
Definition Dwarf.cpp:814
LLVM_ABI StringRef FormatString(DwarfFormat Format)
Definition Dwarf.cpp:1020
LLVM_ABI StringRef GnuMacroString(unsigned Encoding)
Definition Dwarf.cpp:724
LLVM_ABI StringRef EndianityString(unsigned Endian)
Definition Dwarf.cpp:320
LLVM_ABI StringRef ConventionString(unsigned Convention)
Definition Dwarf.cpp:620
LLVM_ABI StringRef MacinfoString(unsigned Encoding)
Definition Dwarf.cpp:684
LLVM_ABI StringRef OperationEncodingString(unsigned Encoding)
Definition Dwarf.cpp:138
LLVM_ABI StringRef UnitTypeString(unsigned)
Definition Dwarf.cpp:803
LLVM_ABI StringRef InlineCodeString(unsigned Code)
Definition Dwarf.cpp:638
LLVM_ABI StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition Dwarf.cpp:833
LLVM_ABI StringRef TagString(unsigned Tag)
Definition Dwarf.cpp:21
LLVM_ABI StringRef LNStandardString(unsigned Standard)
Definition Dwarf.cpp:662
LLVM_ABI StringRef AccessibilityString(unsigned Access)
Definition Dwarf.cpp:336
LLVM_ABI StringRef DefaultedMemberString(unsigned DefaultedEncodings)
Definition Dwarf.cpp:349
LLVM_ABI unsigned getSourceLanguageName(StringRef SourceLanguageNameString)
Definition Dwarf.cpp:598
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:631
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:735
LLVM_ABI unsigned getMacinfo(StringRef MacinfoString)
Definition Dwarf.cpp:703
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:774
@ DW_INL_not_inlined
Definition Dwarf.h:776
@ DW_INL_declared_not_inlined
Definition Dwarf.h:778
@ DW_INL_inlined
Definition Dwarf.h:777
@ DW_INL_declared_inlined
Definition Dwarf.h:779
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:1136
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:825
@ DW_MACRO_lo_user
Definition Dwarf.h:828
@ DW_MACRO_hi_user
Definition Dwarf.h:829
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:808
@ DW_LNCT_lo_user
Definition Dwarf.h:811
@ DW_LNCT_hi_user
Definition Dwarf.h:812
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:901
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:782
@ DW_ORD_row_major
Definition Dwarf.h:784
@ DW_ORD_col_major
Definition Dwarf.h:785
CallingConvention
Definition Dwarf.h:760
@ DW_CC_lo_user
Definition Dwarf.h:764
@ DW_CC_hi_user
Definition Dwarf.h:765
LineNumberOps
Line Number Standard Opcode Encodings.
Definition Dwarf.h:795
@ 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:890
LoclistEntries
DWARF v5 loc list entry encoding values.
Definition Dwarf.h:847
bool isFortran(SourceLanguage S)
Definition Dwarf.h:592
bool isUnitType(uint8_t UnitType)
Definition Dwarf.h:910
@ DW_IDX_lo_user
Definition Dwarf.h:906
@ DW_IDX_hi_user
Definition Dwarf.h:907
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:833
@ DW_MACRO_GNU_lo_user
Definition Dwarf.h:836
@ DW_MACRO_GNU_hi_user
Definition Dwarf.h:837
UnitType
Constants for unit types in DWARF v5.
Definition Dwarf.h:896
@ DW_UT_lo_user
Definition Dwarf.h:899
@ DW_UT_hi_user
Definition Dwarf.h:900
@ 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:752
@ DW_ID_down_case
Definition Dwarf.h:756
@ DW_ID_case_insensitive
Definition Dwarf.h:757
@ DW_ID_case_sensitive
Definition Dwarf.h:754
@ DW_ID_up_case
Definition Dwarf.h:755
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:1011
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:815
@ DW_MACINFO_undef
Definition Dwarf.h:818
@ DW_MACINFO_start_file
Definition Dwarf.h:819
@ DW_MACINFO_end_file
Definition Dwarf.h:820
@ DW_MACINFO_define
Definition Dwarf.h:817
@ DW_MACINFO_vendor_ext
Definition Dwarf.h:821
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:841
LLVM_ABI std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
Definition Dwarf.cpp:923
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1097
VirtualityAttribute
Definition Dwarf.h:197
@ DW_VIRTUALITY_max
Definition Dwarf.h:200
GDBIndexEntryKind
Definition Dwarf.h:971
@ GIEK_NONE
Definition Dwarf.h:972
@ GIEK_UNUSED7
Definition Dwarf.h:979
@ GIEK_TYPE
Definition Dwarf.h:973
@ GIEK_UNUSED6
Definition Dwarf.h:978
@ GIEK_OTHER
Definition Dwarf.h:976
@ GIEK_FUNCTION
Definition Dwarf.h:975
@ GIEK_UNUSED5
Definition Dwarf.h:977
@ GIEK_VARIABLE
Definition Dwarf.h:974
LineNumberExtendedOps
Line Number Extended Opcode Encodings.
Definition Dwarf.h:801
@ DW_LNE_hi_user
Definition Dwarf.h:805
@ DW_LNE_lo_user
Definition Dwarf.h:804
bool isCPlusPlus(SourceLanguage S)
Definition Dwarf.h:512
@ DW_EH_PE_textrel
Definition Dwarf.h:880
@ DW_CHILDREN_no
Definition Dwarf.h:865
@ DW_EH_PE_datarel
Definition Dwarf.h:881
@ DW_EH_PE_pcrel
Definition Dwarf.h:879
@ DW_EH_PE_signed
Definition Dwarf.h:878
@ DW_CHILDREN_yes
Definition Dwarf.h:866
@ DW_EH_PE_sdata4
Definition Dwarf.h:876
@ DW_EH_PE_funcrel
Definition Dwarf.h:882
@ DW_EH_PE_aligned
Definition Dwarf.h:883
@ DW_EH_PE_udata2
Definition Dwarf.h:871
@ DW_EH_PE_sdata8
Definition Dwarf.h:877
@ DW_EH_PE_absptr
Definition Dwarf.h:868
@ DW_EH_PE_sdata2
Definition Dwarf.h:875
@ DW_EH_PE_udata4
Definition Dwarf.h:872
@ DW_EH_PE_udata8
Definition Dwarf.h:873
@ DW_EH_PE_uleb128
Definition Dwarf.h:870
@ DW_EH_PE_indirect
Definition Dwarf.h:884
@ DW_EH_PE_sleb128
Definition Dwarf.h:874
@ DW_EH_PE_omit
Definition Dwarf.h:869
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
Definition Dwarf.h:748
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:866
DiscriminantList
Definition Dwarf.h:788
@ DW_DSC_range
Definition Dwarf.h:791
@ DW_DSC_label
Definition Dwarf.h:790
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:853
@ DW_CFA_hi_user
Definition Dwarf.h:860
@ DW_CFA_extended
Definition Dwarf.h:857
@ DW_CFA_lo_user
Definition Dwarf.h:859
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:962
uint64_t computeTombstoneAddress(uint8_t AddressByteSize)
Definition Dwarf.h:1239
LLVM_ABI llvm::StringRef LanguageDescription(SourceLanguageName name)
Returns a version-independent language name.
Definition Dwarf.cpp:465
AcceleratorTable
Definition Dwarf.h:937
@ DW_ATOM_type_flags
Definition Dwarf.h:944
@ DW_ATOM_null
Definition Dwarf.h:939
@ DW_ATOM_die_tag
Definition Dwarf.h:943
@ DW_FLAG_type_implementation
Definition Dwarf.h:953
@ DW_ATOM_qual_name_hash
Definition Dwarf.h:947
@ DW_ATOM_die_offset
Marker as the end of a list of atoms.
Definition Dwarf.h:940
@ DW_ATOM_type_type_flags
Definition Dwarf.h:946
@ DW_ATOM_cu_offset
Definition Dwarf.h:941
@ DW_hash_function_djb
Definition Dwarf.h:958
bool isC(SourceLanguage S)
Definition Dwarf.h:672
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:982
@ GIEL_EXTERNAL
Definition Dwarf.h:982
@ GIEL_STATIC
Definition Dwarf.h:982
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:118
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:867
static constexpr char Type[3]
Definition Dwarf.h:1210
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1211
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1216
static constexpr char Type[5]
Definition Dwarf.h:1215
static constexpr char Type[4]
Definition Dwarf.h:1220
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1221
static constexpr char Type[4]
Definition Dwarf.h:1230
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1231
static constexpr char Type[3]
Definition Dwarf.h:1235
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1236
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1226
static constexpr char Type[4]
Definition Dwarf.h:1225
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition Dwarf.h:1110
bool DwarfUsesRelocationsAcrossSections
True if DWARF v2 output generally uses relocations for references to other .debug_* sections.
Definition Dwarf.h:1116
DwarfFormat Format
Definition Dwarf.h:1113
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1128
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition Dwarf.h:1121
PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
Definition Dwarf.h:1185
PubIndexEntryDescriptor(uint8_t Value)
Definition Dwarf.h:1189
PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
Definition Dwarf.h:1187
GDBIndexEntryLinkage Linkage
Definition Dwarf.h:1184
static void format(const Enum &E, raw_ostream &OS, StringRef Style)
Definition Dwarf.h:1252