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

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