[gdb/symtab] Fix .debug_aranges duplicate offset warning
authorTom de Vries <tdevries@suse.de>
Mon, 1 Aug 2022 12:00:59 +0000 (14:00 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 1 Aug 2022 12:00:59 +0000 (14:00 +0200)
commit75337cbc1476b7eb403fe0e73c52bf080b5996c8
tree51dd95c41ff2e84e5ff53a3800385259a9352bfd
parente4971956eab2d3091e21918b175cb999a836c057
[gdb/symtab] Fix .debug_aranges duplicate offset warning

The function read_addrmap_from_aranges contains code to issue a warning:
...
      if (!insertpair.second)
       {
         warning (_("Section .debug_aranges in %s has duplicate "
                    "debug_info_offset %s, ignoring .debug_aranges."),
                  objfile_name (objfile), sect_offset_str (per_cu->sect_off));
         return false;
       }
...
but the warning is in fact activated when all_comp_units has duplicate
entries, which is very misleading.

Fix this by:
- adding a test-case that should trigger the warning,
- replacing the current implementation of the warning with an
  assert that all_comp_units should not contain duplicates, and
- properly re-implementing the warning, such that it is triggered
  by the test-case.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29381
gdb/dwarf2/read.c
gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp [new file with mode: 0644]