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

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