Hi Omar, On Mon, Feb 26, 2024 at 11:32:48AM -0800, Omar Sandoval wrote: > 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.
And it cleans up the code nicely. > Also add a test case for dwarf_decl_file. Thanks. > > * 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. All looks good. Pushed. Cheers, Mark