]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libdw: Add dwarf_language and dwarf_language_lower_bound functions.
authorMark Wielaard <mark@klomp.org>
Thu, 30 Jan 2025 17:53:25 +0000 (18:53 +0100)
committerMark Wielaard <mark@klomp.org>
Sat, 8 Mar 2025 23:11:08 +0000 (00:11 +0100)
commit48f32e91524119ef40bce33b1bcc7b6687f9a892
tree1b93c42d99b833dec4625b55a53a2dadb32b46f8
parentf49baa1febcb36707cb5acf9974a4faf269a98d6
libdw: Add dwarf_language and dwarf_language_lower_bound functions.

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 <mark@klomp.org>
NEWS
libdw/dwarf_aggregate_size.c
libdw/dwarf_default_lower_bound.c
libdw/dwarf_getfuncs.c
libdw/dwarf_srclang.c
libdw/libdw.h
libdw/libdw.map
libdw/libdwP.h
tests/Makefile.am
tests/dwarf_language_lower_bound.c [new file with mode: 0644]