[PATCH 2/4] libdw: Add dwarf_language and dwarf_language_lower_bound functions.

2025-03-15 Thread Mark Wielaard
dwarf_language returns a DW_LNAME constant for a CU Die. If the CU Die
has a DW_AT_language_name attribute dwarf_language will return it and
the DW_AT_language_version attribute value. Otherwise dwarf_language
will lookup the (old style) DW_AT_language attribute and translate the
DW_LANG constant into a DW_LNAME constant and version using a new
static function srclang_to_language.

The dwarf_language_lower_bound function works just like the
dwarf_default_lower_bound function, but takes a DW_LNAME constant
instead of a DW_LANG constant.

Adds a new test to make sure dwarf_language_lower_bound handles all
known DW_LNAME constants.

* NEWS: Add new functions.
* libdw/libdw.map (ELFUTILS_0.193): New section with new functions.
* libdw/libdw.h (dwarf_srclang): Add comment explaining this
returns DW_LANG constants.
(dwarf_language): New function.
(dwarf_default_lower_bound): Add comment explaining this works on
DW_LANG constants.
(dwarf_language_lower_bound): New function.
* libdw/libdwP.h: INTDECL dwarf_language and
dwarf_language_lower_bound.
* libdw/dwarf_srclang.c (srclang_to_language): New function.
(dwarf_language): Likewise.
* libdw/dwarf_default_lower_bound.c (dwarf_language_lower_bound):
New function.
* libdw/dwarf_getfuncs.c (dwarf_getfuncs):  Use dwarf_language and
dwarf_language_lower_bound.
* libdw/dwarf_aggregate_size.c (array_size): Likewise.
* tests/dwarf_language_lower_bound.c: New test.
* tests/Makefile.am (check_PROGRAMS): Add dwarf_language_lower_bound.
(TESTS): Likewise.
(dwarf_language_lower_bound_LDADD): New variable.

Signed-off-by: Mark Wielaard 
---
 NEWS   |   2 +
 libdw/dwarf_aggregate_size.c   |   8 +-
 libdw/dwarf_default_lower_bound.c  |  68 ++-
 libdw/dwarf_getfuncs.c |  12 +-
 libdw/dwarf_srclang.c  | 311 +
 libdw/libdw.h  |  26 ++-
 libdw/libdw.map|   6 +
 libdw/libdwP.h |   2 +
 tests/Makefile.am  |   5 +-
 tests/dwarf_language_lower_bound.c |  72 +++
 10 files changed, 493 insertions(+), 19 deletions(-)
 create mode 100644 tests/dwarf_language_lower_bound.c

diff --git a/NEWS b/NEWS
index 4cb5b2260fec..664c125b6eaa 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Version 0.193 (one after 0.192)
 
 debuginfod: Add CORS (webapp access) support to webapi.
 
+libdw: Add dwarf_language and dwarf_language_lower_bound functions.
+
 Version 0.192 "New rules, faster tools"
 
 CONDUCT: A new code of conduct has been adopted.  See the
diff --git a/libdw/dwarf_aggregate_size.c b/libdw/dwarf_aggregate_size.c
index 8216ae42e424..6579212abe96 100644
--- a/libdw/dwarf_aggregate_size.c
+++ b/libdw/dwarf_aggregate_size.c
@@ -1,5 +1,6 @@
 /* Compute size of an aggregate type from DWARF.
Copyright (C) 2010, 2014, 2016 Red Hat, Inc.
+   Copyright (C) 2025, Mark J. Wielaard 
This file is part of elfutils.
 
This file is free software; you can redistribute it and/or modify
@@ -131,10 +132,11 @@ array_size (Dwarf_Die *die, Dwarf_Word *size,
}
  else
{
+ Dwarf_Word lang;
  Dwarf_Die cu = CUDIE (die->cu);
- int lang = INTUSE(dwarf_srclang) (&cu);
- if (lang == -1
- || INTUSE(dwarf_default_lower_bound) (lang, &lower) != 0)
+ int res = INTUSE(dwarf_language) (&cu, &lang, NULL);
+ if (res < 0
+ || INTUSE(dwarf_language_lower_bound) (lang, &lower) != 0)
return -1;
}
  if (unlikely (lower > upper))
diff --git a/libdw/dwarf_default_lower_bound.c 
b/libdw/dwarf_default_lower_bound.c
index f04ae46de0c5..7cc808b22488 100644
--- a/libdw/dwarf_default_lower_bound.c
+++ b/libdw/dwarf_default_lower_bound.c
@@ -1,6 +1,6 @@
 /* Get the default subrange lower bound for a given language.
Copyright (C) 2016 Red Hat, Inc.
-   Copyright (C) 2024 Mark J. Wielaard 
+   Copyright (C) 2024, 2025 Mark J. Wielaard 
This file is part of elfutils.
 
This file is free software; you can redistribute it and/or modify
@@ -125,3 +125,69 @@ dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
 }
 }
 INTDEF (dwarf_default_lower_bound)
+
+/* Determine default lower bound from language, as per the DWARF6
+   https://dwarfstd.org/languages-v6.html table.  */
+int
+dwarf_language_lower_bound (Dwarf_Word lang, Dwarf_Sword *result)
+{
+  switch (lang)
+{
+case DW_LNAME_BLISS:
+case DW_LNAME_C:
+case DW_LNAME_C_plus_plus:
+case DW_LNAME_Crystal:
+case DW_LNAME_D:
+case DW_LNAME_Dylan:
+case DW_LNAME_Go:
+case DW_LNAME_Haskell:
+case DW_LNAME_Java:
+case DW_LNAME_Kotlin:
+case DW_LNAME_ObjC:
+case DW_LNAME_ObjC_plus_plus:
+case DW_LNAME_OCaml:
+case DW_LNAME_OpenCL_C:
+case DW_LNAME

Sourceware Survey 2025

2025-03-15 Thread Mark Wielaard
The Sourceware Project Leadership Committee would like to know who our
users are, which hosted projects they feel part of, what services they
rely on and what the priorities should be for new initiatives.

https://nextcloud.sfconservancy.org/apps/forms/s/xmGgmJFzSb2FZNd58cXMtAZp

The survey will run till the end of March and contains 20 quick
questions (none of the questions are mandatory, please feel free to
skip any you find not relevant, but any answer you give is helpful.)

The overview page (where we will also publish the summary/results) is
here https://sourceware.org/survey-2025 the direct link to the form is
https://nextcloud.sfconservancy.org/apps/forms/s/xmGgmJFzSb2FZNd58cXMtAZp

Also if you like to discuss this survey or give feedback another way
there is the Sourceware Open Office this Friday 14 March at 16:00 UTC
in #overseers on irc.libera.chat. To get the right time in your local
timezone: $ date -d "Fri Mar 14 16:00 UTC 2025"

Thanks,

 Frank Ch. Eigler, Christopher Faylor, Ian Kelling, Ian Lance Taylor,
 Tom Tromey, Jon Turney, Mark J. Wielaard, Elena Zannoni