]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libdw: Handle split DWARF in dwarf_decl_file
authorOmar Sandoval <osandov@fb.com>
Mon, 26 Feb 2024 19:32:48 +0000 (11:32 -0800)
committerMark Wielaard <mark@klomp.org>
Thu, 29 Feb 2024 21:57:09 +0000 (22:57 +0100)
commit2ceed6d40ff1606622b51ce0c8ece3d13454ef23
treeccdffa8201054964fa5cef9bf1456a7509393d08
parent05bea78f46f6a0cbe13402dca0b5a363ecf66cb1
libdw: Handle split DWARF in dwarf_decl_file

Calling dwarf_decl_file on a split DWARF DIE fails this assertion:

  dwarf_decl_file.c:72: dwarf_decl_file: Assertion `cu->files != NULL && cu->files != (void *) -1l' failed.

This is because dwarf_decl_file calls dwarf_getsrclines to populate
cu->files.  For normal units, cu->files is cached by dwarf_getsrclines
when it parses the line number information.  However, for split units,
the line number information is parsed for the skeleton unit, then copied
to the split unit's cu->lines.  Split units have their own file name
table, so cu->files is not copied.

The obvious solution is to use dwarf_getsrcfiles instead of relying on
implicit caching.

Also add a test case for dwarf_decl_file.

* libdw/dwarf_decl_file.c (dwarf_decl_file): Use
dwarf_getsrcfiles instead of dwarf_getsrclines.
* tests/Makefile.am (check_PROGRAMS): Add declfiles.
(TESTS): Add run-declfiles.sh.
(EXTRA_DIST): Add run-declfiles.sh.
(declfiles_LDADD): New variable.
* tests/declfiles.c: New test.
* tests/run-declfiles.sh: New test.

Signed-off-by: Omar Sandoval <osandov@fb.com>
libdw/dwarf_decl_file.c
tests/.gitignore
tests/Makefile.am
tests/declfiles.c [new file with mode: 0644]
tests/run-declfiles.sh [new file with mode: 0755]