* dwarf2read.c (queue_and_load_all_dwo_tus): New function.
authorDoug Evans <dje@google.com>
Wed, 4 Sep 2013 23:05:32 +0000 (23:05 +0000)
committerDoug Evans <dje@google.com>
Wed, 4 Sep 2013 23:05:32 +0000 (23:05 +0000)
(queue_and_load_dwo_tu): New function.
(lookup_dwo_signatured_type): Set per_cu.tu_read.
(maybe_queue_comp_unit): Rename this_cu argument to dependent_cu.
Make dependent_cu optional.
(dw2_do_instantiate_symtab): If we just loaded a CU from a DWO,
and an older .gdb_index is in use, queue and load all its TUs too.

testsuite/
* gdb.base/enumval.c (ZERO): New enum value.
(main): Use it
* gdb.base/enumval.exp: Test ability to print ZERO.

gdb/ChangeLog
gdb/dwarf2read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/enumval.c
gdb/testsuite/gdb.base/enumval.exp

index bd7a8fb0425da2039d91537c99e6bd8d017cb028..91fced47df91779b386d79fac38ecbf304bf846c 100644 (file)
@@ -1,3 +1,13 @@
+2013-09-04  Doug Evans  <dje@google.com>
+
+       * dwarf2read.c (queue_and_load_all_dwo_tus): New function.
+       (queue_and_load_dwo_tu): New function.
+       (lookup_dwo_signatured_type): Set per_cu.tu_read.
+       (maybe_queue_comp_unit): Rename this_cu argument to dependent_cu.
+       Make dependent_cu optional.
+       (dw2_do_instantiate_symtab): If we just loaded a CU from a DWO,
+       and an older .gdb_index is in use, queue and load all its TUs too.
+
 2013-09-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Code cleanup: Change OPF_DISABLE_REALPATH to OPF_RETURN_REALPATH.
index 59b7b01a2fe47ad1dda219a5a13d42dd937241e5..4b30e6e310d168f1d8b48a397208e9d39baea18a 100644 (file)
@@ -1778,6 +1778,8 @@ static struct dwo_unit *lookup_dwo_comp_unit
 static struct dwo_unit *lookup_dwo_type_unit
   (struct signatured_type *, const char *, const char *);
 
+static void queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *);
+
 static void free_dwo_file_cleanup (void *);
 
 static void process_cu_includes (void);
@@ -2338,6 +2340,17 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
     {
       queue_comp_unit (per_cu, language_minimal);
       load_cu (per_cu);
+
+      /* If we just loaded a CU from a DWO, and we're working with an index
+        that may badly handle TUs, load all the TUs in that DWO as well.
+        http://sourceware.org/bugzilla/show_bug.cgi?id=15021  */
+      if (!per_cu->is_debug_types
+         && per_cu->cu->dwo_unit != NULL
+         && dwarf2_per_objfile->index_table != NULL
+         && dwarf2_per_objfile->index_table->version <= 7
+         /* DWP files aren't supported yet.  */
+         && get_dwp_file () == NULL)
+       queue_and_load_all_dwo_tus (per_cu);
     }
 
   process_queue ();
@@ -4468,6 +4481,7 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
     return NULL;
 
   fill_in_sig_entry_from_dwo_entry (objfile, sig_entry, dwo_entry);
+  sig_entry->per_cu.tu_read = 1;
   return sig_entry;
 }
 
@@ -6940,8 +6954,9 @@ queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
   dwarf2_queue_tail = item;
 }
 
-/* THIS_CU has a reference to PER_CU.  If necessary, load the new compilation
-   unit and add it to our queue.
+/* If PER_CU is not yet queued, add it to the queue.
+   If DEPENDENT_CU is non-NULL, it has a reference to PER_CU so add a
+   dependency.
    The result is non-zero if PER_CU was queued, otherwise the result is zero
    meaning either PER_CU is already queued or it is already loaded.
 
@@ -6949,7 +6964,7 @@ queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
    The caller is required to load PER_CU if we return non-zero.  */
 
 static int
-maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
+maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu,
                       struct dwarf2_per_cu_data *per_cu,
                       enum language pretend_language)
 {
@@ -6965,7 +6980,8 @@ maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
 
   /* Mark the dependence relation so that we don't flush PER_CU
      too early.  */
-  dwarf2_add_dependence (this_cu, per_cu);
+  if (dependent_cu != NULL)
+    dwarf2_add_dependence (dependent_cu, per_cu);
 
   /* If it's already on the queue, we have nothing to do.  */
   if (per_cu->queued)
@@ -9828,6 +9844,55 @@ lookup_dwo_type_unit (struct signatured_type *this_tu,
   return lookup_dwo_cutu (&this_tu->per_cu, dwo_name, comp_dir, this_tu->signature, 1);
 }
 
+/* Traversal function for queue_and_load_all_dwo_tus.  */
+
+static int
+queue_and_load_dwo_tu (void **slot, void *info)
+{
+  struct dwo_unit *dwo_unit = (struct dwo_unit *) *slot;
+  struct dwarf2_per_cu_data *per_cu = (struct dwarf2_per_cu_data *) info;
+  ULONGEST signature = dwo_unit->signature;
+  struct signatured_type *sig_type =
+    lookup_dwo_signatured_type (per_cu->cu, signature);
+
+  if (sig_type != NULL)
+    {
+      struct dwarf2_per_cu_data *sig_cu = &sig_type->per_cu;
+
+      /* We pass NULL for DEPENDENT_CU because we don't yet know if there's
+        a real dependency of PER_CU on SIG_TYPE.  That is detected later
+        while processing PER_CU.  */
+      if (maybe_queue_comp_unit (NULL, sig_cu, per_cu->cu->language))
+       load_full_type_unit (sig_cu);
+      VEC_safe_push (dwarf2_per_cu_ptr, per_cu->imported_symtabs, sig_cu);
+    }
+
+  return 1;
+}
+
+/* Queue all TUs contained in the DWO of PER_CU to be read in.
+   The DWO may have the only definition of the type, though it may not be
+   referenced anywhere in PER_CU.  Thus we have to load *all* its TUs.
+   http://sourceware.org/bugzilla/show_bug.cgi?id=15021  */
+
+static void
+queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *per_cu)
+{
+  struct dwo_unit *dwo_unit;
+  struct dwo_file *dwo_file;
+
+  gdb_assert (!per_cu->is_debug_types);
+  gdb_assert (get_dwp_file () == NULL);
+  gdb_assert (per_cu->cu != NULL);
+
+  dwo_unit = per_cu->cu->dwo_unit;
+  gdb_assert (dwo_unit != NULL);
+
+  dwo_file = dwo_unit->dwo_file;
+  if (dwo_file->tus != NULL)
+    htab_traverse_noresize (dwo_file->tus, queue_and_load_dwo_tu, per_cu);
+}
+
 /* Free all resources associated with DWO_FILE.
    Close the DWO file and munmap the sections.
    All memory should be on the objfile obstack.  */
index 62d26d2c6107c8a96e180975797dbaa02bec6932..cfa5590475b1aa7d110043b7dfef72dd7d51ccf6 100644 (file)
@@ -1,4 +1,10 @@
-2013-09-13  Muhammad Bilal  <mbilal@codesourcery.com>
+2013-09-04  Doug Evans  <dje@google.com>
+
+       * gdb.base/enumval.c (ZERO): New enum value.
+       (main): Use it
+       * gdb.base/enumval.exp: Test ability to print ZERO.
+
+2013-09-03  Muhammad Bilal  <mbilal@codesourcery.com>
             Pedro Alves  <palves@redhat.com>
 
        * gdb.base/relocate.exp: Check that invalid options are
index 13e081abce7fc145fd30f150576986dab6e6619e..44d4fd0644b62b2d26c84d9554546c7512eb61ce 100644 (file)
@@ -17,6 +17,8 @@
 
 enum e { I, J = 0xffffffffU, K = 0xf000000000000000ULL } e = J, f = K;
 
+enum { ZERO };
+
 void
 dummy()
 {
@@ -26,5 +28,5 @@ int
 main(void)
 {
   dummy();
-  return 0;
+  return ZERO; /* This is here to ensure it survives into the debug info.  */
 }
index e0964fc889580c6cfb792f170bc3d128ba03ec3f..93e675283d97fd34b3fb7f07bf809483fb65c699 100644 (file)
@@ -70,3 +70,9 @@ gdb_test_multiple $test $test {
        }
     }
 }
+
+# gold/15021
+# With -fdebug-types-section, Gold's .gdb_index entry for ZERO refers to the
+# CU, but the CU doesn't use the TU (type unit) that defines ZERO.
+# Thus gdb has to read in every TU for the CU.
+gdb_test "p ZERO" "ZERO"
This page took 0.058772 seconds and 4 git commands to generate.