valgrind/0012-Recognize-new-DWARF5-DW_LANG-constants.patch

145 lines
5.7 KiB
Diff
Raw Normal View History

From a2c30f44ac39eb36baa4e831b041fe7cdf25e481 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 6 Dec 2024 15:39:25 +0100
Subject: [PATCH 12/14] Recognize new DWARF5 DW_LANG constants
When using --read-var-info=yes readdwarf3 will try to read and
interpret the CU DW_AT_langauge attribute. Since DWARF5 was released a
number if new language constants have been introduced. See
https://dwarfstd.org/languages.html
GCC15 might start emitting some of these when switching to C23 by
default.
When valgrind --read-var-info=yes encounters an unknown DW_LANG
constant it will produce an error and stop processing any further
DWARF.
Recognize all currently known language constants. In particular
recognize DW_LANG_C17, DW_LANG_C23, DW_LANG_C_plus_plus_17,
DW_LANG_C_plus_plus_20, DW_LANG_C_plus_plus_23, DW_LANG_Fortran18,
DW_LANG_Fortran23, DW_LANG_Ada2005, DW_LANG_Ada2012 and DW_LANG_Rust.
https://bugs.kde.org/show_bug.cgi?id=497130
(cherry picked from commit 7136316123c54aba37fdab166e1bf860e452a4ae)
---
NEWS | 1 +
coregrind/m_debuginfo/priv_d3basics.h | 31 +++++++++++++++++++++++++++
coregrind/m_debuginfo/readdwarf3.c | 27 +++++++++++++++++++++--
3 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 7f1334aa0f07..a25f9b663098 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ The following bugs have been fixed or resolved on this branch.
489913 WARNING: unhandled amd64-linux syscall: 444 (landlock_create_ruleset)
494246 syscall fsopen not wrapped
+497130 Recognize new DWARF5 DW_LANG constants
To see details of a given bug, visit
https://bugs.kde.org/show_bug.cgi?id=XXXXXX
diff --git a/coregrind/m_debuginfo/priv_d3basics.h b/coregrind/m_debuginfo/priv_d3basics.h
index 3f6e5c72c9e4..34c98728711c 100644
--- a/coregrind/m_debuginfo/priv_d3basics.h
+++ b/coregrind/m_debuginfo/priv_d3basics.h
@@ -179,6 +179,7 @@ typedef enum dwarf_source_language
/* DWARF 4. */
DW_LANG_Python = 0x0014,
/* DWARF 5. */
+ DW_LANG_OpenCL = 0x0015,
DW_LANG_Go = 0x0016,
DW_LANG_Modula3 = 0x0017,
DW_LANG_Haskell = 0x0018,
@@ -195,6 +196,36 @@ typedef enum dwarf_source_language
DW_LANG_Fortran08 = 0x0023,
DW_LANG_RenderScript = 0x0024,
DW_LANG_BLISS = 0x0025,
+ /* Language codes added since DWARF 5.
+ https://dwarfstd.org/languages.html */
+ DW_LANG_Kotlin = 0x0026,
+ DW_LANG_Zig = 0x0027,
+ DW_LANG_Crystal = 0x0028,
+ DW_LANG_C_plus_plus_17 = 0x002a,
+ DW_LANG_C_plus_plus_20 = 0x002b,
+ DW_LANG_C17 = 0x002c,
+ DW_LANG_Fortran18 = 0x002d,
+ DW_LANG_Ada2005 = 0x002e,
+ DW_LANG_Ada2012 = 0x002f,
+ DW_LANG_HIP = 0x0030,
+ DW_LANG_Assembly = 0x0031,
+ DW_LANG_C_sharp = 0x0032,
+ DW_LANG_Mojo = 0x0033,
+ DW_LANG_GLSL = 0x0034,
+ DW_LANG_GLSL_ES = 0x0035,
+ DW_LANG_HLSL = 0x0036,
+ DW_LANG_OpenCL_CPP = 0x0037,
+ DW_LANG_CPP_for_OpenCL = 0x0038,
+ DW_LANG_SYCL = 0x0039,
+ DW_LANG_C_plus_plus_23 = 0x003a,
+ DW_LANG_Odin = 0x003b,
+ DW_LANG_P4 = 0x003c,
+ DW_LANG_Metal = 0x003d,
+ DW_LANG_C23 = 0x003e,
+ DW_LANG_Fortran23 = 0x003f,
+ DW_LANG_Ruby = 0x0040,
+ DW_LANG_Move = 0x0041,
+ DW_LANG_Hylo = 0x0042,
/* MIPS. */
DW_LANG_Mips_Assembler = 0x8001,
/* UPC. */
diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c
index a4b75a8c532b..735896f7c0d3 100644
--- a/coregrind/m_debuginfo/readdwarf3.c
+++ b/coregrind/m_debuginfo/readdwarf3.c
@@ -3972,19 +3972,42 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents,
case DW_LANG_C_plus_plus: case DW_LANG_ObjC:
case DW_LANG_ObjC_plus_plus: case DW_LANG_UPC:
case DW_LANG_Upc: case DW_LANG_C99: case DW_LANG_C11:
+ case DW_LANG_C17: case DW_LANG_C23:
case DW_LANG_C_plus_plus_11: case DW_LANG_C_plus_plus_14:
+ case DW_LANG_C_plus_plus_17: case DW_LANG_C_plus_plus_20:
+ case DW_LANG_C_plus_plus_23:
parser->language = 'C'; break;
case DW_LANG_Fortran77: case DW_LANG_Fortran90:
case DW_LANG_Fortran95: case DW_LANG_Fortran03:
- case DW_LANG_Fortran08:
+ case DW_LANG_Fortran08: case DW_LANG_Fortran18:
+ case DW_LANG_Fortran23:
parser->language = 'F'; break;
case DW_LANG_Ada83: case DW_LANG_Ada95:
+ case DW_LANG_Ada2005: case DW_LANG_Ada2012:
parser->language = 'A'; break;
case DW_LANG_Cobol74:
case DW_LANG_Cobol85: case DW_LANG_Pascal83:
case DW_LANG_Modula2: case DW_LANG_Java:
case DW_LANG_PLI:
- case DW_LANG_D: case DW_LANG_Python: case DW_LANG_Go:
+ case DW_LANG_D: case DW_LANG_Python:
+ case DW_LANG_OpenCL: case DW_LANG_Go:
+ case DW_LANG_Modula3: case DW_LANG_Haskell:
+ case DW_LANG_OCaml: case DW_LANG_Rust: case DW_LANG_Swift:
+ case DW_LANG_Julia: case DW_LANG_Dylan:
+ case DW_LANG_RenderScript: case DW_LANG_BLISS:
+ case DW_LANG_Kotlin: case DW_LANG_Zig:
+ case DW_LANG_Crystal: case DW_LANG_HIP:
+ case DW_LANG_Assembly: case DW_LANG_C_sharp:
+ case DW_LANG_Mojo: case DW_LANG_GLSL:
+ case DW_LANG_GLSL_ES: case DW_LANG_HLSL:
+ case DW_LANG_OpenCL_CPP: case DW_LANG_CPP_for_OpenCL:
+ case DW_LANG_SYCL:
+ case DW_LANG_Odin:
+ case DW_LANG_P4:
+ case DW_LANG_Metal:
+ case DW_LANG_Ruby:
+ case DW_LANG_Move:
+ case DW_LANG_Hylo:
case DW_LANG_Mips_Assembler:
parser->language = '?'; break;
default:
--
2.47.1