if (table == nullptr)
error (_("Cannot use an index to create the index"));
+ if (per_bfd->infos.size () > 1)
+ error (_("Cannot make an index when the file has multiple .debug_info"
+ " sections"));
if (per_bfd->types.size () > 1)
error (_("Cannot make an index when the file has multiple .debug_types sections"));
const mapped_debug_names_reader &map,
const mapped_debug_names_reader &dwz_map)
{
- if (!check_cus_from_debug_names_list (per_bfd, map, per_bfd->info,
+ if (!check_cus_from_debug_names_list (per_bfd, map, per_bfd->infos[0],
false /* is_dwz */))
return false;
if (map.tu_count != 0)
{
- /* We can only handle a single .debug_types when we have an
- index. */
- if (per_bfd->types.size () > 1)
+ /* We can only handle a single .debug_info and .debug_types when we have
+ an index. */
+ if (per_bfd->infos.size () > 1
+ || per_bfd->types.size () > 1)
return false;
dwarf2_section_info *section
= (per_bfd->types.size () == 1
? &per_bfd->types[0]
- : &per_bfd->info);
+ : &per_bfd->infos[0]);
if (!check_signatured_type_table_from_debug_names (per_objfile,
map, section))
per_bfd->all_units.reserve ((cu_list_elements + dwz_elements) / 2);
create_cus_from_gdb_index_list (per_bfd, cu_list, cu_list_elements,
- &per_bfd->info, 0);
+ &per_bfd->infos[0], 0);
if (dwz_elements == 0)
return;
if (types_list_elements)
{
- /* We can only handle a single .debug_types when we have an
- index. */
- if (per_bfd->types.size () > 1)
+ /* We can only handle a single .debug_info and .debug_types when we have
+ an index. */
+ if (per_bfd->infos.size () > 1
+ || per_bfd->types.size () > 1)
{
per_bfd->all_units.clear ();
return 0;
dwarf2_section_info *section
= (per_bfd->types.size () == 1
? &per_bfd->types[0]
- : &per_bfd->info);
+ : &per_bfd->infos[0]);
create_signatured_type_table_from_gdb_index (per_bfd, section, types_list,
types_list_elements);
per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd);
}
- const bool has_info = (!per_objfile->per_bfd->info.is_virtual
- && per_objfile->per_bfd->info.s.section != nullptr
+ /* Virtual sections are created from DWP files. It's not clear those
+ can occur here, so perhaps the is_virtual checks here are dead code. */
+ const bool has_info = (!per_objfile->per_bfd->infos.empty ()
+ && !per_objfile->per_bfd->infos[0].is_virtual
+ && per_objfile->per_bfd->infos[0].s.section != nullptr
&& !per_objfile->per_bfd->abbrev.is_virtual
&& per_objfile->per_bfd->abbrev.s.section != nullptr);
}
else if (names.info.matches (sectp->name))
{
- this->info.s.section = sectp;
- this->info.size = bfd_section_size (sectp);
+ struct dwarf2_section_info info_section;
+ memset (&info_section, 0, sizeof (info_section));
+ info_section.s.section = sectp;
+ info_section.size = bfd_section_size (sectp);
+ this->infos.push_back (info_section);
}
else if (names.abbrev.matches (sectp->name))
{
void
dwarf2_per_bfd::map_info_sections (struct objfile *objfile)
{
- info.read (objfile);
+ for (auto §ion : infos)
+ section.read (objfile);
+
abbrev.read (objfile);
line.read (objfile);
str.read (objfile);
htab_up types_htab;
gdb_assert (per_objfile->per_bfd->all_units.empty ());
- read_comp_units_from_section (per_objfile, &per_objfile->per_bfd->info,
- &per_objfile->per_bfd->abbrev, 0,
- types_htab, rcuh_kind::COMPILE);
+ for (dwarf2_section_info §ion : per_objfile->per_bfd->infos)
+ read_comp_units_from_section (per_objfile, §ion,
+ &per_objfile->per_bfd->abbrev, 0,
+ types_htab, rcuh_kind::COMPILE);
for (dwarf2_section_info §ion : per_objfile->per_bfd->types)
read_comp_units_from_section (per_objfile, §ion,
&per_objfile->per_bfd->abbrev, 0,
the objfile obstack. */
auto_obstack obstack;
- dwarf2_section_info info {};
+ std::vector<dwarf2_section_info> infos;
dwarf2_section_info abbrev {};
dwarf2_section_info line {};
dwarf2_section_info loc {};
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+namespace sp1 {
+ class A {
+ int i;
+ const int c1 = 1;
+ const int c2 = 2;
+ const int c3 = 3;
+ const int c4 = 4;
+ const int c5 = 5;
+ const int c6 = 6;
+ const int c7 = 7;
+ const int c8 = 8;
+ const int c9 = 9;
+ const int c10 = 10;
+ };
+}
+
+sp1::A a;
+
+int
+main (void)
+{
+ return 0;
+}
--- /dev/null
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile .c
+
+set opts {}
+lappend opts debug
+lappend opts dwarf5
+lappend opts c++
+lappend opts additional_flags=-fdebug-types-section
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" object \
+ $opts] != "" } {
+ return -1
+}
+
+clean_restart $binfile
+
+gdb_test "ptype a" "type = class sp1::A .*"