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

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