Blame SOURCES/gdb-6.6-buildid-locate-rpm-scl.patch

405ea9
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
405ea9
From: Fedora GDB patches <invalid@email.com>
405ea9
Date: Fri, 27 Oct 2017 21:07:50 +0200
405ea9
Subject: gdb-6.6-buildid-locate-rpm-scl.patch
405ea9
405ea9
;; [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585).
405ea9
;;=push+jan
405ea9
405ea9
warning: Skipping deprecated .gdb_index section
405ea9
https://bugzilla.redhat.com/show_bug.cgi?id=953585
405ea9
405ea9
diff --git a/gdb/build-id.c b/gdb/build-id.c
405ea9
--- a/gdb/build-id.c
405ea9
+++ b/gdb/build-id.c
405ea9
@@ -742,7 +742,11 @@ static int missing_rpm_list_entries;
405ea9
 /* Returns the count of newly added rpms.  */
405ea9
 
405ea9
 static int
405ea9
+#ifndef GDB_INDEX_VERIFY_VENDOR
405ea9
 missing_rpm_enlist (const char *filename)
405ea9
+#else
405ea9
+missing_rpm_enlist_1 (const char *filename, int verify_vendor)
405ea9
+#endif
405ea9
 {
405ea9
   static int rpm_init_done = 0;
405ea9
   rpmts ts;
405ea9
@@ -849,7 +853,11 @@ missing_rpm_enlist (const char *filename)
405ea9
   mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
405ea9
   if (mi != NULL)
405ea9
     {
405ea9
+#ifndef GDB_INDEX_VERIFY_VENDOR
405ea9
       for (;;)
405ea9
+#else
405ea9
+      if (!verify_vendor) for (;;)
405ea9
+#endif
405ea9
 	{
405ea9
 	  Header h;
405ea9
 	  char *debuginfo, **slot, *s, *s2;
405ea9
@@ -967,6 +975,37 @@ missing_rpm_enlist (const char *filename)
405ea9
 	    xfree (debuginfo);
405ea9
 	  count++;
405ea9
 	}
405ea9
+#ifdef GDB_INDEX_VERIFY_VENDOR
405ea9
+      else /* verify_vendor */
405ea9
+	{
405ea9
+	  int vendor_pass = 0, vendor_fail = 0;
405ea9
+
405ea9
+	  for (;;)
405ea9
+	    {
405ea9
+	      Header h;
405ea9
+	      errmsg_t err;
405ea9
+	      char *vendor;
405ea9
+
405ea9
+	      h = rpmdbNextIterator_p (mi);
405ea9
+	      if (h == NULL)
405ea9
+		break;
405ea9
+
405ea9
+	      vendor = headerFormat_p (h, "%{vendor}", &err;;
405ea9
+	      if (!vendor)
405ea9
+		{
405ea9
+		  warning (_("Error querying the rpm file `%s': %s"), filename,
405ea9
+			   err);
405ea9
+		  continue;
405ea9
+		}
405ea9
+	      if (strcmp (vendor, "Red Hat, Inc.") == 0)
405ea9
+		vendor_pass = 1;
405ea9
+	      else
405ea9
+		vendor_fail = 1;
405ea9
+	      xfree (vendor);
405ea9
+	    }
405ea9
+	  count = vendor_pass != 0 && vendor_fail == 0;
405ea9
+	}
405ea9
+#endif
405ea9
 
405ea9
       rpmdbFreeIterator_p (mi);
405ea9
     }
405ea9
@@ -976,6 +1015,20 @@ missing_rpm_enlist (const char *filename)
405ea9
   return count;
405ea9
 }
405ea9
 
405ea9
+#ifdef GDB_INDEX_VERIFY_VENDOR
405ea9
+missing_rpm_enlist (const char *filename)
405ea9
+{
405ea9
+  return missing_rpm_enlist_1 (filename, 0);
405ea9
+}
405ea9
+
405ea9
+extern int rpm_verify_vendor (const char *filename);
405ea9
+int
405ea9
+rpm_verify_vendor (const char *filename)
405ea9
+{
405ea9
+  return missing_rpm_enlist_1 (filename, 1);
405ea9
+}
405ea9
+#endif
405ea9
+
405ea9
 static bool
405ea9
 missing_rpm_list_compar (const char *ap, const char *bp)
405ea9
 {
405ea9
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
405ea9
--- a/gdb/dwarf2/read.c
405ea9
+++ b/gdb/dwarf2/read.c
405ea9
@@ -3034,6 +3034,16 @@ read_gdb_index_from_buffer (const char *filename,
405ea9
      "set use-deprecated-index-sections on".  */
405ea9
   if (version < 6 && !deprecated_ok)
405ea9
     {
405ea9
+#ifdef GDB_INDEX_VERIFY_VENDOR
405ea9
+      extern int rpm_verify_vendor (const char *filename);
405ea9
+
405ea9
+      /* Red Hat Developer Toolset exception.  */
405ea9
+      if (rpm_verify_vendor (filename))
405ea9
+	{}
405ea9
+      else
405ea9
+      {
405ea9
+
405ea9
+#endif
405ea9
       static int warning_printed = 0;
405ea9
       if (!warning_printed)
405ea9
 	{
405ea9
@@ -3045,6 +3055,10 @@ to use the section anyway."),
405ea9
 	  warning_printed = 1;
405ea9
 	}
405ea9
       return 0;
405ea9
+#ifdef GDB_INDEX_VERIFY_VENDOR
405ea9
+
405ea9
+      }
405ea9
+#endif
405ea9
     }
405ea9
   /* Version 7 indices generated by gold refer to the CU for a symbol instead
405ea9
      of the TU (for symbols coming from TUs),