offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
struct dwz_file *dwz;
struct objfile *objfile = per_objfile->objfile;
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
gdb::array_view<const gdb_byte> main_index_contents
- = get_gdb_index_contents (objfile, per_objfile->per_bfd);
+ = get_gdb_index_contents (objfile, per_bfd);
if (main_index_contents.empty ())
return 0;
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+ dwz = dwarf2_get_dwz_file (per_bfd);
if (dwz != NULL)
{
struct mapped_index dwz_map;
}
}
- create_cus_from_index (per_objfile->per_bfd, cu_list, cu_list_elements,
- dwz_list, dwz_list_elements);
+ create_cus_from_index (per_bfd, cu_list, cu_list_elements, dwz_list,
+ dwz_list_elements);
if (types_list_elements)
{
/* We can only handle a single .debug_types when we have an
index. */
- if (per_objfile->per_bfd->types.size () != 1)
+ if (per_bfd->types.size () != 1)
return 0;
- dwarf2_section_info *section = &per_objfile->per_bfd->types[0];
+ dwarf2_section_info *section = &per_bfd->types[0];
- create_signatured_type_table_from_index (per_objfile->per_bfd,
- section, types_list,
+ create_signatured_type_table_from_index (per_bfd, section, types_list,
types_list_elements);
}
create_addrmap_from_index (per_objfile, map.get ());
- per_objfile->per_bfd->index_table = std::move (map);
- per_objfile->per_bfd->using_index = 1;
- per_objfile->per_bfd->quick_file_names_table =
- create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ());
+ per_bfd->index_table = std::move (map);
+ per_bfd->using_index = 1;
+ per_bfd->quick_file_names_table =
+ create_quick_file_names_table (per_bfd->all_comp_units.size ());
+
+ /* Save partial symtabs in the per_bfd object, for the benefit of subsequent
+ objfiles using the same BFD. */
+ gdb_assert (per_bfd->partial_symtabs == nullptr);
+ per_bfd->partial_symtabs = objfile->partial_symtabs;
return 1;
}
std::unique_ptr<mapped_debug_names> map (new mapped_debug_names);
mapped_debug_names dwz_map;
struct objfile *objfile = per_objfile->objfile;
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
if (!read_debug_names_from_section (objfile, objfile_name (objfile),
&per_objfile->per_bfd->debug_names, *map))
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+ dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
if (dwz != NULL)
{
if (!read_debug_names_from_section (objfile,
}
}
- create_cus_from_debug_names (per_objfile->per_bfd, *map, dwz_map);
+ create_cus_from_debug_names (per_bfd, *map, dwz_map);
if (map->tu_count != 0)
{
/* We can only handle a single .debug_types when we have an
index. */
- if (per_objfile->per_bfd->types.size () != 1)
+ if (per_bfd->types.size () != 1)
return false;
- dwarf2_section_info *section = &per_objfile->per_bfd->types[0];
+ dwarf2_section_info *section = &per_bfd->types[0];
create_signatured_type_table_from_debug_names
- (per_objfile, *map, section, &per_objfile->per_bfd->abbrev);
+ (per_objfile, *map, section, &per_bfd->abbrev);
}
- create_addrmap_from_aranges (per_objfile,
- &per_objfile->per_bfd->debug_aranges);
+ create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges);
- per_objfile->per_bfd->debug_names_table = std::move (map);
- per_objfile->per_bfd->using_index = 1;
- per_objfile->per_bfd->quick_file_names_table =
+ per_bfd->debug_names_table = std::move (map);
+ per_bfd->using_index = 1;
+ per_bfd->quick_file_names_table =
create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ());
+ /* Save partial symtabs in the per_bfd object, for the benefit of subsequent
+ objfiles using the same BFD. */
+ gdb_assert (per_bfd->partial_symtabs == nullptr);
+ per_bfd->partial_symtabs = objfile->partial_symtabs;
+
return true;
}
if (per_bfd->debug_names_table != nullptr)
{
*index_kind = dw_index_kind::DEBUG_NAMES;
+ per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs;
per_objfile->resize_symtabs ();
return true;
}
if (per_bfd->index_table != nullptr)
{
*index_kind = dw_index_kind::GDB_INDEX;
+ per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs;
per_objfile->resize_symtabs ();
return true;
}
case DW_TAG_subprogram:
case DW_TAG_inlined_subroutine:
add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu);
+ if (cu->language == language_cplus)
+ scan_partial_symbols (pdi->die_child, lowpc, highpc,
+ set_addrmap, cu);
break;
case DW_TAG_constant:
case DW_TAG_variable:
((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field)));
/* Put the discriminant at index 0. */
- TYPE_FIELD_TYPE (type, 0) = field_type;
+ type->field (0).set_type (field_type);
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
SET_FIELD_BITPOS (type->field (0), bit_offset);
name);
struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0,
dataless_name);
- TYPE_FIELD_TYPE (type, 2) = dataless_type;
+ type->field (2).set_type (dataless_type);
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
TYPE_FIELD_NAME (type, 2) = name;
/* Data member other than a C++ static data member. */
/* Get type of field. */
- fp->type = die_type (die, cu);
+ fp->set_type (die_type (die, cu));
SET_FIELD_BITPOS (*fp, 0);
the bit field must be inferred from the type
attribute of the data member containing the
bit field. */
- anonymous_size = TYPE_LENGTH (fp->type);
+ anonymous_size = TYPE_LENGTH (fp->type ());
}
SET_FIELD_BITPOS (*fp,
(FIELD_BITPOS (*fp)
/* The name is already allocated along with this objfile, so we don't
need to duplicate it for the type. */
SET_FIELD_PHYSNAME (*fp, physname ? physname : "");
- FIELD_TYPE (*fp) = die_type (die, cu);
+ fp->set_type (die_type (die, cu));
FIELD_NAME (*fp) = fieldname;
}
else if (die->tag == DW_TAG_inheritance)
/* C++ base class field. */
handle_data_member_location (die, cu, fp);
FIELD_BITSIZE (*fp) = 0;
- FIELD_TYPE (*fp) = die_type (die, cu);
- FIELD_NAME (*fp) = fp->type->name ();
+ fp->set_type (die_type (die, cu));
+ FIELD_NAME (*fp) = fp->type ()->name ();
}
else
gdb_assert_not_reached ("missing case in dwarf2_add_field");
/* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it
even if we error out during the parameters reading below. */
for (iparams = 0; iparams < nparams; iparams++)
- TYPE_FIELD_TYPE (ftype, iparams) = void_type;
+ ftype->field (iparams).set_type (void_type);
iparams = 0;
child_die = die->child;
arg_type, 0);
}
- TYPE_FIELD_TYPE (ftype, iparams) = arg_type;
+ ftype->field (iparams).set_type (arg_type);
iparams++;
}
child_die = child_die->sibling;
if (!load_all
&& cu->language == language_cplus
&& parent_die != NULL
- && parent_die->tag == DW_TAG_subprogram)
+ && parent_die->tag == DW_TAG_subprogram
+ && abbrev->tag != DW_TAG_inlined_subroutine)
{
info_ptr = skip_one_die (reader, info_ptr + bytes_read, abbrev);
continue;
/* The last file a line number was recorded for. */
struct subfile *m_last_subfile = NULL;
+ /* The address of the last line entry. */
+ CORE_ADDR m_last_address;
+
+ /* Set to true when a previous line at the same address (using
+ m_last_address) had m_is_stmt true. This is reset to false when a
+ line entry at a new address (m_address different to m_last_address) is
+ processed. */
+ bool m_stmt_at_address = false;
+
/* When true, record the lines we decode. */
bool m_currently_recording_lines = false;
fe->included_p = 1;
if (m_record_lines_p)
{
- if (m_last_subfile != m_cu->get_builder ()->get_current_subfile ()
- || end_sequence)
+ /* When we switch files we insert an end maker in the first file,
+ switch to the second file and add a new line entry. The
+ problem is that the end marker inserted in the first file will
+ discard any previous line entries at the same address. If the
+ line entries in the first file are marked as is-stmt, while
+ the new line in the second file is non-stmt, then this means
+ the end marker will discard is-stmt lines so we can have a
+ non-stmt line. This means that there are less addresses at
+ which the user can insert a breakpoint.
+
+ To improve this we track the last address in m_last_address,
+ and whether we have seen an is-stmt at this address. Then
+ when switching files, if we have seen a stmt at the current
+ address, and we are switching to create a non-stmt line, then
+ discard the new line. */
+ bool file_changed
+ = m_last_subfile != m_cu->get_builder ()->get_current_subfile ();
+ bool ignore_this_line
+ = (file_changed && !end_sequence && m_last_address == m_address
+ && !m_is_stmt && m_stmt_at_address);
+
+ if ((file_changed && !ignore_this_line) || end_sequence)
{
dwarf_finish_line (m_gdbarch, m_last_subfile, m_address,
m_currently_recording_lines ? m_cu : nullptr);
}
- if (!end_sequence)
+ if (!end_sequence && !ignore_this_line)
{
bool is_stmt = producer_is_codewarrior (m_cu) || m_is_stmt;
}
}
}
+
+ /* Track whether we have seen any m_is_stmt true at m_address in case we
+ have multiple line table entries all at m_address. */
+ if (m_last_address != m_address)
+ {
+ m_stmt_at_address = false;
+ m_last_address = m_address;
+ }
+ m_stmt_at_address |= m_is_stmt;
}
lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch,
m_address = gdbarch_adjust_dwarf2_line (arch, 0, 0);
m_is_stmt = lh->default_is_stmt;
m_discriminator = 0;
+
+ m_last_address = m_address;
+ m_stmt_at_address = false;
}
void