This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [7/10] keep track of dependencies


>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This patch introduces the dependency-tracking code for psymtabs and
Tom> symtabs.

This patch changed a little while rebasing it on top of the Fission
series.

I'm going to put it into the big final commit, but here it is split out
for easier reading.

Tom

>From e63a675d1fa95ec6a12d3f84e31bab2273098204 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Tue, 17 Apr 2012 05:20:56 -0600
Subject: [PATCH 07/10] make each partial unit into a psymtab and then a
 symtab

	* dwarf2read.c (struct dwarf2_per_cu_data) <psymtab>: Update
	comment.
	(struct partial_die_info) <locdesc>: Remove.
	<d>: New field.
	(process_psymtab_comp_unit): Add 'read_partial' argument.
	Update.
	(process_type_comp_unit, dwarf2_build_psymtabs_hard): Update.
	(scan_partial_symbols): Handle DW_TAG_imported_unit.
	(add_partial_symbol): Update.
	(process_die): Handle DW_TAG_partial_unit.
	(read_file_scope): Update comment.
	(load_partial_dies): Handle DW_TAG_imported_unit.
	(read_partial_die): Handle DW_TAG_partial_unit, DW_AT_import.
	(determine_prefix, dwarf2_name): Handle DW_TAG_partial_unit.
---
 gdb/dwarf2read.c |   73 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8964b00..d34c048 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -483,8 +483,7 @@ struct dwarf2_per_cu_data
   union
   {
     /* The partial symbol table associated with this compilation unit,
-       or NULL for partial units (which do not have an associated
-       symtab).  */
+       or NULL for unread partial units.  */
     struct partial_symtab *psymtab;
 
     /* Data needed by the "quick" functions.  */
@@ -695,8 +694,15 @@ struct partial_die_info
        when this compilation unit leaves the cache.  */
     char *scope;
 
-    /* The location description associated with this DIE, if any.  */
-    struct dwarf_block *locdesc;
+    /* Some data associated with the partial DIE.  The tag determines
+       which field is live.  */
+    union
+    {
+      /* The location description associated with this DIE, if any.  */
+      struct dwarf_block *locdesc;
+      /* The offset of an import, for DW_TAG_imported_unit.  */
+      sect_offset offset;
+    } d;
 
     /* If HAS_PC_INFO, the PC range associated with this DIE.  */
     CORE_ADDR lowpc;
@@ -1407,7 +1413,7 @@ static void init_cutu_and_read_dies_simple
 
 static htab_t allocate_signatured_type_table (struct objfile *objfile);
 
-static void process_psymtab_comp_unit (struct dwarf2_per_cu_data *);
+static void process_psymtab_comp_unit (struct dwarf2_per_cu_data *, int);
 
 static htab_t allocate_dwo_unit_table (struct objfile *objfile);
 
@@ -4014,8 +4020,11 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
   struct partial_symtab *pst;
   int has_pc_info;
   const char *filename;
+  int *want_partial_unit_ptr = data;
 
-  if (comp_unit_die->tag == DW_TAG_partial_unit)
+  if (comp_unit_die->tag == DW_TAG_partial_unit
+      && (want_partial_unit_ptr == NULL
+	  || !*want_partial_unit_ptr))
     return;
 
   prepare_one_comp_unit (cu, comp_unit_die);
@@ -4117,7 +4126,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
    Process compilation unit THIS_CU for a psymtab.  */
 
 static void
-process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu)
+process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu,
+			   int want_partial_unit)
 {
   /* If this compilation unit was already read in, free the
      cached copy in order to read it in again.	This is
@@ -4129,7 +4139,7 @@ process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu)
 
   gdb_assert (! this_cu->is_debug_types);
   init_cutu_and_read_dies (this_cu, 0, 0, process_psymtab_comp_unit_reader,
-			   NULL);
+			   &want_partial_unit);
 
   /* Age out any secondary CUs.  */
   age_cached_comp_units ();
@@ -4220,7 +4230,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
     {
       struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
 
-      process_psymtab_comp_unit (per_cu);
+      process_psymtab_comp_unit (per_cu, 0);
     }
 
   objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap,
@@ -4350,7 +4360,8 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
 	 enums.  */
 
       if (pdi->name != NULL || pdi->tag == DW_TAG_namespace
-	  || pdi->tag == DW_TAG_module || pdi->tag == DW_TAG_enumeration_type)
+	  || pdi->tag == DW_TAG_module || pdi->tag == DW_TAG_enumeration_type
+	  || pdi->tag == DW_TAG_imported_unit)
 	{
 	  switch (pdi->tag)
 	    {
@@ -4390,6 +4401,18 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
 	    case DW_TAG_module:
 	      add_partial_module (pdi, lowpc, highpc, need_pc, cu);
 	      break;
+	    case DW_TAG_imported_unit:
+	      {
+		struct dwarf2_per_cu_data *per_cu;
+
+		per_cu = dwarf2_find_containing_comp_unit (pdi->d.offset,
+							   cu->objfile);
+
+		/* Go read the partial unit, if needed.  */
+		if (per_cu->v.psymtab == NULL)
+		  process_psymtab_comp_unit (per_cu, 1);
+	      }
+	      break;
 	    default:
 	      break;
 	    }
@@ -4598,10 +4621,10 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
       }
       break;
     case DW_TAG_variable:
-      if (pdi->locdesc)
-	addr = decode_locdesc (pdi->locdesc, cu);
+      if (pdi->d.locdesc)
+	addr = decode_locdesc (pdi->d.locdesc, cu);
 
-      if (pdi->locdesc
+      if (pdi->d.locdesc
 	  && addr == 0
 	  && !dwarf2_per_objfile->has_section_at_zero)
 	{
@@ -4625,7 +4648,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	     used by GDB, but it comes in handy for debugging partial symbol
 	     table building.  */
 
-	  if (pdi->locdesc || pdi->has_type)
+	  if (pdi->d.locdesc || pdi->has_type)
 	    add_psymbol_to_list (actual_name, strlen (actual_name),
 				 built_actual_name,
 				 VAR_DOMAIN, LOC_STATIC,
@@ -4636,7 +4659,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
       else
 	{
 	  /* Static Variable.  Skip symbols without location descriptors.  */
-	  if (pdi->locdesc == NULL)
+	  if (pdi->d.locdesc == NULL)
 	    {
 	      if (built_actual_name)
 		xfree (actual_name);
@@ -5484,6 +5507,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_padding:
       break;
     case DW_TAG_compile_unit:
+    case DW_TAG_partial_unit:
       read_file_scope (die, cu);
       break;
     case DW_TAG_type_unit:
@@ -6226,7 +6250,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
     }
 }
 
-/* Process DW_TAG_compile_unit.  */
+/* Process DW_TAG_compile_unit or DW_TAG_partial_unit.  */
 
 static void
 read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
@@ -10688,7 +10712,8 @@ load_partial_dies (const struct die_reader_specs *reader,
 	  && abbrev->tag != DW_TAG_variable
 	  && abbrev->tag != DW_TAG_namespace
 	  && abbrev->tag != DW_TAG_module
-	  && abbrev->tag != DW_TAG_member)
+	  && abbrev->tag != DW_TAG_member
+	  && abbrev->tag != DW_TAG_imported_unit)
 	{
 	  /* Otherwise we skip to the next sibling, if any.  */
 	  info_ptr = skip_one_die (reader, info_ptr + bytes_read, abbrev);
@@ -10906,6 +10931,7 @@ read_partial_die (const struct die_reader_specs *reader,
 	  switch (part_die->tag)
 	    {
 	    case DW_TAG_compile_unit:
+	    case DW_TAG_partial_unit:
 	    case DW_TAG_type_unit:
 	      /* Compilation units have a DW_AT_name that is a filename, not
 		 a source language identifier.  */
@@ -10950,7 +10976,7 @@ read_partial_die (const struct die_reader_specs *reader,
           /* Support the .debug_loc offsets.  */
           if (attr_form_is_block (&attr))
             {
-	       part_die->locdesc = DW_BLOCK (&attr);
+	       part_die->d.locdesc = DW_BLOCK (&attr);
             }
           else if (attr_form_is_section_offset (&attr))
             {
@@ -11019,6 +11045,12 @@ read_partial_die (const struct die_reader_specs *reader,
 	      || DW_UNSND (&attr) == DW_INL_declared_inlined)
 	    part_die->may_be_inlined = 1;
 	  break;
+
+	case DW_AT_import:
+	  if (part_die->tag == DW_TAG_imported_unit)
+	    part_die->d.offset = dwarf2_get_ref_die_offset (&attr);
+	  break;
+
 	default:
 	  break;
 	}
@@ -14021,6 +14053,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
 	     So it does not need a prefix.  */
 	  return "";
       case DW_TAG_compile_unit:
+      case DW_TAG_partial_unit:
 	/* gcc-4.5 -gdwarf-4 can drop the enclosing namespace.  Cope.  */
 	if (cu->language == language_cplus
 	    && !VEC_empty (dwarf2_section_info_def, dwarf2_per_objfile->types)
@@ -14141,6 +14174,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
   switch (die->tag)
     {
     case DW_TAG_compile_unit:
+    case DW_TAG_partial_unit:
       /* Compilation units have a DW_AT_name that is a filename, not
 	 a source language identifier.  */
     case DW_TAG_enumeration_type:
@@ -14174,7 +14208,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
 	      if (die->tag == DW_TAG_class_type)
 		return dwarf2_name (die, cu);
 	    }
-	  while (die->tag != DW_TAG_compile_unit);
+	  while (die->tag != DW_TAG_compile_unit
+		 && die->tag != DW_TAG_partial_unit);
 	}
       break;
 
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]