LLVM 24.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_LLVM_LANG_DIALECT(ID, NAME) DW_LLVM_LANG_DIALECT_##NAME = ID,
211#include "llvm/BinaryFormat/Dwarf.def"
213};
214
216#define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID,
217#include "llvm/BinaryFormat/Dwarf.def"
219};
220
222#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
223 DW_LANG_##NAME = ID,
224#include "llvm/BinaryFormat/Dwarf.def"
227};
228
230#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) DW_LNAME_##NAME = ID,
231#include "llvm/BinaryFormat/Dwarf.def"
232};
233
234/// Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
235/// If the version number doesn't exactly match a known version it is
236/// rounded up to the next-highest known version number.
237inline std::optional<SourceLanguage> toDW_LANG(SourceLanguageName name,
238 uint32_t version) {
239 switch (name) {
240 case DW_LNAME_Ada: // YYYY
241 if (version <= 1983)
242 return DW_LANG_Ada83;
243 if (version <= 1995)
244 return DW_LANG_Ada95;
245 if (version <= 2005)
246 return DW_LANG_Ada2005;
247 if (version <= 2012)
248 return DW_LANG_Ada2012;
249 return {};
250 case DW_LNAME_BLISS:
251 return DW_LANG_BLISS;
252 case DW_LNAME_C: // YYYYMM, K&R 000000
253 if (version == 0)
254 return DW_LANG_C;
255 if (version <= 198912)
256 return DW_LANG_C89;
257 if (version <= 199901)
258 return DW_LANG_C99;
259 if (version <= 201112)
260 return DW_LANG_C11;
261 if (version <= 201710)
262 return DW_LANG_C17;
263 if (version <= 202311)
264 return DW_LANG_C23;
265 return {};
266 case DW_LNAME_C_plus_plus: // YYYYMM
267 if (version == 0)
268 return DW_LANG_C_plus_plus;
269 if (version <= 199711)
270 return DW_LANG_C_plus_plus;
271 if (version <= 200310)
272 return DW_LANG_C_plus_plus_03;
273 if (version <= 201103)
274 return DW_LANG_C_plus_plus_11;
275 if (version <= 201402)
276 return DW_LANG_C_plus_plus_14;
277 if (version <= 201703)
278 return DW_LANG_C_plus_plus_17;
279 if (version <= 202002)
280 return DW_LANG_C_plus_plus_20;
281 if (version <= 202302)
282 return DW_LANG_C_plus_plus_23;
283 return {};
284 case DW_LNAME_Cobol: // YYYY
285 if (version <= 1974)
286 return DW_LANG_Cobol74;
287 if (version <= 1985)
288 return DW_LANG_Cobol85;
289 return {};
290 case DW_LNAME_Crystal:
291 return DW_LANG_Crystal;
292 case DW_LNAME_D:
293 return DW_LANG_D;
294 case DW_LNAME_Dylan:
295 return DW_LANG_Dylan;
296 case DW_LNAME_Fortran: // YYYY
297 if (version <= 1977)
298 return DW_LANG_Fortran77;
299 if (version <= 1990)
300 return DW_LANG_Fortran90;
301 if (version <= 1995)
302 return DW_LANG_Fortran95;
303 if (version <= 2003)
304 return DW_LANG_Fortran03;
305 if (version <= 2008)
306 return DW_LANG_Fortran08;
307 if (version <= 2018)
308 return DW_LANG_Fortran18;
309 if (version <= 2023)
310 return DW_LANG_Fortran23;
311 return {};
312 case DW_LNAME_Go:
313 return DW_LANG_Go;
314 case DW_LNAME_Haskell:
315 return DW_LANG_Haskell;
316 case DW_LNAME_HIP:
317 return DW_LANG_HIP;
318 case DW_LNAME_Odin:
319 return DW_LANG_Odin;
320 case DW_LNAME_P4:
321 return DW_LANG_P4;
322 case DW_LNAME_Java:
323 return DW_LANG_Java;
324 case DW_LNAME_Julia:
325 return DW_LANG_Julia;
326 case DW_LNAME_Kotlin:
327 return DW_LANG_Kotlin;
328 case DW_LNAME_Modula2:
329 return DW_LANG_Modula2;
330 case DW_LNAME_Modula3:
331 return DW_LANG_Modula3;
332 case DW_LNAME_ObjC:
333 return DW_LANG_ObjC;
334 case DW_LNAME_ObjC_plus_plus:
335 return DW_LANG_ObjC_plus_plus;
336 case DW_LNAME_OCaml:
337 return DW_LANG_OCaml;
338 case DW_LNAME_OpenCL_C:
339 return DW_LANG_OpenCL;
340 case DW_LNAME_Pascal:
341 return DW_LANG_Pascal83;
342 case DW_LNAME_PLI:
343 return DW_LANG_PLI;
344 case DW_LNAME_Python:
345 return DW_LANG_Python;
346 case DW_LNAME_RenderScript:
347 return DW_LANG_RenderScript;
348 case DW_LNAME_Rust:
349 return DW_LANG_Rust;
350 case DW_LNAME_Swift:
351 return DW_LANG_Swift;
352 case DW_LNAME_UPC:
353 return DW_LANG_UPC;
354 case DW_LNAME_Zig:
355 return DW_LANG_Zig;
356 case DW_LNAME_Assembly:
357 return DW_LANG_Assembly;
358 case DW_LNAME_C_sharp:
359 return DW_LANG_C_sharp;
360 case DW_LNAME_Mojo:
361 return DW_LANG_Mojo;
362 case DW_LNAME_GLSL:
363 return DW_LANG_GLSL;
364 case DW_LNAME_GLSL_ES:
365 return DW_LANG_GLSL_ES;
366 case DW_LNAME_HLSL:
367 return DW_LANG_HLSL;
368 case DW_LNAME_OpenCL_CPP:
369 return DW_LANG_OpenCL_CPP;
370 case DW_LNAME_CPP_for_OpenCL:
371 return {};
372 case DW_LNAME_SYCL:
373 return DW_LANG_SYCL;
374 case DW_LNAME_Ruby:
375 return DW_LANG_Ruby;
376 case DW_LNAME_Move:
377 return DW_LANG_Move;
378 case DW_LNAME_Hylo:
379 return DW_LANG_Hylo;
380 case DW_LNAME_Metal:
381 return DW_LANG_Metal;
382 case DW_LNAME_V:
383 return DW_LANG_V;
384 case DW_LNAME_Algol68:
385 return DW_LANG_Algol68;
386 case DW_LNAME_Nim:
387 return DW_LANG_Nim;
388 case DW_LNAME_Erlang:
389 return DW_LANG_Erlang;
390 case DW_LNAME_Elixir:
391 return DW_LANG_Elixir;
392 case DW_LNAME_Gleam:
393 return DW_LANG_Gleam;
394 }
395 return {};
396}
397
398/// Convert a DWARF 5 DW_LANG to a DWARF 6 pair of language name and version.
399inline std::optional<std::pair<SourceLanguageName, uint32_t>>
401 switch (language) {
402 case DW_LANG_Ada83:
403 return {{DW_LNAME_Ada, 1983}};
404 case DW_LANG_Ada95:
405 return {{DW_LNAME_Ada, 1995}};
406 case DW_LANG_Ada2005:
407 return {{DW_LNAME_Ada, 2005}};
408 case DW_LANG_Ada2012:
409 return {{DW_LNAME_Ada, 2012}};
410 case DW_LANG_BLISS:
411 return {{DW_LNAME_BLISS, 0}};
412 case DW_LANG_C:
413 return {{DW_LNAME_C, 0}};
414 case DW_LANG_C89:
415 return {{DW_LNAME_C, 198912}};
416 case DW_LANG_C99:
417 return {{DW_LNAME_C, 199901}};
418 case DW_LANG_C11:
419 return {{DW_LNAME_C, 201112}};
420 case DW_LANG_C17:
421 return {{DW_LNAME_C, 201710}};
422 case DW_LANG_C23:
423 return {{DW_LNAME_C, 202311}};
424 case DW_LANG_C_plus_plus:
425 return {{DW_LNAME_C_plus_plus, 0}};
426 case DW_LANG_C_plus_plus_03:
427 return {{DW_LNAME_C_plus_plus, 200310}};
428 case DW_LANG_C_plus_plus_11:
429 return {{DW_LNAME_C_plus_plus, 201103}};
430 case DW_LANG_C_plus_plus_14:
431 return {{DW_LNAME_C_plus_plus, 201402}};
432 case DW_LANG_C_plus_plus_17:
433 return {{DW_LNAME_C_plus_plus, 201703}};
434 case DW_LANG_C_plus_plus_20:
435 return {{DW_LNAME_C_plus_plus, 202002}};
436 case DW_LANG_C_plus_plus_23:
437 return {{DW_LNAME_C_plus_plus, 202302}};
438 case DW_LANG_Cobol74:
439 return {{DW_LNAME_Cobol, 1974}};
440 case DW_LANG_Cobol85:
441 return {{DW_LNAME_Cobol, 1985}};
442 case DW_LANG_Crystal:
443 return {{DW_LNAME_Crystal, 0}};
444 case DW_LANG_D:
445 return {{DW_LNAME_D, 0}};
446 case DW_LANG_Dylan:
447 return {{DW_LNAME_Dylan, 0}};
448 case DW_LANG_Fortran77:
449 return {{DW_LNAME_Fortran, 1977}};
450 case DW_LANG_Fortran90:
451 return {{DW_LNAME_Fortran, 1990}};
452 case DW_LANG_Fortran95:
453 return {{DW_LNAME_Fortran, 1995}};
454 case DW_LANG_Fortran03:
455 return {{DW_LNAME_Fortran, 2003}};
456 case DW_LANG_Fortran08:
457 return {{DW_LNAME_Fortran, 2008}};
458 case DW_LANG_Fortran18:
459 return {{DW_LNAME_Fortran, 2018}};
460 case DW_LANG_Fortran23:
461 return {{DW_LNAME_Fortran, 2023}};
462 case DW_LANG_Go:
463 return {{DW_LNAME_Go, 0}};
464 case DW_LANG_Haskell:
465 return {{DW_LNAME_Haskell, 0}};
466 case DW_LANG_HIP:
467 return {{DW_LNAME_HIP, 0}};
468 case DW_LANG_Odin:
469 return {{DW_LNAME_Odin, 0}};
470 case DW_LANG_P4:
471 return {{DW_LNAME_P4, 0}};
472 case DW_LANG_Java:
473 return {{DW_LNAME_Java, 0}};
474 case DW_LANG_Julia:
475 return {{DW_LNAME_Julia, 0}};
476 case DW_LANG_Kotlin:
477 return {{DW_LNAME_Kotlin, 0}};
478 case DW_LANG_Modula2:
479 return {{DW_LNAME_Modula2, 0}};
480 case DW_LANG_Modula3:
481 return {{DW_LNAME_Modula3, 0}};
482 case DW_LANG_ObjC:
483 return {{DW_LNAME_ObjC, 0}};
484 case DW_LANG_ObjC_plus_plus:
485 return {{DW_LNAME_ObjC_plus_plus, 0}};
486 case DW_LANG_OCaml:
487 return {{DW_LNAME_OCaml, 0}};
488 case DW_LANG_OpenCL:
489 return {{DW_LNAME_OpenCL_C, 0}};
490 case DW_LANG_Pascal83:
491 return {{DW_LNAME_Pascal, 1983}};
492 case DW_LANG_PLI:
493 return {{DW_LNAME_PLI, 0}};
494 case DW_LANG_Python:
495 return {{DW_LNAME_Python, 0}};
496 case DW_LANG_RenderScript:
497 case DW_LANG_GOOGLE_RenderScript:
498 return {{DW_LNAME_RenderScript, 0}};
499 case DW_LANG_Rust:
500 return {{DW_LNAME_Rust, 0}};
501 case DW_LANG_Swift:
502 return {{DW_LNAME_Swift, 0}};
503 case DW_LANG_UPC:
504 return {{DW_LNAME_UPC, 0}};
505 case DW_LANG_Zig:
506 return {{DW_LNAME_Zig, 0}};
507 case DW_LANG_Assembly:
508 case DW_LANG_Mips_Assembler:
509 return {{DW_LNAME_Assembly, 0}};
510 case DW_LANG_C_sharp:
511 return {{DW_LNAME_C_sharp, 0}};
512 case DW_LANG_Mojo:
513 return {{DW_LNAME_Mojo, 0}};
514 case DW_LANG_GLSL:
515 return {{DW_LNAME_GLSL, 0}};
516 case DW_LANG_GLSL_ES:
517 return {{DW_LNAME_GLSL_ES, 0}};
518 case DW_LANG_HLSL:
519 return {{DW_LNAME_HLSL, 0}};
520 case DW_LANG_OpenCL_CPP:
521 return {{DW_LNAME_OpenCL_CPP, 0}};
522 case DW_LANG_SYCL:
523 return {{DW_LNAME_SYCL, 0}};
524 case DW_LANG_Ruby:
525 return {{DW_LNAME_Ruby, 0}};
526 case DW_LANG_Move:
527 return {{DW_LNAME_Move, 0}};
528 case DW_LANG_Hylo:
529 return {{DW_LNAME_Hylo, 0}};
530 case DW_LANG_Metal:
531 return {{DW_LNAME_Metal, 0}};
532 case DW_LANG_V:
533 return {{DW_LNAME_V, 0}};
534 case DW_LANG_Algol68:
535 return {{DW_LNAME_Algol68, 1968}};
536 case DW_LANG_Nim:
537 return {{DW_LNAME_Nim, 0}};
538 case DW_LANG_Erlang:
539 return {{DW_LNAME_Erlang, 0}};
540 case DW_LANG_Elixir:
541 return {{DW_LNAME_Elixir, 0}};
542 case DW_LANG_Gleam:
543 return {{DW_LNAME_Gleam, 0}};
544 case DW_LANG_BORLAND_Delphi:
545 case DW_LANG_CPP_for_OpenCL:
546 case DW_LANG_lo_user:
547 case DW_LANG_hi_user:
548 return {};
549 }
550 return {};
551}
552
553/// Returns a version-independent language name.
555
556/// Returns a language name corresponding to the specified version.
557/// If the version is not recognized for the specified language, returns
558/// the version-independent name.
561
563 bool result = false;
564 // Deliberately enumerate all the language options so we get a warning when
565 // new language options are added (-Wswitch) that'll hopefully help keep this
566 // switch up-to-date when new C++ versions are added.
567 switch (S) {
568 case DW_LANG_C_plus_plus:
569 case DW_LANG_C_plus_plus_03:
570 case DW_LANG_C_plus_plus_11:
571 case DW_LANG_C_plus_plus_14:
572 case DW_LANG_C_plus_plus_17:
573 case DW_LANG_C_plus_plus_20:
574 case DW_LANG_C_plus_plus_23:
575 result = true;
576 break;
577 case DW_LANG_C89:
578 case DW_LANG_C:
579 case DW_LANG_Ada83:
580 case DW_LANG_Cobol74:
581 case DW_LANG_Cobol85:
582 case DW_LANG_Fortran77:
583 case DW_LANG_Fortran90:
584 case DW_LANG_Pascal83:
585 case DW_LANG_Modula2:
586 case DW_LANG_Java:
587 case DW_LANG_C99:
588 case DW_LANG_Ada95:
589 case DW_LANG_Fortran95:
590 case DW_LANG_PLI:
591 case DW_LANG_ObjC:
592 case DW_LANG_ObjC_plus_plus:
593 case DW_LANG_UPC:
594 case DW_LANG_D:
595 case DW_LANG_Python:
596 case DW_LANG_OpenCL:
597 case DW_LANG_Go:
598 case DW_LANG_Modula3:
599 case DW_LANG_Haskell:
600 case DW_LANG_OCaml:
601 case DW_LANG_Rust:
602 case DW_LANG_C11:
603 case DW_LANG_Swift:
604 case DW_LANG_Julia:
605 case DW_LANG_Dylan:
606 case DW_LANG_Fortran03:
607 case DW_LANG_Fortran08:
608 case DW_LANG_RenderScript:
609 case DW_LANG_BLISS:
610 case DW_LANG_Mips_Assembler:
611 case DW_LANG_GOOGLE_RenderScript:
612 case DW_LANG_BORLAND_Delphi:
613 case DW_LANG_lo_user:
614 case DW_LANG_hi_user:
615 case DW_LANG_Kotlin:
616 case DW_LANG_Zig:
617 case DW_LANG_Crystal:
618 case DW_LANG_C17:
619 case DW_LANG_Fortran18:
620 case DW_LANG_Ada2005:
621 case DW_LANG_Ada2012:
622 case DW_LANG_HIP:
623 case DW_LANG_Assembly:
624 case DW_LANG_C_sharp:
625 case DW_LANG_Mojo:
626 case DW_LANG_GLSL:
627 case DW_LANG_GLSL_ES:
628 case DW_LANG_HLSL:
629 case DW_LANG_OpenCL_CPP:
630 case DW_LANG_CPP_for_OpenCL:
631 case DW_LANG_SYCL:
632 case DW_LANG_Ruby:
633 case DW_LANG_Move:
634 case DW_LANG_Hylo:
635 case DW_LANG_Metal:
636 case DW_LANG_C23:
637 case DW_LANG_Fortran23:
638 case DW_LANG_Odin:
639 case DW_LANG_P4:
640 case DW_LANG_V:
641 case DW_LANG_Algol68:
642 case DW_LANG_Nim:
643 case DW_LANG_Erlang:
644 case DW_LANG_Elixir:
645 case DW_LANG_Gleam:
646 result = false;
647 break;
648 }
649
650 return result;
651}
652
653inline bool isFortran(SourceLanguage S) {
654 bool result = false;
655 // Deliberately enumerate all the language options so we get a warning when
656 // new language options are added (-Wswitch) that'll hopefully help keep this
657 // switch up-to-date when new Fortran versions are added.
658 switch (S) {
659 case DW_LANG_Fortran77:
660 case DW_LANG_Fortran90:
661 case DW_LANG_Fortran95:
662 case DW_LANG_Fortran03:
663 case DW_LANG_Fortran08:
664 case DW_LANG_Fortran18:
665 case DW_LANG_Fortran23:
666 result = true;
667 break;
668 case DW_LANG_C89:
669 case DW_LANG_C:
670 case DW_LANG_Ada83:
671 case DW_LANG_C_plus_plus:
672 case DW_LANG_Cobol74:
673 case DW_LANG_Cobol85:
674 case DW_LANG_Pascal83:
675 case DW_LANG_Modula2:
676 case DW_LANG_Java:
677 case DW_LANG_C99:
678 case DW_LANG_Ada95:
679 case DW_LANG_PLI:
680 case DW_LANG_ObjC:
681 case DW_LANG_ObjC_plus_plus:
682 case DW_LANG_UPC:
683 case DW_LANG_D:
684 case DW_LANG_Python:
685 case DW_LANG_OpenCL:
686 case DW_LANG_Go:
687 case DW_LANG_Modula3:
688 case DW_LANG_Haskell:
689 case DW_LANG_C_plus_plus_03:
690 case DW_LANG_C_plus_plus_11:
691 case DW_LANG_OCaml:
692 case DW_LANG_Rust:
693 case DW_LANG_C11:
694 case DW_LANG_Swift:
695 case DW_LANG_Julia:
696 case DW_LANG_Dylan:
697 case DW_LANG_C_plus_plus_14:
698 case DW_LANG_RenderScript:
699 case DW_LANG_BLISS:
700 case DW_LANG_Mips_Assembler:
701 case DW_LANG_GOOGLE_RenderScript:
702 case DW_LANG_BORLAND_Delphi:
703 case DW_LANG_lo_user:
704 case DW_LANG_hi_user:
705 case DW_LANG_Kotlin:
706 case DW_LANG_Zig:
707 case DW_LANG_Crystal:
708 case DW_LANG_C_plus_plus_17:
709 case DW_LANG_C_plus_plus_20:
710 case DW_LANG_C17:
711 case DW_LANG_Ada2005:
712 case DW_LANG_Ada2012:
713 case DW_LANG_HIP:
714 case DW_LANG_Assembly:
715 case DW_LANG_C_sharp:
716 case DW_LANG_Mojo:
717 case DW_LANG_GLSL:
718 case DW_LANG_GLSL_ES:
719 case DW_LANG_HLSL:
720 case DW_LANG_OpenCL_CPP:
721 case DW_LANG_CPP_for_OpenCL:
722 case DW_LANG_SYCL:
723 case DW_LANG_Ruby:
724 case DW_LANG_Move:
725 case DW_LANG_Hylo:
726 case DW_LANG_Metal:
727 case DW_LANG_C_plus_plus_23:
728 case DW_LANG_C23:
729 case DW_LANG_Odin:
730 case DW_LANG_P4:
731 case DW_LANG_V:
732 case DW_LANG_Algol68:
733 case DW_LANG_Nim:
734 case DW_LANG_Erlang:
735 case DW_LANG_Elixir:
736 case DW_LANG_Gleam:
737 result = false;
738 break;
739 }
740
741 return result;
742}
743
744inline bool isC(SourceLanguage S) {
745 // Deliberately enumerate all the language options so we get a warning when
746 // new language options are added (-Wswitch) that'll hopefully help keep this
747 // switch up-to-date when new C++ versions are added.
748 switch (S) {
749 case DW_LANG_C11:
750 case DW_LANG_C17:
751 case DW_LANG_C23:
752 case DW_LANG_C89:
753 case DW_LANG_C99:
754 case DW_LANG_C:
755 case DW_LANG_ObjC:
756 return true;
757 case DW_LANG_C_plus_plus:
758 case DW_LANG_C_plus_plus_03:
759 case DW_LANG_C_plus_plus_11:
760 case DW_LANG_C_plus_plus_14:
761 case DW_LANG_C_plus_plus_17:
762 case DW_LANG_C_plus_plus_20:
763 case DW_LANG_Ada83:
764 case DW_LANG_Cobol74:
765 case DW_LANG_Cobol85:
766 case DW_LANG_Fortran77:
767 case DW_LANG_Fortran90:
768 case DW_LANG_Pascal83:
769 case DW_LANG_Modula2:
770 case DW_LANG_Java:
771 case DW_LANG_Ada95:
772 case DW_LANG_Fortran95:
773 case DW_LANG_PLI:
774 case DW_LANG_ObjC_plus_plus:
775 case DW_LANG_UPC:
776 case DW_LANG_D:
777 case DW_LANG_Python:
778 case DW_LANG_OpenCL:
779 case DW_LANG_Go:
780 case DW_LANG_Modula3:
781 case DW_LANG_Haskell:
782 case DW_LANG_OCaml:
783 case DW_LANG_Rust:
784 case DW_LANG_Swift:
785 case DW_LANG_Julia:
786 case DW_LANG_Dylan:
787 case DW_LANG_Fortran03:
788 case DW_LANG_Fortran08:
789 case DW_LANG_RenderScript:
790 case DW_LANG_BLISS:
791 case DW_LANG_Mips_Assembler:
792 case DW_LANG_GOOGLE_RenderScript:
793 case DW_LANG_BORLAND_Delphi:
794 case DW_LANG_lo_user:
795 case DW_LANG_hi_user:
796 case DW_LANG_Kotlin:
797 case DW_LANG_Zig:
798 case DW_LANG_Crystal:
799 case DW_LANG_Fortran18:
800 case DW_LANG_Ada2005:
801 case DW_LANG_Ada2012:
802 case DW_LANG_HIP:
803 case DW_LANG_Assembly:
804 case DW_LANG_C_sharp:
805 case DW_LANG_Mojo:
806 case DW_LANG_GLSL:
807 case DW_LANG_GLSL_ES:
808 case DW_LANG_HLSL:
809 case DW_LANG_OpenCL_CPP:
810 case DW_LANG_CPP_for_OpenCL:
811 case DW_LANG_SYCL:
812 case DW_LANG_Ruby:
813 case DW_LANG_Move:
814 case DW_LANG_Hylo:
815 case DW_LANG_Metal:
816 case DW_LANG_C_plus_plus_23:
817 case DW_LANG_Fortran23:
818 case DW_LANG_Odin:
819 case DW_LANG_P4:
820 case DW_LANG_V:
821 case DW_LANG_Algol68:
822 case DW_LANG_Nim:
823 case DW_LANG_Erlang:
824 case DW_LANG_Elixir:
825 case DW_LANG_Gleam:
826 return false;
827 }
828 llvm_unreachable("Unknown language kind.");
829}
830
832 return isFortran(S) ? DW_ATE_signed : DW_ATE_unsigned;
833}
834
836 // Identifier case codes
841};
842
844// Calling convention codes
845#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
846#include "llvm/BinaryFormat/Dwarf.def"
849};
850
852#define HANDLE_DW_ASPACE(ID, NAME) DW_ASPACE_LLVM_##NAME = ID,
853#define HANDLE_DW_ASPACE_PRED(ID, NAME, PRED) DW_ASPACE_LLVM_##NAME = ID,
854#include "llvm/BinaryFormat/Dwarf.def"
855};
856
864
866 // Array ordering
869};
870
872 // Discriminant descriptor values
875};
876
877/// Line Number Standard Opcode Encodings.
879#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
880#include "llvm/BinaryFormat/Dwarf.def"
881};
882
883/// Line Number Extended Opcode Encodings.
885#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
886#include "llvm/BinaryFormat/Dwarf.def"
889};
890
892#define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID,
893#include "llvm/BinaryFormat/Dwarf.def"
896};
897
906
907/// DWARF v5 macro information entry type encodings.
909#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
910#include "llvm/BinaryFormat/Dwarf.def"
913};
914
915/// GNU .debug_macro macro information entry type encodings.
917#define HANDLE_DW_MACRO_GNU(ID, NAME) DW_MACRO_GNU_##NAME = ID,
918#include "llvm/BinaryFormat/Dwarf.def"
921};
922
923/// DWARF v5 range list entry encoding values.
925#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
926#include "llvm/BinaryFormat/Dwarf.def"
927};
928
929/// DWARF v5 loc list entry encoding values.
931#define HANDLE_DW_LLE(ID, NAME) DW_LLE_##NAME = ID,
932#include "llvm/BinaryFormat/Dwarf.def"
933};
934
935/// Call frame instruction encodings.
937#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
938#define HANDLE_DW_CFA_PRED(ID, NAME, ARCH) DW_CFA_##NAME = ID,
939#include "llvm/BinaryFormat/Dwarf.def"
941
944};
945
969
970/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
971/// Keep this list in sync with clang's DeclObjCCommon.h
972/// ObjCPropertyAttribute::Kind!
974#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
975#include "llvm/BinaryFormat/Dwarf.def"
976};
977
978/// Constants for unit types in DWARF v5.
979enum UnitType : unsigned char {
980#define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID,
981#include "llvm/BinaryFormat/Dwarf.def"
984};
985
986enum Index {
987#define HANDLE_DW_IDX(ID, NAME) DW_IDX_##NAME = ID,
988#include "llvm/BinaryFormat/Dwarf.def"
991};
992
994 switch (UnitType) {
995 case DW_UT_compile:
996 case DW_UT_type:
997 case DW_UT_partial:
998 case DW_UT_skeleton:
999 case DW_UT_split_compile:
1000 case DW_UT_split_type:
1001 return true;
1002 default:
1003 return false;
1004 }
1005}
1006
1008 switch (T) {
1009 case DW_TAG_compile_unit:
1010 case DW_TAG_type_unit:
1011 case DW_TAG_partial_unit:
1012 case DW_TAG_skeleton_unit:
1013 return true;
1014 default:
1015 return false;
1016 }
1017}
1018
1019// Constants for the DWARF v5 Accelerator Table Proposal
1021 // Data layout descriptors.
1022 DW_ATOM_null = 0u, /// Marker as the end of a list of atoms.
1023 DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
1024 DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
1025 // item in question.
1026 DW_ATOM_die_tag = 3u, // A tag entry.
1027 DW_ATOM_type_flags = 4u, // Set of flags for a type.
1028
1029 DW_ATOM_type_type_flags = 5u, // Dsymutil type extension.
1030 DW_ATOM_qual_name_hash = 6u, // Dsymutil qualified hash extension.
1031
1032 // DW_ATOM_type_flags values.
1033
1034 // Always set for C++, only set for ObjC if this is the @implementation for a
1035 // class.
1037
1038 // Hash functions.
1039
1040 // Daniel J. Bernstein hash.
1042};
1043
1044// Return a suggested bucket count for the DWARF v5 Accelerator Table.
1046 if (UniqueHashCount > 1024)
1047 return UniqueHashCount / 4;
1048 if (UniqueHashCount > 16)
1049 return UniqueHashCount / 2;
1050 return std::max<uint32_t>(UniqueHashCount, 1);
1051}
1052
1053// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
1064
1066
1067/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
1068///
1069/// All these functions map their argument's value back to the
1070/// corresponding enumerator name or return an empty StringRef if the value
1071/// isn't known.
1072///
1073/// @{
1075LLVM_ABI StringRef ChildrenString(unsigned Children);
1077LLVM_ABI StringRef FormEncodingString(unsigned Encoding);
1078LLVM_ABI StringRef OperationEncodingString(unsigned Encoding);
1080 unsigned SubOpEncoding);
1081LLVM_ABI StringRef AttributeEncodingString(unsigned Encoding);
1082LLVM_ABI StringRef DecimalSignString(unsigned Sign);
1083LLVM_ABI StringRef EndianityString(unsigned Endian);
1085LLVM_ABI StringRef DefaultedMemberString(unsigned DefaultedEncodings);
1086LLVM_ABI StringRef VisibilityString(unsigned Visibility);
1087LLVM_ABI StringRef VirtualityString(unsigned Virtuality);
1088LLVM_ABI StringRef EnumKindString(unsigned EnumKind);
1089LLVM_ABI StringRef LanguageString(unsigned Language);
1091LLVM_ABI StringRef LanguageDialectString(unsigned LanguageDialect);
1092LLVM_ABI StringRef CaseString(unsigned Case);
1093LLVM_ABI StringRef ConventionString(unsigned Convention);
1094LLVM_ABI StringRef InlineCodeString(unsigned Code);
1095LLVM_ABI StringRef ArrayOrderString(unsigned Order);
1096LLVM_ABI StringRef LNStandardString(unsigned Standard);
1097LLVM_ABI StringRef LNExtendedString(unsigned Encoding);
1098LLVM_ABI StringRef MacinfoString(unsigned Encoding);
1099LLVM_ABI StringRef MacroString(unsigned Encoding);
1100LLVM_ABI StringRef GnuMacroString(unsigned Encoding);
1101LLVM_ABI StringRef RangeListEncodingString(unsigned Encoding);
1102LLVM_ABI StringRef LocListEncodingString(unsigned Encoding);
1103LLVM_ABI StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch);
1106LLVM_ABI StringRef AtomTypeString(unsigned Atom);
1107LLVM_ABI StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
1109LLVM_ABI StringRef IndexString(unsigned Idx);
1111LLVM_ABI StringRef FormatString(bool IsDWARF64);
1112LLVM_ABI StringRef RLEString(unsigned RLE);
1113LLVM_ABI StringRef AddressSpaceString(unsigned AS, const llvm::Triple &TT);
1114/// @}
1115
1116/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
1117///
1118/// These functions map their strings back to the corresponding enumeration
1119/// value or return 0 if there is none, except for these exceptions:
1120///
1121/// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
1122/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
1123/// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
1124///
1125/// @{
1128LLVM_ABI unsigned getSubOperationEncoding(unsigned OpEncoding,
1136LLVM_ABI unsigned getAttributeEncoding(StringRef EncodingString);
1139/// @}
1140
1141/// \defgroup DwarfConstantsVersioning Dwarf version for constants
1142///
1143/// For constants defined by DWARF, returns the DWARF version when the constant
1144/// was first defined. For vendor extensions, if there is a version-related
1145/// policy for when to emit it, returns a version number for that policy.
1146/// Otherwise returns 0.
1147///
1148/// @{
1149LLVM_ABI unsigned TagVersion(Tag T);
1151LLVM_ABI unsigned FormVersion(Form F);
1152LLVM_ABI unsigned OperationVersion(LocationAtom O);
1153LLVM_ABI unsigned AttributeEncodingVersion(TypeKind E);
1154LLVM_ABI unsigned LanguageVersion(SourceLanguage L);
1155/// @}
1156
1157/// \defgroup DwarfConstantsVendor Dwarf "vendor" for constants
1158///
1159/// These functions return an identifier describing "who" defined the constant,
1160/// either the DWARF standard itself or the vendor who defined the extension.
1161///
1162/// @{
1163LLVM_ABI unsigned TagVendor(Tag T);
1165LLVM_ABI unsigned FormVendor(Form F);
1166LLVM_ABI unsigned OperationVendor(LocationAtom O);
1167LLVM_ABI unsigned AttributeEncodingVendor(TypeKind E);
1168LLVM_ABI unsigned LanguageVendor(SourceLanguage L);
1169/// @}
1170
1171/// The number of operands for the given LocationAtom.
1172LLVM_ABI std::optional<unsigned> OperationOperands(LocationAtom O);
1173
1174/// The arity of the given LocationAtom. This is the number of elements on the
1175/// stack this operation operates on. Returns -1 if the arity is variable (e.g.
1176/// depending on the argument) or unknown.
1177LLVM_ABI std::optional<unsigned> OperationArity(LocationAtom O);
1178
1179inline bool isTlsAddressOp(uint8_t O) {
1180 return O == DW_OP_form_tls_address || O == DW_OP_GNU_push_tls_address;
1181}
1182
1183LLVM_ABI std::optional<unsigned> LanguageLowerBound(SourceLanguage L);
1184
1185/// The size of a reference determined by the DWARF 32/64-bit format.
1187 switch (Format) {
1189 return 4;
1191 return 8;
1192 }
1193 llvm_unreachable("Invalid Format value");
1194}
1195
1196/// A helper struct providing information about the byte size of DW_FORM
1197/// values that vary in size depending on the DWARF version, address byte
1198/// size, or DWARF32/DWARF64.
1203 /// True if DWARF v2 output generally uses relocations for references
1204 /// to other .debug_* sections.
1206
1207 /// The definition of the size of form DW_FORM_ref_addr depends on the
1208 /// version. In DWARF v2 it's the size of an address; after that, it's the
1209 /// size of a reference.
1211 if (Version == 2)
1212 return AddrSize;
1213 return getDwarfOffsetByteSize();
1214 }
1215
1216 /// The size of a reference is determined by the DWARF 32/64-bit format.
1221 return (getDwarfOffsetByteSize() == 4) ? UINT32_MAX : UINT64_MAX;
1222 }
1223
1224 explicit operator bool() const { return Version && AddrSize; }
1225};
1226
1227/// Get the byte size of the unit length field depending on the DWARF format.
1229 switch (Format) {
1231 return 4;
1233 return 12;
1234 }
1235 llvm_unreachable("Invalid Format value");
1236}
1237
1238/// Get the fixed byte size for a given form.
1239///
1240/// If the form has a fixed byte size, then an Optional with a value will be
1241/// returned. If the form is always encoded using a variable length storage
1242/// format (ULEB or SLEB numbers or blocks) then std::nullopt will be returned.
1243///
1244/// \param Form DWARF form to get the fixed byte size for.
1245/// \param Params DWARF parameters to help interpret forms.
1246/// \returns std::optional<uint8_t> value with the fixed byte size or
1247/// std::nullopt if \p Form doesn't have a fixed byte size.
1248LLVM_ABI std::optional<uint8_t> getFixedFormByteSize(dwarf::Form Form,
1249 FormParams Params);
1250
1251/// Tells whether the specified form is defined in the specified version,
1252/// or is an extension if extensions are allowed.
1253LLVM_ABI bool isValidFormForVersion(Form F, unsigned Version,
1254 bool ExtensionsOk = true);
1255
1256/// Returns the symbolic string representing Val when used as a value
1257/// for attribute Attr.
1259
1260/// Returns the symbolic string representing Val when used as a value
1261/// for atom Atom.
1262LLVM_ABI StringRef AtomValueString(uint16_t Atom, unsigned Val);
1263
1264/// Describes an entry of the various gnu_pub* debug sections.
1265///
1266/// The gnu_pub* kind looks like:
1267///
1268/// 0-3 reserved
1269/// 4-6 symbol kind
1270/// 7 0 == global, 1 == static
1271///
1272/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
1273/// offset of the cu within the debug_info section stored in those 24 bits.
1282 : Kind(
1283 static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> KIND_OFFSET)),
1284 Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
1285 LINKAGE_OFFSET)) {}
1286 uint8_t toBits() const {
1287 return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET;
1288 }
1289
1290private:
1291 enum {
1292 KIND_OFFSET = 4,
1293 KIND_MASK = 7 << KIND_OFFSET,
1294 LINKAGE_OFFSET = 7,
1295 LINKAGE_MASK = 1 << LINKAGE_OFFSET
1296 };
1297};
1298
1299template <typename Enum> struct EnumTraits : public std::false_type {};
1300
1301template <> struct EnumTraits<Attribute> : public std::true_type {
1302 static constexpr char Type[3] = "AT";
1304};
1305
1306template <> struct EnumTraits<Form> : public std::true_type {
1307 static constexpr char Type[5] = "FORM";
1309};
1310
1311template <> struct EnumTraits<Index> : public std::true_type {
1312 static constexpr char Type[4] = "IDX";
1314};
1315
1316template <> struct EnumTraits<Tag> : public std::true_type {
1317 static constexpr char Type[4] = "TAG";
1319};
1320
1321template <> struct EnumTraits<LineNumberOps> : public std::true_type {
1322 static constexpr char Type[4] = "LNS";
1324};
1325
1326template <> struct EnumTraits<LocationAtom> : public std::true_type {
1327 static constexpr char Type[3] = "OP";
1329};
1330
1332 return std::numeric_limits<uint64_t>::max() >> (8 - AddressByteSize) * 8;
1333}
1334
1335} // End of namespace dwarf
1336
1337/// Dwarf constants format_provider
1338///
1339/// Specialization of the format_provider template for dwarf enums. Unlike the
1340/// dumping functions above, these format unknown enumerator values as
1341/// DW_TYPE_unknown_1234 (e.g. DW_TAG_unknown_ffff).
1342template <typename Enum>
1343struct format_provider<Enum, std::enable_if_t<dwarf::EnumTraits<Enum>::value>> {
1344 static void format(const Enum &E, raw_ostream &OS, StringRef Style) {
1346 if (Str.empty()) {
1347 OS << "DW_" << dwarf::EnumTraits<Enum>::Type << "_unknown_"
1348 << llvm::format("%x", E);
1349 } else
1350 OS << Str;
1351 }
1352};
1353} // End of namespace llvm
1354
1355#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:215
DXIL Finalize Linkage
DXIL Resource Access
#define F(x, y, z)
Definition MD5.cpp:54
#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:105
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
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:710
LLVM_ABI StringRef RangeListEncodingString(unsigned Encoding)
Definition Dwarf.cpp:778
LLVM_ABI StringRef LanguageDialectString(unsigned LanguageDialect)
Definition Dwarf.cpp:621
LLVM_ABI StringRef CaseString(unsigned Case)
Definition Dwarf.cpp:643
LLVM_ABI StringRef SourceLanguageNameString(SourceLanguageName Lang)
Definition Dwarf.cpp:601
LLVM_ABI StringRef VisibilityString(unsigned Visibility)
Definition Dwarf.cpp:362
LLVM_ABI StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition Dwarf.cpp:893
LLVM_ABI StringRef AttributeString(unsigned Attribute)
Definition Dwarf.cpp:72
LLVM_ABI StringRef CallFrameString(unsigned Encoding, Triple::ArchType Arch)
Definition Dwarf.cpp:800
LLVM_ABI StringRef FormEncodingString(unsigned Encoding)
Definition Dwarf.cpp:105
LLVM_ABI StringRef ArrayOrderString(unsigned Order)
Definition Dwarf.cpp:689
LLVM_ABI StringRef MacroString(unsigned Encoding)
Definition Dwarf.cpp:750
LLVM_ABI StringRef EnumKindString(unsigned EnumKind)
Definition Dwarf.cpp:393
LLVM_ABI StringRef LocListEncodingString(unsigned Encoding)
Definition Dwarf.cpp:789
LLVM_ABI StringRef IndexString(unsigned Idx)
Definition Dwarf.cpp:953
LLVM_ABI StringRef RLEString(unsigned RLE)
Definition Dwarf.cpp:1075
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:1086
LLVM_ABI StringRef ChildrenString(unsigned Children)
Definition Dwarf.cpp:62
LLVM_ABI StringRef ApplePropertyString(unsigned)
Definition Dwarf.cpp:829
LLVM_ABI StringRef AtomTypeString(unsigned Atom)
Definition Dwarf.cpp:851
LLVM_ABI StringRef FormatString(DwarfFormat Format)
Definition Dwarf.cpp:1061
LLVM_ABI StringRef GnuMacroString(unsigned Encoding)
Definition Dwarf.cpp:761
LLVM_ABI StringRef EndianityString(unsigned Endian)
Definition Dwarf.cpp:320
LLVM_ABI StringRef ConventionString(unsigned Convention)
Definition Dwarf.cpp:657
LLVM_ABI StringRef MacinfoString(unsigned Encoding)
Definition Dwarf.cpp:721
LLVM_ABI StringRef OperationEncodingString(unsigned Encoding)
Definition Dwarf.cpp:138
LLVM_ABI StringRef UnitTypeString(unsigned)
Definition Dwarf.cpp:840
LLVM_ABI StringRef InlineCodeString(unsigned Code)
Definition Dwarf.cpp:675
LLVM_ABI StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition Dwarf.cpp:870
LLVM_ABI StringRef TagString(unsigned Tag)
Definition Dwarf.cpp:21
LLVM_ABI StringRef LNStandardString(unsigned Standard)
Definition Dwarf.cpp:699
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:613
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 getLanguageDialect(StringRef LanguageDialectString)
Definition Dwarf.cpp:632
LLVM_ABI unsigned getTag(StringRef TagString)
Definition Dwarf.cpp:32
LLVM_ABI unsigned getCallingConvention(StringRef LanguageString)
Definition Dwarf.cpp:668
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:772
LLVM_ABI unsigned getMacinfo(StringRef MacinfoString)
Definition Dwarf.cpp:740
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:857
@ DW_INL_not_inlined
Definition Dwarf.h:859
@ DW_INL_declared_not_inlined
Definition Dwarf.h:861
@ DW_INL_inlined
Definition Dwarf.h:860
@ DW_INL_declared_inlined
Definition Dwarf.h:862
const uint32_t DW_CIE_ID
Special ID values that distinguish a CIE from a FDE in DWARF CFI.
Definition Dwarf.h:98
bool isTlsAddressOp(uint8_t O)
Definition Dwarf.h:1179
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
Definition Dwarf.h:1228
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:908
@ DW_MACRO_lo_user
Definition Dwarf.h:911
@ DW_MACRO_hi_user
Definition Dwarf.h:912
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:891
@ DW_LNCT_lo_user
Definition Dwarf.h:894
@ DW_LNCT_hi_user
Definition Dwarf.h:895
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:942
DefaultedMemberAttribute
Definition Dwarf.h:215
@ DW_DEFAULTED_max
Definition Dwarf.h:218
SourceLanguageName
Definition Dwarf.h:229
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:865
@ DW_ORD_row_major
Definition Dwarf.h:867
@ DW_ORD_col_major
Definition Dwarf.h:868
CallingConvention
Definition Dwarf.h:843
@ DW_CC_lo_user
Definition Dwarf.h:847
@ DW_CC_hi_user
Definition Dwarf.h:848
LineNumberOps
Line Number Standard Opcode Encodings.
Definition Dwarf.h:878
@ 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:973
LoclistEntries
DWARF v5 loc list entry encoding values.
Definition Dwarf.h:930
bool isFortran(SourceLanguage S)
Definition Dwarf.h:653
bool isUnitType(uint8_t UnitType)
Definition Dwarf.h:993
LanguageDialectAttribute
Definition Dwarf.h:209
@ DW_LLVM_LANG_DIALECT_max
Definition Dwarf.h:212
@ DW_IDX_lo_user
Definition Dwarf.h:989
@ DW_IDX_hi_user
Definition Dwarf.h:990
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:916
@ DW_MACRO_GNU_lo_user
Definition Dwarf.h:919
@ DW_MACRO_GNU_hi_user
Definition Dwarf.h:920
UnitType
Constants for unit types in DWARF v5.
Definition Dwarf.h:979
@ DW_UT_lo_user
Definition Dwarf.h:982
@ DW_UT_hi_user
Definition Dwarf.h:983
@ 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:225
@ DW_LANG_hi_user
Definition Dwarf.h:226
CaseSensitivity
Definition Dwarf.h:835
@ DW_ID_down_case
Definition Dwarf.h:839
@ DW_ID_case_insensitive
Definition Dwarf.h:840
@ DW_ID_case_sensitive
Definition Dwarf.h:837
@ DW_ID_up_case
Definition Dwarf.h:838
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:1052
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:237
MacinfoRecordType
Definition Dwarf.h:898
@ DW_MACINFO_undef
Definition Dwarf.h:901
@ DW_MACINFO_start_file
Definition Dwarf.h:902
@ DW_MACINFO_end_file
Definition Dwarf.h:903
@ DW_MACINFO_define
Definition Dwarf.h:900
@ DW_MACINFO_vendor_ext
Definition Dwarf.h:904
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:924
LLVM_ABI std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
Definition Dwarf.cpp:964
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1186
VirtualityAttribute
Definition Dwarf.h:197
@ DW_VIRTUALITY_max
Definition Dwarf.h:200
GDBIndexEntryKind
Definition Dwarf.h:1054
@ GIEK_UNUSED7
Definition Dwarf.h:1062
@ GIEK_UNUSED6
Definition Dwarf.h:1061
@ GIEK_FUNCTION
Definition Dwarf.h:1058
@ GIEK_UNUSED5
Definition Dwarf.h:1060
@ GIEK_VARIABLE
Definition Dwarf.h:1057
LineNumberExtendedOps
Line Number Extended Opcode Encodings.
Definition Dwarf.h:884
@ DW_LNE_hi_user
Definition Dwarf.h:888
@ DW_LNE_lo_user
Definition Dwarf.h:887
bool isCPlusPlus(SourceLanguage S)
Definition Dwarf.h:562
@ DW_EH_PE_textrel
Definition Dwarf.h:963
@ DW_CHILDREN_no
Definition Dwarf.h:948
@ DW_EH_PE_datarel
Definition Dwarf.h:964
@ DW_EH_PE_pcrel
Definition Dwarf.h:962
@ DW_EH_PE_signed
Definition Dwarf.h:961
@ DW_CHILDREN_yes
Definition Dwarf.h:949
@ DW_EH_PE_sdata4
Definition Dwarf.h:959
@ DW_EH_PE_funcrel
Definition Dwarf.h:965
@ DW_EH_PE_aligned
Definition Dwarf.h:966
@ DW_EH_PE_udata2
Definition Dwarf.h:954
@ DW_EH_PE_sdata8
Definition Dwarf.h:960
@ DW_EH_PE_absptr
Definition Dwarf.h:951
@ DW_EH_PE_sdata2
Definition Dwarf.h:958
@ DW_EH_PE_udata4
Definition Dwarf.h:955
@ DW_EH_PE_udata8
Definition Dwarf.h:956
@ DW_EH_PE_uleb128
Definition Dwarf.h:953
@ DW_EH_PE_indirect
Definition Dwarf.h:967
@ DW_EH_PE_sleb128
Definition Dwarf.h:957
@ DW_EH_PE_omit
Definition Dwarf.h:952
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
Definition Dwarf.h:831
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:903
DiscriminantList
Definition Dwarf.h:871
@ DW_DSC_range
Definition Dwarf.h:874
@ DW_DSC_label
Definition Dwarf.h:873
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:936
@ DW_CFA_hi_user
Definition Dwarf.h:943
@ DW_CFA_extended
Definition Dwarf.h:940
@ DW_CFA_lo_user
Definition Dwarf.h:942
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:1045
uint64_t computeTombstoneAddress(uint8_t AddressByteSize)
Definition Dwarf.h:1331
LLVM_ABI llvm::StringRef LanguageDescription(SourceLanguageName name)
Returns a version-independent language name.
Definition Dwarf.cpp:465
@ DW_ATOM_type_flags
Definition Dwarf.h:1027
@ DW_ATOM_null
Definition Dwarf.h:1022
@ DW_ATOM_die_tag
Definition Dwarf.h:1026
@ DW_FLAG_type_implementation
Definition Dwarf.h:1036
@ DW_ATOM_qual_name_hash
Definition Dwarf.h:1030
@ DW_ATOM_die_offset
Marker as the end of a list of atoms.
Definition Dwarf.h:1023
@ DW_ATOM_type_type_flags
Definition Dwarf.h:1029
@ DW_ATOM_cu_offset
Definition Dwarf.h:1024
@ DW_hash_function_djb
Definition Dwarf.h:1041
bool isC(SourceLanguage S)
Definition Dwarf.h:744
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:1065
@ GIEL_EXTERNAL
Definition Dwarf.h:1065
@ GIEL_STATIC
Definition Dwarf.h:1065
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:400
This is an optimization pass for GlobalISel generic memory operations.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition Format.h:94
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
static constexpr char Type[3]
Definition Dwarf.h:1302
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1303
static constexpr char Type[5]
Definition Dwarf.h:1307
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1308
static constexpr char Type[4]
Definition Dwarf.h:1312
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1313
static constexpr char Type[4]
Definition Dwarf.h:1322
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1323
static constexpr char Type[3]
Definition Dwarf.h:1327
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1328
static LLVM_ABI StringRef(*const StringFn)(unsigned)
Definition Dwarf.h:1318
static constexpr char Type[4]
Definition Dwarf.h:1317
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition Dwarf.h:1199
bool DwarfUsesRelocationsAcrossSections
True if DWARF v2 output generally uses relocations for references to other .debug_* sections.
Definition Dwarf.h:1205
DwarfFormat Format
Definition Dwarf.h:1202
uint64_t getDwarfMaxOffset() const
Definition Dwarf.h:1220
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1217
uint8_t getRefAddrByteSize() const
The definition of the size of form DW_FORM_ref_addr depends on the version.
Definition Dwarf.h:1210
PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
Definition Dwarf.h:1277
PubIndexEntryDescriptor(uint8_t Value)
Definition Dwarf.h:1281
PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
Definition Dwarf.h:1279
GDBIndexEntryLinkage Linkage
Definition Dwarf.h:1276
static void format(const Enum &E, raw_ostream &OS, StringRef Style)
Definition Dwarf.h:1344