+2021-05-17 Tom Tromey <tom@tromey.com>
+
+ * dwarf2/read.c (maybe_queue_comp_unit)
+ (dwarf2_per_objfile::age_comp_units): Update.
+ (dwarf2_add_dependence, dwarf2_mark_helper, dwarf2_mark): Move to
+ dwarf2_cu methods.
+ * dwarf2/cu.h (struct dwarf2_cu) <mark, clear_mark, is_marked,
+ add_dependence>: New methods.
+ <m_dependencies>: Add "m_" prefix. Now private.
+ <m_mark>: Add "m_" prefix.
+ * dwarf2/cu.c (dwarf2_cu::dwarf2_cu): Update.
+ (dwarf2_mark_helper): New function.
+ (dwarf2_cu::mark, dwarf2_cu::add_dependence): New methods.
+
2021-05-17 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_cu::addr_sized_int_type)
dwarf2_per_objfile *per_objfile)
: per_cu (per_cu),
per_objfile (per_objfile),
- mark (false),
+ m_mark (false),
has_loclist (false),
checked_producer (false),
producer_is_gxx_lt_4_6 (false),
addr_type = addr_sized_int_type (addr_type->is_unsigned ());
return addr_type;
}
+
+/* A hashtab traversal function that marks the dependent CUs. */
+
+static int
+dwarf2_mark_helper (void **slot, void *data)
+{
+ dwarf2_per_cu_data *per_cu = (dwarf2_per_cu_data *) *slot;
+ dwarf2_per_objfile *per_objfile = (dwarf2_per_objfile *) data;
+ dwarf2_cu *cu = per_objfile->get_cu (per_cu);
+
+ /* cu->m_dependencies references may not yet have been ever read if
+ QUIT aborts reading of the chain. As such dependencies remain
+ valid it is not much useful to track and undo them during QUIT
+ cleanups. */
+ if (cu != nullptr)
+ cu->mark ();
+ return 1;
+}
+
+/* See dwarf2/cu.h. */
+
+void
+dwarf2_cu::mark ()
+{
+ if (!m_mark)
+ {
+ m_mark = true;
+ if (m_dependencies != nullptr)
+ htab_traverse (m_dependencies, dwarf2_mark_helper, per_objfile);
+ }
+}
+
+/* See dwarf2/cu.h. */
+
+void
+dwarf2_cu::add_dependence (struct dwarf2_per_cu_data *ref_per_cu)
+{
+ void **slot;
+
+ if (m_dependencies == nullptr)
+ m_dependencies
+ = htab_create_alloc_ex (5, htab_hash_pointer, htab_eq_pointer,
+ NULL, &comp_unit_obstack,
+ hashtab_obstack_allocate,
+ dummy_obstack_deallocate);
+
+ slot = htab_find_slot (m_dependencies, ref_per_cu, INSERT);
+ if (*slot == nullptr)
+ *slot = ref_per_cu;
+}
the integer is unsigned or not. */
struct type *addr_sized_int_type (bool unsigned_p) const;
+ /* Mark this CU as used. */
+ void mark ();
+
+ /* Clear the mark on this CU. */
+ void clear_mark ()
+ {
+ m_mark = false;
+ }
+
+ /* True if this CU has been marked. */
+ bool is_marked () const
+ {
+ return m_mark;
+ }
+
+ /* Add a dependence relationship from this cu to REF_PER_CU. */
+ void add_dependence (struct dwarf2_per_cu_data *ref_per_cu);
+
/* The header of the compilation unit. */
struct comp_unit_head header {};
symbols are being read. */
std::unique_ptr<buildsym_compunit> m_builder;
+ /* A set of pointers to dwarf2_per_cu_data objects for compilation
+ units referenced by this one. Only set during full symbol processing;
+ partial symbol tables do not have dependencies. */
+ htab_t m_dependencies = nullptr;
+
public:
/* The generic symbol table building routines have separate lists for
file scope symbols and all all other scopes (local scopes). So
/* Full DIEs if read in. */
struct die_info *dies = nullptr;
- /* A set of pointers to dwarf2_per_cu_data objects for compilation
- units referenced by this one. Only set during full symbol processing;
- partial symbol tables do not have dependencies. */
- htab_t dependencies = nullptr;
-
/* Header data from the line table, during full symbol processing. */
struct line_header *line_header = nullptr;
/* Non-NULL if LINE_HEADER is owned by this DWARF_CU. Otherwise,
gdb::optional<ULONGEST> str_offsets_base;
/* Mark used when releasing cached dies. */
- bool mark : 1;
+ bool m_mark : 1;
/* This CU references .debug_loc. See the symtab->locations_valid field.
This test is imperfect as there may exist optimized debug code not using
static void process_full_type_unit (dwarf2_cu *cu,
enum language pretend_language);
-static void dwarf2_add_dependence (struct dwarf2_cu *,
- struct dwarf2_per_cu_data *);
-
-static void dwarf2_mark (struct dwarf2_cu *);
-
static struct type *get_die_type_at_offset (sect_offset,
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
/* Mark the dependence relation so that we don't flush PER_CU
too early. */
if (dependent_cu != NULL)
- dwarf2_add_dependence (dependent_cu, per_cu);
+ dependent_cu->add_dependence (per_cu);
/* If it's already on the queue, we have nothing to do. */
if (per_cu->queued)
/* Start by clearing all marks. */
for (auto pair : m_dwarf2_cus)
- pair.second->mark = false;
+ pair.second->clear_mark ();
/* Traverse all CUs, mark them and their dependencies if used recently
enough. */
cu->last_used++;
if (cu->last_used <= dwarf_max_cache_age)
- dwarf2_mark (cu);
+ cu->mark ();
}
/* Delete all CUs still not marked. */
{
dwarf2_cu *cu = it->second;
- if (!cu->mark)
+ if (!cu->is_marked ())
{
dwarf_read_debug_printf_v ("deleting old CU %s",
sect_offset_str (cu->per_cu->sect_off));
return get_die_type_at_offset (die->sect_off, cu->per_cu, cu->per_objfile);
}
-/* Add a dependence relationship from CU to REF_PER_CU. */
-
-static void
-dwarf2_add_dependence (struct dwarf2_cu *cu,
- struct dwarf2_per_cu_data *ref_per_cu)
-{
- void **slot;
-
- if (cu->dependencies == NULL)
- cu->dependencies
- = htab_create_alloc_ex (5, htab_hash_pointer, htab_eq_pointer,
- NULL, &cu->comp_unit_obstack,
- hashtab_obstack_allocate,
- dummy_obstack_deallocate);
-
- slot = htab_find_slot (cu->dependencies, ref_per_cu, INSERT);
- if (*slot == NULL)
- *slot = ref_per_cu;
-}
-
-/* Subroutine of dwarf2_mark to pass to htab_traverse.
- Set the mark field in every compilation unit in the
- cache that we must keep because we are keeping CU.
-
- DATA is the dwarf2_per_objfile object in which to look up CUs. */
-
-static int
-dwarf2_mark_helper (void **slot, void *data)
-{
- dwarf2_per_cu_data *per_cu = (dwarf2_per_cu_data *) *slot;
- dwarf2_per_objfile *per_objfile = (dwarf2_per_objfile *) data;
- dwarf2_cu *cu = per_objfile->get_cu (per_cu);
-
- /* cu->dependencies references may not yet have been ever read if QUIT aborts
- reading of the chain. As such dependencies remain valid it is not much
- useful to track and undo them during QUIT cleanups. */
- if (cu == nullptr)
- return 1;
-
- if (cu->mark)
- return 1;
-
- cu->mark = true;
-
- if (cu->dependencies != nullptr)
- htab_traverse (cu->dependencies, dwarf2_mark_helper, per_objfile);
-
- return 1;
-}
-
-/* Set the mark field in CU and in every other compilation unit in the
- cache that we must keep because we are keeping CU. */
-
-static void
-dwarf2_mark (struct dwarf2_cu *cu)
-{
- if (cu->mark)
- return;
-
- cu->mark = true;
-
- if (cu->dependencies != nullptr)
- htab_traverse (cu->dependencies, dwarf2_mark_helper, cu->per_objfile);
-}
-
/* Trivial hash function for partial_die_info: the hash value of a DIE
is its offset in .debug_info for this objfile. */