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

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