[PATCH] dwarf: Dump .debug_loclists only for DWARF-5

Jan Beulich jbeulich@suse.com
Mon Mar 24 08:56:21 GMT 2025
On 21.03.2025 16:23, H.J. Lu wrote:
> On Fri, Mar 21, 2025 at 12:28 AM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 20.03.2025 21:27, H.J. Lu wrote:
>>> --- a/binutils/dwarf.c
>>> +++ b/binutils/dwarf.c
>>> @@ -7324,7 +7324,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
>>>    unsigned int *array = NULL;
>>>    const char *suffix = strrchr (section->name, '.');
>>>    bool is_dwo = false;
>>> -  int is_loclists = strstr (section->name, "debug_loclists") != NULL;
>>> +  bool is_loclists = strstr (section->name, "debug_loclists") != NULL;
>>>    uint64_t next_header_offset = 0;
>>>
>>>    if (suffix && strcmp (suffix, ".dwo") == 0)
>>> @@ -7450,6 +7450,11 @@ display_debug_loc (struct dwarf_section *section, void *file)
>>>        debug_info *debug_info_p = debug_information + i;
>>>        uint32_t offset_count;
>>>
>>> +      /* Dump .debug_loclists only for DWARF-5 and dump .debug_loc only
>>> +      for pre-DWARF-5.  */
>>> +      if ((debug_info_p->dwarf_version == 5) != is_loclists)
>>> +     continue;
>>
>> Comment and code aren't quite in sync: What about versions above 5? Aren't our
>> chances better to stay correct if, until we know otherwise, we treat higher
>> versions like 5, not like 4 and earlier?
> 
> I was following
> 
> if (debug_info_p->dwarf_version == 5)
> 
> a few lines below.  I guess since DWARF-5 added .debug_loclists, we don't know
> if it will be different in the future.

Well, between things staying the same in Dwarf6 and things moving back to what
Dwarf4 had, which one do you think is more likely? If things changed again, we'd
be screwed anyway (unless we properly bailed out in such cases).

But at the very least a comment should accurately describe the code it's related
to at the time of its introduction. It's bad enough that comments easily go stale
later on.

Jan


More information about the Binutils mailing list