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