]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move producer checks to dwarf2_cu
authorTom Tromey <tom@tromey.com>
Fri, 31 Jan 2025 18:25:45 +0000 (11:25 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 20 Feb 2025 00:58:04 +0000 (17:58 -0700)
This changes the various producer-checking functions to be methods on
dwarf2_cu.  It adds a few new caching members as well -- every one
that could reasonably be done this way has been converted, with the
only exception being a gdbarch hook.

Note the new asserts in the accessors.  Without the earlier
prepare_one_comp_unit change, these could trigger in some modes.

gdb/dwarf2/cu.c
gdb/dwarf2/cu.h
gdb/dwarf2/macro.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index 1029b2426bbaf2a43a12468802c834b38b2c1e37..89f52825240e12b3f1caf0c17f9d6728e5a9cfe9 100644 (file)
@@ -21,6 +21,7 @@
 #include "dwarf2/read.h"
 #include "objfiles.h"
 #include "filenames.h"
+#include "producer.h"
 #include "gdbsupport/pathstuff.h"
 
 /* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE.  */
@@ -31,17 +32,25 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
     per_objfile (per_objfile),
     m_mark (false),
     has_loclist (false),
-    checked_producer (false),
-    producer_is_gxx_lt_4_6 (false),
-    producer_is_gcc_lt_4_3 (false),
-    producer_is_gcc_11 (false),
-    producer_is_icc (false),
-    producer_is_icc_lt_14 (false),
-    producer_is_codewarrior (false),
-    producer_is_clang (false),
-    producer_is_gas_lt_2_38 (false),
-    producer_is_gas_2_39 (false),
-    producer_is_gas_ge_2_40 (false),
+    m_checked_producer (false),
+    m_producer_is_gxx_lt_4_6 (false),
+    m_producer_is_gcc_lt_4_5 (false),
+    m_producer_is_gcc_lt_4_3 (false),
+    m_producer_is_gcc_ge_4 (false),
+    m_producer_is_gcc_11 (false),
+    m_producer_is_gcc (false),
+    m_producer_is_icc (false),
+    m_producer_is_icc_lt_14 (false),
+    m_producer_is_codewarrior (false),
+    m_producer_is_clang (false),
+    m_producer_is_gas_lt_2_38 (false),
+    m_producer_is_gas_2_39 (false),
+    m_producer_is_gas_ge_2_40 (false),
+    m_producer_is_realview (false),
+    m_producer_is_xlc (false),
+    m_producer_is_xlc_opencl (false),
+    m_producer_is_gf77 (false),
+    m_producer_is_ggo (false),
     processing_has_namespace_info (false)
 {
 }
@@ -98,7 +107,7 @@ dwarf2_cu::start_compunit_symtab (const char *name, const char *comp_dir,
   const char *debugformat = debugformat_strings[this->header.version - 2];
 
   get_builder ()->record_debugformat (debugformat);
-  get_builder ()->record_producer (producer);
+  get_builder ()->record_producer (m_producer);
 
   processing_has_namespace_info = false;
 
@@ -161,3 +170,71 @@ dwarf2_cu::get_builder ()
 
   gdb_assert_not_reached ("");
 }
+
+/* See dwarf2/cu.h.  */
+
+void
+dwarf2_cu::set_producer (const char *producer)
+{
+  gdb_assert (m_producer == nullptr || strcmp (producer, m_producer) == 0);
+  m_producer = producer;
+
+  int major, minor;
+
+  if (m_producer == nullptr)
+    {
+      /* For unknown compilers expect their behavior is DWARF version
+        compliant.
+
+        GCC started to support .debug_types sections by -gdwarf-4 since
+        gcc-4.5.x.  As the .debug_types sections are missing DW_AT_producer
+        for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4
+        combination.  gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility
+        interpreted incorrectly by GDB now - GCC PR debug/48229.  */
+    }
+  else if (::producer_is_gcc (m_producer, &major, &minor))
+    {
+      m_producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6);
+      m_producer_is_gcc_lt_4_5 = major < 4 || (major == 4 && minor < 5);
+      m_producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3);
+      m_producer_is_gcc_ge_4 = major >= 4;
+      m_producer_is_gcc_11 = major == 11;
+      m_producer_is_gcc = true;
+    }
+  else if (::producer_is_icc (m_producer, &major, &minor))
+    {
+      m_producer_is_icc = true;
+      m_producer_is_icc_lt_14 = major < 14;
+    }
+  else if (startswith (m_producer, "CodeWarrior S12/L-ISA"))
+    m_producer_is_codewarrior = true;
+  else if (::producer_is_clang (m_producer, &major, &minor))
+    m_producer_is_clang = true;
+  else if (::producer_is_gas (m_producer, &major, &minor))
+    {
+      m_producer_is_gas_lt_2_38 = major < 2 || (major == 2 && minor < 38);
+      m_producer_is_gas_2_39 = major == 2 && minor == 39;
+      m_producer_is_gas_ge_2_40 = major > 2 || (major == 2 && minor >= 40);
+    }
+  else if (::producer_is_realview (m_producer))
+    m_producer_is_realview = true;
+  else if (startswith (m_producer, "IBM(R) XL C/C++ Advanced Edition"))
+    m_producer_is_xlc = true;
+  else if (strstr (m_producer, "IBM XL C for OpenCL") != nullptr)
+    m_producer_is_xlc_opencl = true;
+  else
+    {
+      /* For other non-GCC compilers, expect their behavior is DWARF version
+        compliant.  */
+    }
+
+  if (m_producer != nullptr)
+    {
+      if (strstr (m_producer, "GNU F77") != nullptr)
+       m_producer_is_gf77 = true;
+      else if (strstr (m_producer, "GNU Go ") != nullptr)
+       m_producer_is_ggo = true;
+    }
+
+  m_checked_producer = true;
+}
index a24040f4d41d135eeef63090969355b94fe322c0..b97a5403dc840317294ff7e016754500e4df858e 100644 (file)
@@ -115,9 +115,155 @@ struct dwarf2_cu
     return language_defn->la_language;
   }
 
-  const char *producer = nullptr;
+  /* Set the producer string and check various properties of it.  */
+  void set_producer (const char *producer);
+
+  /* Check for GCC PR debug/45124 fix which is not present in any G++
+     version up to 4.5.any while it is present already in G++ 4.6.0 -
+     the PR has been fixed during 4.6.0 experimental.  */
+  bool producer_is_gxx_lt_4_6 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gxx_lt_4_6;
+  }
+
+  /* Check for GCC < 4.5.x.  */
+  bool producer_is_gcc_lt_4_5 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gcc_lt_4_5;
+  }
+
+  /* Codewarrior (at least as of version 5.0.40) generates dwarf line
+     information with incorrect is_stmt attributes.  */
+  bool producer_is_codewarrior () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_codewarrior;
+  }
+
+  bool producer_is_gas_lt_2_38 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gas_lt_2_38;
+  }
+
+  bool producer_is_gas_2_39 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gas_2_39;
+  }
+
+  /* Return true if CU is produced by GAS 2.39 or later.  */
+  bool producer_is_gas_ge_2_39 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gas_2_39 || m_producer_is_gas_ge_2_40;
+  }
+
+  /* ICC<14 does not output the required DW_AT_declaration on
+     incomplete types, but gives them a size of zero.  Starting with
+     version 14, ICC is compatible with GCC.  */
+  bool producer_is_icc_lt_14 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_icc_lt_14;
+  }
+
+  /* ICC generates a DW_AT_type for C void functions.  This was
+     observed on ICC 14.0.5.212, and appears to be against the DWARF
+     spec (V5 3.3.2) which says that void functions should not have a
+     DW_AT_type.  */
+  bool producer_is_icc () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_icc;
+  }
+
+  /* Check for possibly missing DW_AT_comp_dir with relative
+     .debug_line directory paths.  GCC SVN r127613 (new option
+     -fdebug-prefix-map) fixed this, it was first present in GCC
+     release 4.3.0.  */
+  bool producer_is_gcc_lt_4_3 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gcc_lt_4_3;
+  }
+
+  /* Check for GCC 4 or later.  */
+  bool producer_is_gcc_ge_4 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gcc_ge_4;
+  }
+
+  /* Check for GCC 11 exactly.  */
+  bool producer_is_gcc_11 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gcc_11;
+  }
+
+  /* Check for any version of GCC.  */
+  bool producer_is_gcc () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gcc;
+  }
+
+  /* Return true if the producer of the inferior is clang.  */
+  bool producer_is_clang () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_clang;
+  }
+
+  /* Return true if the producer is RealView.  */
+  bool producer_is_realview () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_realview;
+  }
+
+  /* Return true if the producer is IBM XLC.  */
+  bool producer_is_xlc () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_xlc;
+  }
+
+  /* Return true if the producer is IBM XLC for OpenCL.  */
+  bool producer_is_xlc_opencl () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_xlc_opencl;
+  }
+
+  /* Return true if the producer is GNU F77.  */
+  bool producer_is_gf77 () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_gf77;
+  }
+
+  /* Return true if the producer is GNU Go.  */
+  bool producer_is_ggo () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer_is_ggo;
+  }
+
+  /* Return the producer.  In general this should not be used and
+     instead new checks should be added to set_producer.  */
+  const char *get_producer () const
+  {
+    gdb_assert (m_checked_producer);
+    return m_producer;
+  }
 
 private:
+  const char *m_producer = nullptr;
+
   /* The symtab builder for this CU.  This is only non-NULL when full
      symbols are being read.  */
   buildsym_compunit_up m_builder;
@@ -258,17 +404,25 @@ public:
      if all the producer_is_* fields are valid.  This information is cached
      because profiling CU expansion showed excessive time spent in
      producer_is_gxx_lt_4_6.  */
-  bool checked_producer : 1;
-  bool producer_is_gxx_lt_4_6 : 1;
-  bool producer_is_gcc_lt_4_3 : 1;
-  bool producer_is_gcc_11 : 1;
-  bool producer_is_icc : 1;
-  bool producer_is_icc_lt_14 : 1;
-  bool producer_is_codewarrior : 1;
-  bool producer_is_clang : 1;
-  bool producer_is_gas_lt_2_38 : 1;
-  bool producer_is_gas_2_39 : 1;
-  bool producer_is_gas_ge_2_40 : 1;
+  bool m_checked_producer : 1;
+  bool m_producer_is_gxx_lt_4_6 : 1;
+  bool m_producer_is_gcc_lt_4_5 : 1;
+  bool m_producer_is_gcc_lt_4_3 : 1;
+  bool m_producer_is_gcc_ge_4 : 1;
+  bool m_producer_is_gcc_11 : 1;
+  bool m_producer_is_gcc : 1;
+  bool m_producer_is_icc : 1;
+  bool m_producer_is_icc_lt_14 : 1;
+  bool m_producer_is_codewarrior : 1;
+  bool m_producer_is_clang : 1;
+  bool m_producer_is_gas_lt_2_38 : 1;
+  bool m_producer_is_gas_2_39 : 1;
+  bool m_producer_is_gas_ge_2_40 : 1;
+  bool m_producer_is_realview : 1;
+  bool m_producer_is_xlc : 1;
+  bool m_producer_is_xlc_opencl : 1;
+  bool m_producer_is_gf77 : 1;
+  bool m_producer_is_ggo : 1;
 
   /* When true, the file that we're processing is known to have
      debugging info for C++ namespaces.  GCC 3.3.x did not produce
index aab855ac28a6bb7ee01f4fd951f200c036ec6617..9ab9b345ef649a928437cc1e12f1ed8904ebfdf6 100644 (file)
@@ -652,7 +652,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
            complaint (_("macro debug info has an unmatched "
                         "`close_file' directive"));
          else if (current_file->included_by == nullptr
-                  && producer_is_clang (cu))
+                  && cu->producer_is_clang ())
            {
              /* Clang, until the current version, misplaces some macro
                 definitions - such as ones defined in the command line,
index f31ddb5ce1e6ce25e938d47b056f4efda8843c5c..821f761558c945b9fa0a4093c668cf3ad78cacef 100644 (file)
@@ -153,9 +153,6 @@ static int dwarf2_locexpr_block_index;
 static int dwarf2_loclist_block_index;
 static int ada_block_index;
 
-static bool producer_is_gas_lt_2_38 (struct dwarf2_cu *cu);
-static bool producer_is_gas_ge_2_39 (struct dwarf2_cu *cu);
-
 /* Size of .debug_loclists section header for 32-bit DWARF format.  */
 #define LOCLIST_HEADER_SIZE32 12
 
@@ -1175,7 +1172,6 @@ static void queue_and_load_all_dwo_tus (dwarf2_cu *cu);
 
 static void process_cu_includes (dwarf2_per_objfile *per_objfile);
 
-static void check_producer (struct dwarf2_cu *cu);
 \f
 /* Various complaints about symbol reading that don't abort the process.  */
 
@@ -5558,8 +5554,6 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
 
   if (cust != NULL)
     {
-      int gcc_4_minor = producer_is_gcc_ge_4 (cu->producer);
-
       /* Set symtab language to language from DW_AT_language.  If the
         compilation is from a C file generated by language preprocessors, do
         not set the language if it was already deduced by start_subfile.  */
@@ -5579,13 +5573,13 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
         Still one can confuse GDB by using non-standard GCC compilation
         options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
         */
-      if (cu->has_loclist && gcc_4_minor >= 5)
+      /* Note that this code traditionally did not accept non-GCC
+        compilers; that is preserved but seems potentially wrong.  */
+      if (cu->has_loclist && cu->producer_is_gcc ()
+         && !cu->producer_is_gcc_lt_4_5 ())
        cust->set_locations_valid (true);
 
-      int major, minor;
-      if (cu->producer != nullptr
-         && producer_is_gcc (cu->producer, &major, &minor)
-         && (major < 4 || (major == 4 && minor < 5)))
+      if (cu->producer_is_gcc_lt_4_5 ())
        /* Don't trust gcc < 4.5.x.  */
        cust->set_epilogue_unwind_valid (false);
       else
@@ -6574,55 +6568,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
                       &objfile->objfile_obstack);
 }
 
-/* ICC<14 does not output the required DW_AT_declaration on incomplete
-   types, but gives them a size of zero.  Starting with version 14,
-   ICC is compatible with GCC.  */
-
-static bool
-producer_is_icc_lt_14 (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_icc_lt_14;
-}
-
-/* ICC generates a DW_AT_type for C void functions.  This was observed on
-   ICC 14.0.5.212, and appears to be against the DWARF spec (V5 3.3.2)
-   which says that void functions should not have a DW_AT_type.  */
-
-static bool
-producer_is_icc (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_icc;
-}
-
-/* Check for possibly missing DW_AT_comp_dir with relative .debug_line
-   directory paths.  GCC SVN r127613 (new option -fdebug-prefix-map) fixed
-   this, it was first present in GCC release 4.3.0.  */
-
-static bool
-producer_is_gcc_lt_4_3 (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_gcc_lt_4_3;
-}
-
-/* See dwarf2/read.h.  */
-bool
-producer_is_clang (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_clang;
-}
-
 static file_and_directory &
 find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
 {
@@ -6635,7 +6580,7 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
                          dwarf2_string_attr (die, DW_AT_comp_dir, cu));
 
   if (res.get_comp_dir () == nullptr
-      && producer_is_gcc_lt_4_3 (cu)
+      && cu->producer_is_gcc_lt_4_3 ()
       && res.get_name () != nullptr
       && IS_ABSOLUTE_PATH (res.get_name ()))
     {
@@ -6776,7 +6721,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
      implicitly prefixing it with the compilation dir.  Work around this by
      prefixing it with the source dir instead.  */
   if (cu->header.version == 5 && !IS_ABSOLUTE_PATH (fnd.get_name ())
-      && producer_is_gas_lt_2_38 (cu))
+      && cu->producer_is_gas_lt_2_38 ())
     {
       attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
       if (attr != nullptr && attr->form_is_unsigned ())
@@ -9252,7 +9197,7 @@ fixup_low_high_pc (struct dwarf2_cu *cu, struct die_info *die, CORE_ADDR *low_pc
   struct gdbarch *gdbarch = objfile->arch ();
 
   if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm
-      && producer_is_gas_ge_2_39 (cu))
+      && cu->producer_is_gas_ge_2_39 ())
     {
       /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low_pc
         attribute with the thumb bit set (PR gas/31115).  Work around this.  */
@@ -10792,110 +10737,6 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
   dwarf2_record_block_entry_pc (die, block, cu);
 }
 
-/* Check whether the producer field indicates either of GCC < 4.6, or the
-   Intel C/C++ compiler, and cache the result in CU.  */
-
-static void
-check_producer (struct dwarf2_cu *cu)
-{
-  int major, minor;
-
-  if (cu->producer == NULL)
-    {
-      /* For unknown compilers expect their behavior is DWARF version
-        compliant.
-
-        GCC started to support .debug_types sections by -gdwarf-4 since
-        gcc-4.5.x.  As the .debug_types sections are missing DW_AT_producer
-        for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4
-        combination.  gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility
-        interpreted incorrectly by GDB now - GCC PR debug/48229.  */
-    }
-  else if (producer_is_gcc (cu->producer, &major, &minor))
-    {
-      cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6);
-      cu->producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3);
-      cu->producer_is_gcc_11 = major == 11;
-    }
-  else if (producer_is_icc (cu->producer, &major, &minor))
-    {
-      cu->producer_is_icc = true;
-      cu->producer_is_icc_lt_14 = major < 14;
-    }
-  else if (startswith (cu->producer, "CodeWarrior S12/L-ISA"))
-    cu->producer_is_codewarrior = true;
-  else if (producer_is_clang (cu->producer, &major, &minor))
-    cu->producer_is_clang = true;
-  else if (producer_is_gas (cu->producer, &major, &minor))
-    {
-      cu->producer_is_gas_lt_2_38 = major < 2 || (major == 2 && minor < 38);
-      cu->producer_is_gas_2_39 = major == 2 && minor == 39;
-      cu->producer_is_gas_ge_2_40 = major > 2 || (major == 2 && minor >= 40);
-    }
-  else
-    {
-      /* For other non-GCC compilers, expect their behavior is DWARF version
-        compliant.  */
-    }
-
-  cu->checked_producer = true;
-}
-
-/* Check for GCC PR debug/45124 fix which is not present in any G++ version up
-   to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed
-   during 4.6.0 experimental.  */
-
-static bool
-producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_gxx_lt_4_6;
-}
-
-
-/* Codewarrior (at least as of version 5.0.40) generates dwarf line information
-   with incorrect is_stmt attributes.  */
-
-static bool
-producer_is_codewarrior (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_codewarrior;
-}
-
-static bool
-producer_is_gas_lt_2_38 (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_gas_lt_2_38;
-}
-
-static bool
-producer_is_gas_2_39 (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_gas_2_39;
-}
-
-/* Return true if CU is produced by GAS 2.39 or later.  */
-
-static bool
-producer_is_gas_ge_2_39 (struct dwarf2_cu *cu)
-{
-  if (!cu->checked_producer)
-    check_producer (cu);
-
-  return cu->producer_is_gas_2_39 || cu->producer_is_gas_ge_2_40;
-}
-
 /* Return the accessibility of DIE, as given by DW_AT_accessibility.
    If that attribute is not available, return the appropriate
    default.  */
@@ -10915,7 +10756,7 @@ dwarf2_access_attribute (struct die_info *die, struct dwarf2_cu *cu)
                 plongest (value));
     }
 
-  if (cu->header.version < 3 || producer_is_gxx_lt_4_6 (cu))
+  if (cu->header.version < 3 || cu->producer_is_gxx_lt_4_6 ())
     {
       /* The default DWARF 2 accessibility for members is public, the default
         accessibility for inheritance is private.  */
@@ -11008,7 +10849,7 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu,
               Negative DW_AT_data_member_location
               https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101378
             */
-         if (offset == -1 && cu->producer_is_gcc_11)
+         if (offset == -1 && cu->producer_is_gcc_11 ())
            {
              complaint (_("DW_AT_data_member_location value of -1, assuming 0"));
              offset = 0;
@@ -12141,7 +11982,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
 
   maybe_set_alignment (cu, die, type);
 
-  if (producer_is_icc_lt_14 (cu) && (type->length () == 0))
+  if (cu->producer_is_icc_lt_14 () && type->length () == 0)
     {
       /* ICC<14 does not output the required DW_AT_declaration on
         incomplete types, but gives them a size of zero.  */
@@ -12153,7 +11994,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
   if (die_is_declaration (die, cu))
     type->set_is_stub (true);
   else if (attr == NULL && die->child == NULL
-          && producer_is_realview (cu->producer))
+          && cu->producer_is_realview ())
     /* RealView does not output the required DW_AT_declaration
        on incomplete types.  */
     type->set_is_stub (true);
@@ -12434,8 +12275,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
                  set_type_vptr_fieldno (type, TYPE_VPTR_FIELDNO (t));
                }
            }
-         else if (cu->producer
-                  && startswith (cu->producer, "IBM(R) XL C/C++ Advanced Edition"))
+         else if (cu->producer_is_xlc ())
            {
              /* The IBM XLC compiler does not provide direct indication
                 of the containing type, but the vtable pointer is
@@ -13264,8 +13104,7 @@ read_array_order (struct die_info *die, struct dwarf2_cu *cu)
      FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
      version checking.  */
 
-  if (cu->lang () == language_fortran
-      && cu->producer && strstr (cu->producer, "GNU F77"))
+  if (cu->lang () == language_fortran && cu->producer_is_gf77 ())
     {
       return DW_ORD_row_major;
     }
@@ -14018,7 +13857,7 @@ prototyped_function_p (struct die_info *die, struct dwarf2_cu *cu)
      prototyped and unprototyped functions; default to prototyped,
      since that is more common in modern code (and RealView warns
      about unprototyped functions).  */
-  if (producer_is_realview (cu->producer))
+  if (cu->producer_is_realview ())
     return 1;
 
   return 0;
@@ -14050,7 +13889,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
       && !type->is_stub ()
       && die->child == nullptr
       && (cu->per_cu->version () == 2
-         || producer_is_gas_2_39 (cu)))
+         || cu->producer_is_gas_2_39 ()))
     {
       /* Work around PR gas/29517, pretend we have an DW_TAG_unspecified_type
         return type.  */
@@ -14077,7 +13916,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
       && is_valid_DW_AT_calling_convention_for_subroutine (attr->constant_value (0)))
     TYPE_CALLING_CONVENTION (ftype)
       = (enum dwarf_calling_convention) attr->constant_value (0);
-  else if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL"))
+  else if (cu->producer_is_xlc_opencl ())
     TYPE_CALLING_CONVENTION (ftype) = DW_CC_GDB_IBM_OpenCL;
   else
     TYPE_CALLING_CONVENTION (ftype) = DW_CC_normal;
@@ -14197,7 +14036,8 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
   struct gdbarch *gdbarch = objfile->arch ();
   struct type *target_type = die_type (die, cu);
 
-  if (gdbarch_dwarf2_omit_typedef_p (gdbarch, target_type, cu->producer, name))
+  if (gdbarch_dwarf2_omit_typedef_p (gdbarch, target_type,
+                                    cu->get_producer (), name))
     {
       /* The long double is defined as a base type in C.  GCC creates a long
         double typedef with target-type _Float128 for the long double to
@@ -14546,7 +14386,7 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, int bits, int unsigned_p,
   /* Versions of Intel's C Compiler generate an integer type called "void"
      instead of using DW_TAG_unspecified_type.  This has been seen on
      at least versions 14, 17, and 18.  */
-  if (bits == 0 && producer_is_icc (cu) && name != nullptr
+  if (bits == 0 && cu->producer_is_icc () && name != nullptr
       && strcmp (name, "void") == 0)
     type = builtin_type (objfile)->builtin_void;
   else
@@ -17902,7 +17742,7 @@ lnp_state_machine::record_line (bool end_sequence)
       if (!end_sequence && !ignore_this_line)
        {
          linetable_entry_flags lte_flags = m_flags;
-         if (producer_is_codewarrior (m_cu))
+         if (m_cu->producer_is_codewarrior ())
            lte_flags |= LEF_IS_STMT;
 
          if (dwarf_record_line_p (m_cu, m_line, m_last_line,
@@ -21231,22 +21071,20 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu,
 
   if (comp_unit_die == nullptr)
     {
+      cu->set_producer (nullptr);
       cu->language_defn = language_def (pretend_language);
       cu->per_cu->set_unit_type (DW_UT_compile);
       cu->per_cu->set_lang (pretend_language, (dwarf_source_language) 0);
       return;
     }
 
-  cu->producer = dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu);
-  /* Re-check if needed.  */
-  cu->checked_producer = false;
+  cu->set_producer (dwarf2_string_attr (comp_unit_die, DW_AT_producer, cu));
 
   /* Set the language we're debugging.  */
   attr = dwarf2_attr (comp_unit_die, DW_AT_language, cu);
   enum language lang;
   dwarf_source_language dw_lang = (dwarf_source_language) 0;
-  if (cu->producer != nullptr
-      && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
+  if (cu->producer_is_xlc_opencl ())
     {
       /* The XLCL doesn't generate DW_LANG_OpenCL because this
         attribute is not standardised yet.  As a workaround for the
@@ -21255,8 +21093,7 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu,
       lang = language_opencl;
       dw_lang = DW_LANG_OpenCL;
     }
-  else if (cu->producer != nullptr
-          && strstr (cu->producer, "GNU Go ") != NULL)
+  else if (cu->producer_is_ggo ())
     {
       /* Similar hack for Go.  */
       lang = language_go;
@@ -21275,10 +21112,9 @@ cutu_reader::prepare_one_comp_unit (struct dwarf2_cu *cu,
   /* Initialize the lto_artificial field.  */
   attr = dwarf2_attr (comp_unit_die, DW_AT_name, cu);
   if (attr != nullptr
-      && cu->producer != nullptr
+      && cu->producer_is_gcc ()
       && attr->as_string () != nullptr
-      && strcmp (attr->as_string (), "<artificial>") == 0
-      && producer_is_gcc (cu->producer, nullptr, nullptr))
+      && strcmp (attr->as_string (), "<artificial>") == 0)
     cu->per_cu->lto_artificial = true;
 
   switch (comp_unit_die->tag)
index 56705c5a193b92e73f2970ebca7130fca2318a30..0938dacc73c34035ad1c79ea394734f8ee0fa449 100644 (file)
@@ -893,9 +893,6 @@ extern void dwarf2_get_section_info (struct objfile *,
                                     asection **, const gdb_byte **,
                                     bfd_size_type *);
 
-/* Return true if the producer of the inferior is clang.  */
-extern bool producer_is_clang (struct dwarf2_cu *cu);
-
 /* Interface for DWARF indexing methods.  */
 
 struct dwarf2_base_index_functions : public quick_symbol_functions