On Wed, Nov 01, 2023 at 03:03:57PM +0100, Mark Wielaard wrote: > Hi Omar, > > On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote: > > From: Omar Sandoval <osan...@fb.com> > > > > DWARF package (.dwp) files have a .debug_cu_index section and, > > optionally, a .debug_tu_index section. Add them to the list of DWARF > > sections. > > > > Unfortunately, it's not that simple: the other debug sections in a dwp > > file have names ending with .dwo, which confuses the checks introduced > > by commit 5b21e70216b8 ("libdw: dwarf_elf_begin should use either plain, > > dwo or lto DWARF sections."). So, we also have to special case > > .debug_cu_index and .debug_tu_index in scn_dwarf_type and check_section > > to treat them as TYPE_DWO sections. > > This seems to work, but I wonder if we should have a specific TYPE_DWP?
I tried this, and it made check_section even more confusing (because then we need a more complicated check than result->type == section type). I came to the same conclusion that since this is internal for now, it didn't really matter. Although maybe the name TYPE_SPLIT would make more sense now rather than overloading TYPE_DWO. When this becomes public, separate TYPE_DWO and TYPE_DWP types might be nicer so that a hypothetical dwarf_get_type function could tell you whether you got a dwo file or a dwp file. > It doesn't really matter now, because the enum dwarf_type is only used > internally. But I was hoping to extend the dwarf_begin interface with a > flag so that you can open a DWARF as a specific type. For example there > are single file split DWARF files. Which contain both "plain" and > ".dwo" sections. Currently you can only open them as "plain", but there > are actually two "views" of such files. > > https://sourceware.org/bugzilla/show_bug.cgi?id=28573 > > Do you think there are reasons to open a file as either TYPE_DWO or > TYPE_DWP? Or doesn't that not make sense? If we were to treat a dwp file as a dwo file, I guess we'd have to pretend it only contained one unit and ignore the rest, which I don't think makes much sense. So even if we had separate types for them, I don't know if we should allow that.