[packages/gdb] - up to 8.1

arekm arekm at pld-linux.org
Sun Feb 4 09:57:19 CET 2018


commit 4b0e5c1bdb8bb8711a8994ccd38895107a2fe662
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Feb 4 09:57:12 2018 +0100

    - up to 8.1

 gdb-6.3-gstack-20050411.patch                      |  154 +-
 gdb-6.6-buildid-locate-core-as-arg.patch           |   87 +-
 ...ding-warning-missing-debuginfo-rhbz981154.patch |   61 +-
 gdb-6.6-buildid-locate-rpm-librpm-workaround.patch |   51 +-
 gdb-6.6-buildid-locate-rpm-scl.patch               |   43 +-
 gdb-6.6-buildid-locate-rpm.patch                   | 2093 ++++++++++----------
 gdb-6.6-buildid-locate-solib-missing-ids.patch     |  155 +-
 gdb-6.6-buildid-locate.patch                       |  899 +++++----
 gdb-archer-vla-tests.patch                         |  520 +++--
 gdb-gdb-add-index-script.patch                     |  140 +-
 gdb-readline.patch                                 |    4 +-
 gdb-vla-intel-fortran-strides.patch                |  394 ++--
 gdb-vla-intel-fortran-vla-strings.patch            |  450 ++---
 gdb-vla-intel-stringbt-fix.patch                   |   66 +-
 gdb-vla-intel-tests.patch                          |   58 +-
 gdb.spec                                           |    5 +-
 16 files changed, 2764 insertions(+), 2416 deletions(-)
---
diff --git a/gdb.spec b/gdb.spec
index f841387..0b7dd91 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -19,14 +19,13 @@ Summary(tr.UTF-8):	C ve diğer diller için sembolik hata ayıklayıcı
 Summary(uk.UTF-8):	Символьний відладчик для С та інших мов
 Summary(zh_CN.UTF-8):	[开发]C和其他语言的调试器
 Summary(zh_TW.UTF-8):	[.-A開發]C和.$)B其.-A他語.$)B言的調試器
-%define		snap	20120926
 Name:		gdb
-Version:	8.0.1
+Version:	8.1
 Release:	1
 License:	GPL v3+
 Group:		Development/Debuggers
 Source0:	http://ftp.gnu.org/gnu/gdb/%{name}-%{version}.tar.xz
-# Source0-md5:	48cac527e6f3018b865ece021e9723ac
+# Source0-md5:	f46487561f9a16916a8102316f7fd105
 Source1:	http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2
 # Source1-md5:	2e8a48939ae282c12bbacdd54e398247
 Source3:	%{name}-gstack.man
diff --git a/gdb-6.3-gstack-20050411.patch b/gdb-6.3-gstack-20050411.patch
index f1e9e3a..3619504 100644
--- a/gdb-6.3-gstack-20050411.patch
+++ b/gdb-6.3-gstack-20050411.patch
@@ -1,14 +1,34 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Andrew Cagney <cagney at gnu.org>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: gdb-6.3-gstack-20050411.patch
+
+FileName: gdb-6.3-gstack-20050411.patch
+
+;; Add a wrapper script to GDB that implements pstack using the
+;; --readnever option.
+;;=push
+
 2004-11-23  Andrew Cagney  <cagney at redhat.com>
 
 	* Makefile.in (uninstall-gstack, install-gstack): New rules, add
 	to install and uninstall.
 	* gstack.sh, gstack.1: New files.
+---
+ gdb/Makefile.in                   | 34 ++++++++++++++++++--
+ gdb/gstack.sh                     | 43 +++++++++++++++++++++++++
+ gdb/testsuite/gdb.base/gstack.c   | 43 +++++++++++++++++++++++++
+ gdb/testsuite/gdb.base/gstack.exp | 66 +++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 184 insertions(+), 2 deletions(-)
+ create mode 100644 gdb/gstack.sh
+ create mode 100644 gdb/testsuite/gdb.base/gstack.c
+ create mode 100644 gdb/testsuite/gdb.base/gstack.exp
 
-Index: gdb-7.7/gdb/Makefile.in
-===================================================================
---- gdb-7.7.orig/gdb/Makefile.in	2014-02-06 20:29:09.401214339 +0100
-+++ gdb-7.7/gdb/Makefile.in	2014-02-06 20:29:09.501214360 +0100
-@@ -1067,7 +1067,7 @@ info install-info clean-info dvi pdf ins
+diff --git a/gdb/Makefile.in b/gdb/Makefile.in
+index 17b71c6e7c..e77d6a5c03 100644
+--- a/gdb/Makefile.in
++++ b/gdb/Makefile.in
+@@ -1744,7 +1744,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
  install: all
  	@$(MAKE) $(FLAGS_TO_PASS) install-only
  
@@ -17,7 +37,7 @@ Index: gdb-7.7/gdb/Makefile.in
  	transformed_name=`t='$(program_transform_name)'; \
  			  echo gdb | sed -e "$$t"` ; \
  		if test "x$$transformed_name" = x; then \
-@@ -1104,7 +1104,25 @@ install-strip:
+@@ -1784,7 +1784,25 @@ install-guile:
  install-python:
  	$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
  
@@ -44,7 +64,7 @@ Index: gdb-7.7/gdb/Makefile.in
  	transformed_name=`t='$(program_transform_name)'; \
  			  echo gdb | sed -e $$t` ; \
  		if test "x$$transformed_name" = x; then \
-@@ -1127,6 +1145,18 @@ uninstall: force $(CONFIG_UNINSTALL)
+@@ -1807,6 +1825,18 @@ uninstall: force $(CONFIG_UNINSTALL)
  	fi
  	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
  
@@ -63,10 +83,11 @@ Index: gdb-7.7/gdb/Makefile.in
  # The C++ name parser can be built standalone for testing.
  test-cp-name-parser.o: cp-name-parser.c
  	$(COMPILE) -DTEST_CPNAMES cp-name-parser.c
-Index: gdb-7.7/gdb/gstack.sh
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.7/gdb/gstack.sh	2014-02-06 20:29:09.501214360 +0100
+diff --git a/gdb/gstack.sh b/gdb/gstack.sh
+new file mode 100644
+index 0000000000..f7f07248f7
+--- /dev/null
++++ b/gdb/gstack.sh
 @@ -0,0 +1,43 @@
 +#!/bin/sh
 +
@@ -97,7 +118,7 @@ Index: gdb-7.7/gdb/gstack.sh
 +    fi
 +fi
 +
-+GDB=${GDB:-/usr/bin/gdb}
++GDB=${GDB:-gdb}
 +
 +# Run GDB, strip out unwanted noise.
 +# --readnever is no longer used since .gdb_index is now in use.
@@ -111,10 +132,60 @@ Index: gdb-7.7/gdb/gstack.sh
 +    -e 's/^\((gdb) \)*//' \
 +    -e '/^#/p' \
 +    -e '/^Thread/p'
-Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.exp
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.7/gdb/testsuite/gdb.base/gstack.exp	2014-02-06 20:43:17.774747352 +0100
+diff --git a/gdb/testsuite/gdb.base/gstack.c b/gdb/testsuite/gdb.base/gstack.c
+new file mode 100644
+index 0000000000..dc10813f04
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gstack.c
+@@ -0,0 +1,43 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++   Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
++
++   This program is free software; you can redistribute it and/or modify
++   it under the terms of the GNU General Public License as published by
++   the Free Software Foundation; either version 3 of the License, or
++   (at your option) any later version.
++
++   This program is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++   GNU General Public License for more details.
++
++   You should have received a copy of the GNU General Public License
++   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
++
++#include <stdio.h>
++#include <unistd.h>
++#include <string.h>
++
++void
++func (void)
++{
++  const char msg[] = "looping\n";
++
++  /* Use the most simple notification not to get caught by attach on exiting
++     the function.  */
++  write (1, msg, strlen (msg));
++  
++  for (;;);
++}
++
++int
++main (void)
++{
++  alarm (60);
++  nice (100);
++
++  func ();
++
++  return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gstack.exp b/gdb/testsuite/gdb.base/gstack.exp
+new file mode 100644
+index 0000000000..1186ec57bc
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gstack.exp
 @@ -0,0 +1,66 @@
 +# Copyright (C) 2012 Free Software Foundation, Inc.
 +
@@ -182,51 +253,6 @@ Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.exp
 +gdb_exit
 +
 +remote_exec host "kill -9 $pid"
-Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.c
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.7/gdb/testsuite/gdb.base/gstack.c	2014-02-06 20:29:09.502214360 +0100
-@@ -0,0 +1,43 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+   Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
-+
-+   This program is free software; you can redistribute it and/or modify
-+   it under the terms of the GNU General Public License as published by
-+   the Free Software Foundation; either version 3 of the License, or
-+   (at your option) any later version.
-+
-+   This program is distributed in the hope that it will be useful,
-+   but WITHOUT ANY WARRANTY; without even the implied warranty of
-+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+   GNU General Public License for more details.
-+
-+   You should have received a copy of the GNU General Public License
-+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-+
-+#include <stdio.h>
-+#include <unistd.h>
-+#include <string.h>
-+
-+void
-+func (void)
-+{
-+  const char msg[] = "looping\n";
-+
-+  /* Use the most simple notification not to get caught by attach on exiting
-+     the function.  */
-+  write (1, msg, strlen (msg));
-+  
-+  for (;;);
-+}
-+
-+int
-+main (void)
-+{
-+  alarm (60);
-+  nice (100);
-+
-+  func ();
-+
-+  return 0;
-+}
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch
index 85d4fe5..5d9792a 100644
--- a/gdb-6.6-buildid-locate-core-as-arg.patch
+++ b/gdb-6.6-buildid-locate-core-as-arg.patch
@@ -1,5 +1,13 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: print a more useful error message for "gdb core"
+
+FileName: gdb-6.6-buildid-locate-core-as-arg.patch
+
+;;=push+jan
+
 http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html
-Subject: Re: [patch] print a more useful error message for "gdb core"
 
 [ Fixed up since the mail.  ]
 
@@ -31,16 +39,13 @@ autodetections.  The second command line argument
 (captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but
 neither "attach" accepts a core file nor "core-file" accepts a PID.
 
-
 The patch makes sense only with the build-id patchset so this is not submit
 for FSF GDB inclusion yet.  I am fine with your patch (+/- Hui Zhu's pending
 bfd_check_format_matches) as the patch below is its natural extension.
 
-
 Sorry for the delay,
 Jan
 
-
 2010-01-25  Jan Kratochvil  <jan.kratochvil at redhat.com>
 
 	* exceptions.h (enum errors <IS_CORE_ERROR>): New.
@@ -57,11 +62,30 @@ Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html
 
 	* exec.c (exec_file_attach): Print a more useful error message if the
 	user did "gdb core".
-
-Index: gdb-7.12.50.20170226/gdb/exec.c
-===================================================================
---- gdb-7.12.50.20170226.orig/gdb/exec.c	2017-02-27 22:18:00.945026211 +0100
-+++ gdb-7.12.50.20170226/gdb/exec.c	2017-02-27 22:18:08.111076350 +0100
+---
+ gdb/common/common-exceptions.h |  3 +++
+ gdb/exec.c                     | 22 +++++++++++++++---
+ gdb/main.c                     | 53 +++++++++++++++++++++++++++++++++++++++---
+ 3 files changed, 72 insertions(+), 6 deletions(-)
+
+diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
+index 15c85e28ab..9fe2375bce 100644
+--- a/gdb/common/common-exceptions.h
++++ b/gdb/common/common-exceptions.h
+@@ -104,6 +104,9 @@ enum errors {
+      "_ERROR" is appended to the name.  */
+   MAX_COMPLETIONS_REACHED_ERROR,
+ 
++  /* Attempt to load a core file as executable.  */
++  IS_CORE_ERROR,
++
+   /* Add more errors here.  */
+   NR_ERRORS
+ };
+diff --git a/gdb/exec.c b/gdb/exec.c
+index c8c32ecc27..b329e2b834 100644
+--- a/gdb/exec.c
++++ b/gdb/exec.c
 @@ -35,6 +35,7 @@
  #include "progspace.h"
  #include "gdb_bfd.h"
@@ -70,7 +94,7 @@ Index: gdb-7.12.50.20170226/gdb/exec.c
  
  #include <fcntl.h>
  #include "readline/readline.h"
-@@ -359,12 +360,27 @@
+@@ -346,12 +347,27 @@ exec_file_attach (const char *filename, int from_tty)
  
        if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
  	{
@@ -101,11 +125,11 @@ Index: gdb-7.12.50.20170226/gdb/exec.c
  	}
  
        if (build_section_table (exec_bfd, &sections, &sections_end))
-Index: gdb-7.12.50.20170226/gdb/main.c
-===================================================================
---- gdb-7.12.50.20170226.orig/gdb/main.c	2017-02-27 22:18:00.945026211 +0100
-+++ gdb-7.12.50.20170226/gdb/main.c	2017-02-27 22:18:08.112076357 +0100
-@@ -459,6 +459,37 @@
+diff --git a/gdb/main.c b/gdb/main.c
+index 3c98787edb..17d35f4a8a 100644
+--- a/gdb/main.c
++++ b/gdb/main.c
+@@ -446,6 +446,37 @@ struct cmdarg
    char *string;
  };
  
@@ -141,9 +165,9 @@ Index: gdb-7.12.50.20170226/gdb/main.c
 +}
 +
  static void
- captured_main_1 (struct captured_main_args *context, int &python_script)
+ captured_main_1 (struct captured_main_args *context)
  {
-@@ -910,6 +941,8 @@
+@@ -882,6 +913,8 @@ captured_main_1 (struct captured_main_args *context)
  	{
  	  symarg = argv[optind];
  	  execarg = argv[optind];
@@ -152,7 +176,7 @@ Index: gdb-7.12.50.20170226/gdb/main.c
  	  optind++;
  	}
  
-@@ -1060,11 +1093,25 @@
+@@ -1032,11 +1065,25 @@ captured_main_1 (struct captured_main_args *context)
        && symarg != NULL
        && strcmp (execarg, symarg) == 0)
      {
@@ -171,27 +195,16 @@ Index: gdb-7.12.50.20170226/gdb/main.c
        /* The exec file and the symbol-file are the same.  If we can't
           open it, better only print one error message.
 -         catch_command_errors returns non-zero on success!  */
--      if (catch_command_errors_const (exec_file_attach, execarg,
--				      !batch_flag))
+-      if (catch_command_errors (exec_file_attach, execarg,
+-				!batch_flag))
 +         catch_command_errors returns non-zero on success!
 +	 Do not load EXECARG as a symbol file if it has been already processed
 +	 as a core file.  */
-+      if (catch_command_errors_const (func, execarg, !batch_flag)
++      if (catch_command_errors (func, execarg, !batch_flag)
 +	  && core_bfd == NULL)
- 	catch_command_errors_const (symbol_file_add_main_adapter, symarg,
- 				    !batch_flag);
+ 	catch_command_errors (symbol_file_add_main_adapter, symarg,
+ 			      !batch_flag);
      }
-Index: gdb-7.12.50.20170226/gdb/common/common-exceptions.h
-===================================================================
---- gdb-7.12.50.20170226.orig/gdb/common/common-exceptions.h	2017-02-27 22:18:00.946026218 +0100
-+++ gdb-7.12.50.20170226/gdb/common/common-exceptions.h	2017-02-27 22:18:08.112076357 +0100
-@@ -106,6 +106,9 @@
-      "_ERROR" is appended to the name.  */
-   MAX_COMPLETIONS_REACHED_ERROR,
- 
-+  /* Attempt to load a core file as executable.  */
-+  IS_CORE_ERROR,
-+
-   /* Add more errors here.  */
-   NR_ERRORS
- };
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
index 32f2a83..f228577 100644
--- a/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
+++ b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
@@ -1,3 +1,15 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: 
+ gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
+
+FileName: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
+
+;; Fix 'gdb gives highly misleading error when debuginfo pkg is present,
+;; but not corresponding binary pkg' (RH BZ 981154).
+;;=push+jan
+
 Comments by Sergio Durigan Junior <sergiodj at redhat.com>:
 
   This is the fix for RH BZ #981154
@@ -14,11 +26,33 @@ Comments by Sergio Durigan Junior <sergiodj at redhat.com>:
   and had a little thinko there.  The variable 'filename' needs to be set to
   NULL after it is free'd, otherwise the code below thinks that it is still
   valid and doesn't print the necessary warning ("Try: yum install ...").
+---
+ gdb/build-id.c                                     |  5 +-
+ .../rhbz981154-misleading-yum-install-warning.exp  | 97 ++++++++++++++++++++++
+ 2 files changed, 101 insertions(+), 1 deletion(-)
+ create mode 100644 gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
 
-Index: gdb-7.12.50.20170207/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
-===================================================================
---- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ gdb-7.12.50.20170207/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp	2017-02-26 19:14:58.492609659 +0100
+diff --git a/gdb/build-id.c b/gdb/build-id.c
+index 409a5b8c54..e2c1e81266 100644
+--- a/gdb/build-id.c
++++ b/gdb/build-id.c
+@@ -592,7 +592,10 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
+ 	  do_cleanups (inner);
+ 
+ 	  if (abfd == NULL)
+-	    continue;
++	    {
++	      filename = NULL;
++	      continue;
++	    }
+ 
+ 	  if (build_id_verify (abfd.get(), build_id_len, build_id))
+ 	    break;
+diff --git a/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
+new file mode 100644
+index 0000000000..bb70c5cf44
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
 @@ -0,0 +1,97 @@
 +#   Copyright (C) 2014  Free Software Foundation, Inc.
 +
@@ -117,19 +151,6 @@ Index: gdb-7.12.50.20170207/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-ins
 +
 +# Leaving the link there will cause breakage in the next run.
 +remote_exec build "rm -f [standard_output_file ${build_id_without_debug}]"
-Index: gdb-7.12.50.20170207/gdb/build-id.c
-===================================================================
---- gdb-7.12.50.20170207.orig/gdb/build-id.c	2017-02-26 19:14:51.943562799 +0100
-+++ gdb-7.12.50.20170207/gdb/build-id.c	2017-02-26 19:14:58.492609659 +0100
-@@ -589,7 +589,10 @@
- 	  do_cleanups (inner);
- 
- 	  if (abfd == NULL)
--	    continue;
-+	    {
-+	      filename = NULL;
-+	      continue;
-+	    }
- 
- 	  if (build_id_verify (abfd.get(), build_id_len, build_id))
- 	    break;
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
index 3378717..b94cc1f 100644
--- a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
+++ b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
@@ -1,20 +1,22 @@
-Index: gdb-7.6.90.20140127/gdb/proc-service.list
-===================================================================
---- gdb-7.6.90.20140127.orig/gdb/proc-service.list	2014-02-06 17:32:42.810640320 +0100
-+++ gdb-7.6.90.20140127/gdb/proc-service.list	2014-02-06 17:33:35.406696964 +0100
-@@ -37,4 +37,7 @@
-   ps_pstop;
-   ps_ptread;
-   ps_ptwrite;
-+
-+  /* gdb-6.6-buildid-locate-rpm.patch */
-+  rpmsqEnable;
- };
-Index: gdb-7.6.90.20140127/gdb/build-id.c
-===================================================================
---- gdb-7.6.90.20140127.orig/gdb/build-id.c	2014-02-06 17:30:14.230480264 +0100
-+++ gdb-7.6.90.20140127/gdb/build-id.c	2014-02-06 17:34:28.846754283 +0100
-@@ -677,6 +677,19 @@ build_id_to_filename (const struct elf_b
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
+
+FileName: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
+
+;; Workaround librpm BZ 643031 due to its unexpected exit() calls (BZ 642879).
+;;=push+jan
+---
+ gdb/build-id.c        | 13 +++++++++++++
+ gdb/proc-service.list |  3 +++
+ 2 files changed, 16 insertions(+)
+
+diff --git a/gdb/build-id.c b/gdb/build-id.c
+index d60cf622dc..409a5b8c54 100644
+--- a/gdb/build-id.c
++++ b/gdb/build-id.c
+@@ -678,6 +678,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
  #include <dlfcn.h>
  #endif
  
@@ -34,3 +36,18 @@ Index: gdb-7.6.90.20140127/gdb/build-id.c
  /* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
     and avoid their duplicities during a single inferior run.  */
  
+diff --git a/gdb/proc-service.list b/gdb/proc-service.list
+index 53f7ed8b1e..323f5e83c2 100644
+--- a/gdb/proc-service.list
++++ b/gdb/proc-service.list
+@@ -37,4 +37,7 @@
+   ps_pstop;
+   ps_ptread;
+   ps_ptwrite;
++
++  /* gdb-6.6-buildid-locate-rpm.patch */
++  rpmsqEnable;
+ };
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate-rpm-scl.patch b/gdb-6.6-buildid-locate-rpm-scl.patch
index f2f605d..9200bab 100644
--- a/gdb-6.6-buildid-locate-rpm-scl.patch
+++ b/gdb-6.6-buildid-locate-rpm-scl.patch
@@ -1,10 +1,25 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: gdb-6.6-buildid-locate-rpm-scl.patch
+
+FileName: gdb-6.6-buildid-locate-rpm-scl.patch
+
+;; [SCL] Skip deprecated .gdb_index warning for Red Hat built files (BZ 953585).
+;;=push+jan
+
 warning: Skipping deprecated .gdb_index section
 https://bugzilla.redhat.com/show_bug.cgi?id=953585
+---
+ gdb/build-id.c   | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ gdb/dwarf2read.c | 14 ++++++++++++++
+ 2 files changed, 68 insertions(+)
 
-diff -dup -rup gdb-7.10.50.20160106-orig/gdb/build-id.c gdb-7.10.50.20160106/gdb/build-id.c
---- gdb-7.10.50.20160106-orig/gdb/build-id.c	2016-01-09 14:40:39.420385241 +0100
-+++ gdb-7.10.50.20160106/gdb/build-id.c	2016-01-09 14:41:05.944549393 +0100
-@@ -713,7 +713,11 @@ static int missing_rpm_list_entries;
+diff --git a/gdb/build-id.c b/gdb/build-id.c
+index e2c1e81266..1b75530f91 100644
+--- a/gdb/build-id.c
++++ b/gdb/build-id.c
+@@ -715,7 +715,11 @@ static int missing_rpm_list_entries;
  /* Returns the count of newly added rpms.  */
  
  static int
@@ -16,7 +31,7 @@ diff -dup -rup gdb-7.10.50.20160106-orig/gdb/build-id.c gdb-7.10.50.20160106/gdb
  {
    static int rpm_init_done = 0;
    rpmts ts;
-@@ -817,7 +821,11 @@ missing_rpm_enlist (const char *filename
+@@ -822,7 +826,11 @@ missing_rpm_enlist (const char *filename)
    mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
    if (mi != NULL)
      {
@@ -28,7 +43,7 @@ diff -dup -rup gdb-7.10.50.20160106-orig/gdb/build-id.c gdb-7.10.50.20160106/gdb
  	{
  	  Header h;
  	  char *debuginfo, **slot, *s, *s2;
-@@ -935,6 +943,37 @@ missing_rpm_enlist (const char *filename
+@@ -940,6 +948,37 @@ missing_rpm_enlist (const char *filename)
  	    xfree (debuginfo);
  	  count++;
  	}
@@ -66,7 +81,7 @@ diff -dup -rup gdb-7.10.50.20160106-orig/gdb/build-id.c gdb-7.10.50.20160106/gdb
  
        rpmdbFreeIterator_p (mi);
      }
-@@ -945,6 +984,21 @@ missing_rpm_enlist (const char *filename
+@@ -950,6 +989,21 @@ missing_rpm_enlist (const char *filename)
  }
  
  static int
@@ -88,10 +103,11 @@ diff -dup -rup gdb-7.10.50.20160106-orig/gdb/build-id.c gdb-7.10.50.20160106/gdb
  missing_rpm_list_compar (const char *const *ap, const char *const *bp)
  {
    return strcoll (*ap, *bp);
-diff -dup -rup gdb-7.10.50.20160106-orig/gdb/dwarf2read.c gdb-7.10.50.20160106/gdb/dwarf2read.c
---- gdb-7.10.50.20160106-orig/gdb/dwarf2read.c	2016-01-09 14:40:39.416385216 +0100
-+++ gdb-7.10.50.20160106/gdb/dwarf2read.c	2016-01-09 14:41:05.942549381 +0100
-@@ -3111,6 +3111,16 @@ read_index_from_section (struct objfile
+diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
+index 2c972d5e74..64329af71e 100644
+--- a/gdb/dwarf2read.c
++++ b/gdb/dwarf2read.c
+@@ -3725,6 +3725,16 @@ read_index_from_section (struct objfile *objfile,
       "set use-deprecated-index-sections on".  */
    if (version < 6 && !deprecated_ok)
      {
@@ -108,7 +124,7 @@ diff -dup -rup gdb-7.10.50.20160106-orig/gdb/dwarf2read.c gdb-7.10.50.20160106/g
        static int warning_printed = 0;
        if (!warning_printed)
  	{
-@@ -3122,6 +3132,10 @@ to use the section anyway."),
+@@ -3736,6 +3746,10 @@ to use the section anyway."),
  	  warning_printed = 1;
  	}
        return 0;
@@ -119,3 +135,6 @@ diff -dup -rup gdb-7.10.50.20160106-orig/gdb/dwarf2read.c gdb-7.10.50.20160106/g
      }
    /* Version 7 indices generated by gold refer to the CU for a symbol instead
       of the TU (for symbols coming from TUs),
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch
index 56ce7db..7697afa 100644
--- a/gdb-6.6-buildid-locate-rpm.patch
+++ b/gdb-6.6-buildid-locate-rpm.patch
@@ -1,54 +1,27 @@
-Index: gdb-7.11.50.20160630/gdb/event-top.c
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/event-top.c	2016-07-02 23:43:24.085214144 +0200
-+++ gdb-7.11.50.20160630/gdb/event-top.c	2016-07-03 14:37:12.572130734 +0200
-@@ -40,6 +40,7 @@
- #include "buffer.h"
- #include "ser-event.h"
- #include "gdb_select.h"
-+#include "symfile.h"
- 
- /* readline include files.  */
- #include "readline/readline.h"
-@@ -347,6 +348,8 @@
-   /* Reset the nesting depth used when trace-commands is set.  */
-   reset_command_nest_depth ();
- 
-+  debug_flush_missing ();
-+
-   old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
- 
-   /* Do not call the python hook on an explicit prompt change as
-@@ -794,7 +797,10 @@
-       command_handler (cmd);
- 
-       if (ui->prompt_state != PROMPTED)
--	display_gdb_prompt (0);
-+	{
-+	  debug_flush_missing ();
-+	  display_gdb_prompt (0);
-+	}
-     }
- }
- 
-Index: gdb-7.11.50.20160630/gdb/symfile.h
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/symfile.h	2016-07-03 14:34:32.032753668 +0200
-+++ gdb-7.11.50.20160630/gdb/symfile.h	2016-07-03 14:37:12.573130742 +0200
-@@ -592,6 +592,8 @@
- /* build-id support.  */
- extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
- extern void debug_print_missing (const char *binary, const char *debug);
-+extern void debug_flush_missing (void);
-+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
- 
- /* From dwarf2read.c */
- 
-Index: gdb-7.11.50.20160630/gdb/aclocal.m4
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/aclocal.m4	2016-07-02 23:43:24.085214144 +0200
-+++ gdb-7.11.50.20160630/gdb/aclocal.m4	2016-07-03 14:37:12.576130768 +0200
-@@ -11,6 +11,221 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: gdb-6.6-buildid-locate-rpm.patch
+
+FileName: gdb-6.6-buildid-locate-rpm.patch
+
+;;=push+jan
+---
+ gdb/aclocal.m4   | 215 +++++++++++++++++++++++
+ gdb/build-id.c   | 407 +++++++++++++++++++++++++++++++++++++++++++-
+ gdb/config.in    |   6 +
+ gdb/configure    | 508 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ gdb/configure.ac | 193 +++++++++++++++++++++
+ gdb/corelow.c    |   2 +-
+ gdb/event-top.c  |   8 +-
+ gdb/symfile.h    |   2 +
+ 8 files changed, 1331 insertions(+), 10 deletions(-)
+
+diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
+index e0d38ea267..da5ac313e3 100644
+--- a/gdb/aclocal.m4
++++ b/gdb/aclocal.m4
+@@ -12,6 +12,221 @@
  # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  # PARTICULAR PURPOSE.
  
@@ -269,592 +242,539 @@ Index: gdb-7.11.50.20160630/gdb/aclocal.m4
 +
  # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
  
- # Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-Index: gdb-7.11.50.20160630/gdb/config.in
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/config.in	2016-07-02 23:43:24.085214144 +0200
-+++ gdb-7.11.50.20160630/gdb/config.in	2016-07-03 14:37:12.576130768 +0200
-@@ -33,6 +33,9 @@
- /* Define to BFD's default target vector. */
- #undef DEFAULT_BFD_VEC
+ # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
+diff --git a/gdb/build-id.c b/gdb/build-id.c
+index 5740628386..d60cf622dc 100644
+--- a/gdb/build-id.c
++++ b/gdb/build-id.c
+@@ -35,6 +35,8 @@
+ #include "elf/common.h"
+ #include "elf-bfd.h"
+ #include <sys/stat.h>
++#include "elf/external.h"
++#include "inferior.h"
  
-+/* librpm version specific library name to dlopen. */
-+#undef DLOPEN_LIBRPM
-+
- /* Define to 1 if translation of program messages to the user's native
-    language is requested. */
- #undef ENABLE_NLS
-@@ -261,6 +264,9 @@
- /* Define if Python 2.7 is being used. */
- #undef HAVE_LIBPYTHON2_7
+ #define BUILD_ID_VERBOSE_NONE 0
+ #define BUILD_ID_VERBOSE_FILENAMES 1
+@@ -666,8 +668,366 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
+   return result;
+ }
  
-+/* Define if librpm library is being used. */
-+#undef HAVE_LIBRPM
++#ifdef HAVE_LIBRPM
 +
- /* Define to 1 if you have the <libunwind-ia64.h> header file. */
- #undef HAVE_LIBUNWIND_IA64_H
- 
-Index: gdb-7.11.50.20160630/gdb/configure
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/configure	2016-07-02 23:43:24.085214144 +0200
-+++ gdb-7.11.50.20160630/gdb/configure	2016-07-03 14:37:12.581130811 +0200
-@@ -705,6 +705,11 @@
- HAVE_NATIVE_GCORE_TARGET
- TARGET_OBS
- subdirs
-+RPM_LIBS
-+RPM_CFLAGS
-+PKG_CONFIG_LIBDIR
-+PKG_CONFIG_PATH
-+PKG_CONFIG
- GDB_DATADIR
- DEBUGDIR
- MAKEINFO_EXTRA_FLAGS
-@@ -814,6 +819,7 @@
- with_relocated_sources
- with_auto_load_dir
- with_auto_load_safe_path
-+with_rpm
- enable_targets
- enable_64_bit_bfd
- enable_gdbcli
-@@ -870,6 +876,11 @@
- CPP
- MAKEINFO
- MAKEINFOFLAGS
-+PKG_CONFIG
-+PKG_CONFIG_PATH
-+PKG_CONFIG_LIBDIR
-+RPM_CFLAGS
-+RPM_LIBS
- YACC
- YFLAGS
- XMKMF'
-@@ -1541,6 +1552,8 @@
-                           [--with-auto-load-dir]
-   --without-auto-load-safe-path
-                           do not restrict auto-loaded files locations
-+  --with-rpm              query rpm database for missing debuginfos (yes/no,
-+                          def. auto=librpm.so)
-   --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
-   --with-curses           use the curses library instead of the termcap
-                           library
-@@ -1595,6 +1608,13 @@
-   MAKEINFO    Parent configure detects if it is of sufficient version.
-   MAKEINFOFLAGS
-               Parameters for MAKEINFO.
-+  PKG_CONFIG  path to pkg-config utility
-+  PKG_CONFIG_PATH
-+              directories to add to pkg-config's search path
-+  PKG_CONFIG_LIBDIR
-+              path overriding pkg-config's built-in search path
-+  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
-+  RPM_LIBS    linker flags for RPM, overriding pkg-config
-   YACC        The `Yet Another C Compiler' implementation to use. Defaults to
-               the first program found out of: `bison -y', `byacc', `yacc'.
-   YFLAGS      The list of arguments that will be passed by default to $YACC.
-@@ -5613,6 +5633,494 @@
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
- $as_echo "$with_auto_load_safe_path" >&6; }
- 
-+# Integration with rpm library to support missing debuginfo suggestions.
-+# --without-rpm: Disable any rpm support.
-+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
-+#   Even with runtime missing `libname.so' GDB will still other run correctly.
-+#   Missing `libname.so' during ./configure will abort the configuration.
-+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
-+#   minor version first such as `librpm-4.6.so' as minor version differences
-+#   mean API+ABI incompatibility.  If the specific match versioned library name
-+#   could not be found still open dynamically at least `librpm.so'.
-+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
-+#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
-+#   be probably linked with the version specific library (as `librpm-4.6.so').
-+#   Failure to find librpm by pkg-config will abort the configuration.
-+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
-+#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
++#include <rpm/rpmlib.h>
++#include <rpm/rpmts.h>
++#include <rpm/rpmdb.h>
++#include <rpm/header.h>
++#ifdef DLOPEN_LIBRPM
++#include <dlfcn.h>
++#endif
 +
++/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
++   and avoid their duplicities during a single inferior run.  */
 +
-+# Check whether --with-rpm was given.
-+if test "${with_rpm+set}" = set; then :
-+  withval=$with_rpm;
-+else
-+  with_rpm="auto"
-+fi
++static struct htab *missing_rpm_hash;
 +
++/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
++   all the rpms right before the nearest GDB prompt.  It gets cleared after
++   each such print (it is questionable if we should clear it after the print).
++   */
 +
++struct missing_rpm
++  {
++    struct missing_rpm *next;
++    char rpm[1];
++  };
++static struct missing_rpm *missing_rpm_list;
++static int missing_rpm_list_entries;
 +
++/* Returns the count of newly added rpms.  */
 +
-+if test "x$with_rpm" != "xno"; then
-+  if test "x$with_rpm" = "xyes"; then
-+    LIBRPM="librpm.so"
-+    RPM_REQUIRE=true
-+    DLOPEN_REQUIRE=false
-+  elif test "x$with_rpm" = "xauto"; then
-+    LIBRPM="librpm.so"
-+    RPM_REQUIRE=false
-+    DLOPEN_REQUIRE=false
-+  else
-+    LIBRPM="$with_rpm"
-+    RPM_REQUIRE=true
-+    DLOPEN_REQUIRE=true
-+  fi
-+  LIBRPM_STRING='"'"$LIBRPM"'"'
++static int
++missing_rpm_enlist (const char *filename)
++{
++  static int rpm_init_done = 0;
++  rpmts ts;
++  rpmdbMatchIterator mi;
++  int count = 0;
 +
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
-+$as_echo_n "checking specific librpm version... " >&6; }
-+  HAVE_DLOPEN_LIBRPM=false
-+  save_LIBS="$LIBS"
-+  LIBS="$LIBS -ldl"
-+  if test "$cross_compiling" = yes; then :
-+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+as_fn_error "cannot run test program while cross compiling
-+See \`config.log' for more details." "$LINENO" 5; }
-+else
-+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h.  */
++#ifdef DLOPEN_LIBRPM
++  /* Duplicate here the declarations to verify they match.  The same sanity
++     check is present also in `configure.ac'.  */
++  extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++  static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
++  extern int rpmReadConfigFiles(const char * file, const char * target);
++  static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
++  extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++  static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
++  extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++  static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
++  extern rpmts rpmtsCreate(void);
++  static rpmts (*rpmtsCreate_p) (void);
++  extern rpmts rpmtsFree(rpmts ts);
++  static rpmts (*rpmtsFree_p) (rpmts ts);
++  extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++                                              const void * keyp, size_t keylen);
++  static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
++						    rpmTag rpmtag,
++						    const void *keyp,
++						    size_t keylen);
++#else	/* !DLOPEN_LIBRPM */
++# define headerFormat_p headerFormat
++# define rpmReadConfigFiles_p rpmReadConfigFiles
++# define rpmdbFreeIterator_p rpmdbFreeIterator
++# define rpmdbNextIterator_p rpmdbNextIterator
++# define rpmtsCreate_p rpmtsCreate
++# define rpmtsFree_p rpmtsFree
++# define rpmtsInitIterator_p rpmtsInitIterator
++#endif	/* !DLOPEN_LIBRPM */
 +
-+#include <rpm/rpmlib.h>
-+#include <dlfcn.h>
-+#include <errno.h>
++  gdb_assert (filename != NULL);
 +
-+int
-+main ()
-+{
++  if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
++    return 0;
 +
-+    void *h;
-+    const char *const *rpmverp;
-+    FILE *f;
++  if (is_target_filename (filename))
++    return 0;
 +
-+    f = fopen ("conftest.out", "w");
-+    if (!f)
++  if (filename[0] != '/')
++    {
++      warning (_("Ignoring non-absolute filename: <%s>"), filename);
++      return 0;
++    }
++
++  if (!rpm_init_done)
++    {
++      static int init_tried;
++
++      /* Already failed the initialization before?  */
++      if (init_tried)
++      	return 0;
++      init_tried = 1;
++
++#ifdef DLOPEN_LIBRPM
 +      {
-+	fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
-+		 strerror (errno));
-+	return 1;
-+      }
-+    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
-+    if (!h)
-+      {
-+	fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
-+	return 1;
-+      }
-+    rpmverp = dlsym (h, "RPMVERSION");
-+    if (!rpmverp)
-+      {
-+	fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
-+	return 1;
-+      }
-+    fprintf (stderr, "RPMVERSION is: \"");
-+    fprintf (stderr, "%s\"\n", *rpmverp);
-+
-+    /* Try to find the specific librpm version only for "librpm.so" as we do
-+       not know how to assemble the version string otherwise.  */
-+
-+    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
-+      {
-+	fprintf (f, "%s\n", $LIBRPM_STRING);
-+	return 0;
-+      }
-+    else
-+      {
-+	char *h2_name;
-+	void *h2;
-+	int major, minor;
++	void *h;
 +
-+	if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
-+	  {
-+	    fprintf (stderr, "Unable to parse RPMVERSION.\n");
-+	    fprintf (f, "%s\n", $LIBRPM_STRING);
-+	    return 0;
-+	  }
-+	/* Avoid the square brackets by malloc.  */
-+	h2_name = malloc (64);
-+	sprintf (h2_name, "librpm-%d.%d.so", major, minor);
-+	h2 = dlopen (h2_name, RTLD_LAZY);
-+	if (!h2)
++	h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
++	if (!h)
 +	  {
-+	    fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
-+	    fprintf (f, "%s\n", $LIBRPM_STRING);
++	    warning (_("Unable to open \"%s\" (%s), "
++		      "missing debuginfos notifications will not be displayed"),
++		     DLOPEN_LIBRPM, dlerror ());
 +	    return 0;
 +	  }
-+	if (h2 != h)
++
++	if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat"))
++	      && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles"))
++	      && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator"))
++	      && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
++	      && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
++	      && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
++	      && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
 +	  {
-+	    fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
-+		     $LIBRPM_STRING, h2_name);
-+	    fprintf (f, "%s\n", $LIBRPM_STRING);
++	    warning (_("Opened library \"%s\" is incompatible (%s), "
++		      "missing debuginfos notifications will not be displayed"),
++		     DLOPEN_LIBRPM, dlerror ());
++	    if (dlclose (h))
++	      warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
++		       dlerror ());
 +	    return 0;
 +	  }
-+	/* Found the valid .so name with a specific version.  */
-+	fprintf (f, "%s\n", h2_name);
-+	return 0;
 +      }
++#endif	/* DLOPEN_LIBRPM */
 +
-+  ;
-+  return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_run "$LINENO"; then :
++      if (rpmReadConfigFiles_p (NULL, NULL) != 0)
++	{
++	  warning (_("Error reading the rpm configuration files"));
++	  return 0;
++	}
 +
-+    DLOPEN_LIBRPM="`cat conftest.out`"
-+    if test "x$DLOPEN_LIBRPM" != "x"; then
-+      HAVE_DLOPEN_LIBRPM=true
-+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
-+$as_echo "$DLOPEN_LIBRPM" >&6; }
-+    fi
++      rpm_init_done = 1;
++    }
 +
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-+  conftest.$ac_objext conftest.beam conftest.$ac_ext
-+fi
++  ts = rpmtsCreate_p ();
 +
-+  rm -f conftest.out
++  mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
++  if (mi != NULL)
++    {
++      for (;;)
++	{
++	  Header h;
++	  char *debuginfo, **slot, *s, *s2;
++	  errmsg_t err;
++	  size_t srcrpmlen = sizeof (".src.rpm") - 1;
++	  size_t debuginfolen = sizeof ("-debuginfo") - 1;
++	  rpmdbMatchIterator mi_debuginfo;
 +
++	  h = rpmdbNextIterator_p (mi);
++	  if (h == NULL)
++	    break;
 +
++	  /* Verify the debuginfo file is not already installed.  */
 +
-+  if $HAVE_DLOPEN_LIBRPM; then
++	  debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
++				      &err);
++	  if (!debuginfo)
++	    {
++	      warning (_("Error querying the rpm file `%s': %s"), filename,
++	               err);
++	      continue;
++	    }
++	  /* s = `.src.rpm-debuginfo.%{arch}' */
++	  s = strrchr (debuginfo, '-') - srcrpmlen;
++	  s2 = NULL;
++	  if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
++	    {
++	      /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
++	      s2 = (char *) memrchr (debuginfo, '-', s - debuginfo);
++	    }
++	  if (s2)
++	    {
++	      /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
++	      s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo);
++	    }
++	  if (!s2)
++	    {
++	      warning (_("Error querying the rpm file `%s': %s"), filename,
++	               debuginfo);
++	      xfree (debuginfo);
++	      continue;
++	    }
++	  /* s = `.src.rpm-debuginfo.%{arch}' */
++	  /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
++	  memmove (s2 + debuginfolen, s2, s - s2);
++	  memcpy (s2, "-debuginfo", debuginfolen);
++	  /* s = `XXXX.%{arch}' */
++	  /* strlen ("XXXX") == srcrpmlen + debuginfolen */
++	  /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
++	  /* strlen ("XX") == srcrpmlen */
++	  memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
++		   strlen (s + srcrpmlen + debuginfolen) + 1);
++	  /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
 +
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
-+$as_echo_n "checking rpm library API compatibility... " >&6; }
-+    # The compilation requires -Werror to verify anything.
-+    save_CFLAGS="$CFLAGS"
-+    CFLAGS="$CFLAGS -Werror"
-+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h.  */
++	  /* RPMDBI_PACKAGES requires keylen == sizeof (int).  */
++	  /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel().  */
++	  mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
++	  xfree (debuginfo);
++	  if (mi_debuginfo)
++	    {
++	      rpmdbFreeIterator_p (mi_debuginfo);
++	      count = 0;
++	      break;
++	    }
 +
-+/* Duplicate here the declarations to verify they match "elfread.c".  */
-+#include <rpm/rpmlib.h>
-+#include <rpm/rpmts.h>
-+#include <rpm/rpmdb.h>
-+#include <rpm/header.h>
-+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
-+extern int rpmReadConfigFiles(const char * file, const char * target);
-+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
-+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
-+extern rpmts rpmtsCreate(void);
-+extern rpmts rpmtsFree(rpmts ts);
-+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
-+					    const void * keyp, size_t keylen);
++	  /* The allocated memory gets utilized below for MISSING_RPM_HASH.  */
++	  debuginfo = headerFormat_p (h,
++				      "%{name}-%{version}-%{release}.%{arch}",
++				      &err);
++	  if (!debuginfo)
++	    {
++	      warning (_("Error querying the rpm file `%s': %s"), filename,
++	               err);
++	      continue;
++	    }
 +
-+int
-+main ()
-+{
++	  /* Base package name for `debuginfo-install'.  We do not use the
++	     `yum' command directly as the line
++		 yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
++	     would be more complicated than just:
++		 debuginfo-install NAME-VERSION-RELEASE.ARCH
++	     Do not supply the rpm base name (derived from .src.rpm name) as
++	     debuginfo-install is unable to install the debuginfo package if
++	     the base name PKG binary rpm is not installed while for example
++	     PKG-libs would be installed (RH Bug 467901).
++	     FUTURE: After multiple debuginfo versions simultaneously installed
++	     get supported the support for the VERSION-RELEASE tags handling
++	     may need an update.  */
 +
-+  ;
-+  return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_compile "$LINENO"; then :
++	  if (missing_rpm_hash == NULL)
++	    {
++	      /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
++		 should not deallocate the entries.  */
 +
-+      LIBRPM_COMPAT=true
-+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
++	      missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
++			       (int (*) (const void *, const void *)) streq,
++						    NULL, xcalloc, xfree);
++	    }
++	  slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
++	  /* XCALLOC never returns NULL.  */
++	  gdb_assert (slot != NULL);
++	  if (*slot == NULL)
++	    {
++	      struct missing_rpm *missing_rpm;
 +
-+else
++	      *slot = debuginfo;
 +
-+      LIBRPM_COMPAT=false
-+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
++	      missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
++	      strcpy (missing_rpm->rpm, debuginfo);
++	      missing_rpm->next = missing_rpm_list;
++	      missing_rpm_list = missing_rpm;
++	      missing_rpm_list_entries++;
++	    }
++	  else
++	    xfree (debuginfo);
++	  count++;
++	}
 +
-+fi
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-+    CFLAGS="$save_CFLAGS"
++      rpmdbFreeIterator_p (mi);
++    }
 +
-+    if ! $LIBRPM_COMPAT; then
-+      HAVE_DLOPEN_LIBRPM=false
-+    fi
-+  fi
++  rpmtsFree_p (ts);
 +
-+  if $HAVE_DLOPEN_LIBRPM; then
-+    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
++  return count;
++}
 +
-+cat >>confdefs.h <<_ACEOF
-+#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
-+_ACEOF
-+
-+
-+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
-+
-+  else
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+    LIBS="$save_LIBS"
-+    if $DLOPEN_REQUIRE; then
-+      as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
-+    fi
-+
-+
-+
-+
-+
-+
-+
-+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-+	if test -n "$ac_tool_prefix"; then
-+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+$as_echo_n "checking for $ac_word... " >&6; }
-+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  case $PKG_CONFIG in
-+  [\\/]* | ?:[\\/]*)
-+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-+  ;;
-+  *)
-+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+for as_dir in $PATH
-+do
-+  IFS=$as_save_IFS
-+  test -z "$as_dir" && as_dir=.
-+    for ac_exec_ext in '' $ac_executable_extensions; do
-+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+    break 2
-+  fi
-+done
-+  done
-+IFS=$as_save_IFS
-+
-+  ;;
-+esac
-+fi
-+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-+if test -n "$PKG_CONFIG"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-+$as_echo "$PKG_CONFIG" >&6; }
-+else
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+fi
-+
-+
-+fi
-+if test -z "$ac_cv_path_PKG_CONFIG"; then
-+  ac_pt_PKG_CONFIG=$PKG_CONFIG
-+  # Extract the first word of "pkg-config", so it can be a program name with args.
-+set dummy pkg-config; ac_word=$2
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+$as_echo_n "checking for $ac_word... " >&6; }
-+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  case $ac_pt_PKG_CONFIG in
-+  [\\/]* | ?:[\\/]*)
-+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-+  ;;
-+  *)
-+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+for as_dir in $PATH
-+do
-+  IFS=$as_save_IFS
-+  test -z "$as_dir" && as_dir=.
-+    for ac_exec_ext in '' $ac_executable_extensions; do
-+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+    break 2
-+  fi
-+done
-+  done
-+IFS=$as_save_IFS
-+
-+  ;;
-+esac
-+fi
-+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
-+if test -n "$ac_pt_PKG_CONFIG"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
-+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
-+else
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+fi
-+
-+  if test "x$ac_pt_PKG_CONFIG" = x; then
-+    PKG_CONFIG=""
-+  else
-+    case $cross_compiling:$ac_tool_warned in
-+yes:)
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-+ac_tool_warned=yes ;;
-+esac
-+    PKG_CONFIG=$ac_pt_PKG_CONFIG
-+  fi
-+else
-+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-+fi
-+
-+fi
-+if test -n "$PKG_CONFIG"; then
-+	_pkg_min_version=0.9.0
-+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
-+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
-+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
-+	else
-+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+		PKG_CONFIG=""
-+	fi
-+fi
-+
-+pkg_failed=no
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
-+$as_echo_n "checking for RPM... " >&6; }
++static int
++missing_rpm_list_compar (const char *const *ap, const char *const *bp)
++{
++  return strcoll (*ap, *bp);
++}
 +
-+if test -n "$RPM_CFLAGS"; then
-+    pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
-+ elif test -n "$PKG_CONFIG"; then
-+    if test -n "$PKG_CONFIG" && \
-+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
-+  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
-+  ac_status=$?
-+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+  test $ac_status = 0; }; then
-+  pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
-+		      test "x$?" != "x0" && pkg_failed=yes
-+else
-+  pkg_failed=yes
-+fi
-+ else
-+    pkg_failed=untried
-+fi
-+if test -n "$RPM_LIBS"; then
-+    pkg_cv_RPM_LIBS="$RPM_LIBS"
-+ elif test -n "$PKG_CONFIG"; then
-+    if test -n "$PKG_CONFIG" && \
-+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
-+  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
-+  ac_status=$?
-+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+  test $ac_status = 0; }; then
-+  pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
-+		      test "x$?" != "x0" && pkg_failed=yes
-+else
-+  pkg_failed=yes
-+fi
-+ else
-+    pkg_failed=untried
-+fi
++/* It returns a NULL-terminated array of strings needing to be FREEd.  It may
++   also return only NULL.  */
 +
++static void
++missing_rpm_list_print (void)
++{
++  char **array, **array_iter;
++  struct missing_rpm *list_iter;
++  struct cleanup *cleanups;
 +
++  if (missing_rpm_list_entries == 0)
++    return;
 +
-+if test $pkg_failed = yes; then
-+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
++  array = (char **) xmalloc (sizeof (*array) * missing_rpm_list_entries);
++  cleanups = make_cleanup (xfree, array);
 +
-+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-+        _pkg_short_errors_supported=yes
-+else
-+        _pkg_short_errors_supported=no
-+fi
-+        if test $_pkg_short_errors_supported = yes; then
-+	        RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
-+        else
-+	        RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
-+        fi
-+	# Put the nasty error message in config.log where it belongs
-+	echo "$RPM_PKG_ERRORS" >&5
++  array_iter = array;
++  for (list_iter = missing_rpm_list; list_iter != NULL;
++       list_iter = list_iter->next)
++    {
++      *array_iter++ = list_iter->rpm;
++    }
++  gdb_assert (array_iter == array + missing_rpm_list_entries);
 +
-+	HAVE_LIBRPM=false
-+elif test $pkg_failed = untried; then
-+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+	HAVE_LIBRPM=false
-+else
-+	RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
-+	RPM_LIBS=$pkg_cv_RPM_LIBS
-+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
-+	HAVE_LIBRPM=true
-+fi
++  qsort (array, missing_rpm_list_entries, sizeof (*array),
++	 (int (*) (const void *, const void *)) missing_rpm_list_compar);
 +
-+    if $HAVE_LIBRPM; then
++  printf_unfiltered (_("Missing separate debuginfos, use: %s"),
++#ifdef DNF_DEBUGINFO_INSTALL
++		     "dnf "
++#endif
++		     "debuginfo-install");
++  for (array_iter = array; array_iter < array + missing_rpm_list_entries;
++       array_iter++)
++    {
++      putchar_unfiltered (' ');
++      puts_unfiltered (*array_iter);
++    }
++  putchar_unfiltered ('\n');
 +
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
-+$as_echo_n "checking rpm library API compatibility... " >&6; }
-+    # The compilation requires -Werror to verify anything.
-+    save_CFLAGS="$CFLAGS"
-+    CFLAGS="$CFLAGS -Werror"
-+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h.  */
++  while (missing_rpm_list != NULL)
++    {
++      list_iter = missing_rpm_list;
++      missing_rpm_list = list_iter->next;
++      xfree (list_iter);
++    }
++  missing_rpm_list_entries = 0;
 +
-+/* Duplicate here the declarations to verify they match "elfread.c".  */
-+#include <rpm/rpmlib.h>
-+#include <rpm/rpmts.h>
-+#include <rpm/rpmdb.h>
-+#include <rpm/header.h>
-+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
-+extern int rpmReadConfigFiles(const char * file, const char * target);
-+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
-+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
-+extern rpmts rpmtsCreate(void);
-+extern rpmts rpmtsFree(rpmts ts);
-+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
-+					    const void * keyp, size_t keylen);
++  do_cleanups (cleanups);
++}
 +
-+int
-+main ()
++static void
++missing_rpm_change (void)
 +{
++  debug_flush_missing ();
 +
-+  ;
-+  return 0;
++  gdb_assert (missing_rpm_list == NULL);
++  if (missing_rpm_hash != NULL)
++    {
++      htab_delete (missing_rpm_hash);
++      missing_rpm_hash = NULL;
++    }
 +}
-+_ACEOF
-+if ac_fn_c_try_compile "$LINENO"; then :
-+
-+      LIBRPM_COMPAT=true
-+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
 +
-+else
-+
-+      LIBRPM_COMPAT=false
-+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+
-+fi
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-+    CFLAGS="$save_CFLAGS"
++enum missing_exec
++  {
++    /* Init state.  EXEC_BFD also still could be NULL.  */
++    MISSING_EXEC_NOT_TRIED,
++    /* We saw a non-NULL EXEC_BFD but RPM has no info about it.  */
++    MISSING_EXEC_NOT_FOUND,
++    /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
++       or separate) or the main executable's RPM is now contained in
++       MISSING_RPM_HASH.  */
++    MISSING_EXEC_ENLISTED
++  };
++static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
 +
-+      if ! $LIBRPM_COMPAT; then
-+	HAVE_LIBRPM=false
-+	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
-+      fi
-+    fi
++#endif	/* HAVE_LIBRPM */
 +
-+    if $HAVE_LIBRPM; then
++void
++debug_flush_missing (void)
++{
++#ifdef HAVE_LIBRPM
++  missing_rpm_list_print ();
++#endif
++}
 +
-+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
+ /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
+-     Try to install the hash file ...
++     yum --enablerepo='*debug*' install ...
+    avoidance.  */
+ 
+ struct missing_filepair
+@@ -721,11 +1081,17 @@ missing_filepair_change (void)
+       /* All their memory came just from missing_filepair_OBSTACK.  */
+       missing_filepair_hash = NULL;
+     }
++#ifdef HAVE_LIBRPM
++  missing_exec = MISSING_EXEC_NOT_TRIED;
++#endif
+ }
+ 
+ static void
+ debug_print_executable_changed (void)
+ {
++#ifdef HAVE_LIBRPM
++  missing_rpm_change ();
++#endif
+   missing_filepair_change ();
+ }
+ 
+@@ -792,14 +1158,39 @@ debug_print_missing (const char *binary, const char *debug)
+ 
+   *slot = missing_filepair;
+ 
+-  /* We do not collect and flush these messages as each such message
+-     already requires its own separate lines.  */
++#ifdef HAVE_LIBRPM
++  if (missing_exec == MISSING_EXEC_NOT_TRIED)
++    {
++      char *execfilename;
+ 
+-  fprintf_unfiltered (gdb_stdlog,
+-		      _("Missing separate debuginfo for %s\n"), binary);
+-  if (debug != NULL)
+-    fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
+-			debug);
++      execfilename = get_exec_file (0);
++      if (execfilename != NULL)
++	{
++	  if (missing_rpm_enlist (execfilename) == 0)
++	    missing_exec = MISSING_EXEC_NOT_FOUND;
++	  else
++	    missing_exec = MISSING_EXEC_ENLISTED;
++	}
++    }
++  if (missing_exec != MISSING_EXEC_ENLISTED)
++    if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
++	&& (debug == NULL || missing_rpm_enlist (debug) == 0))
++#endif	/* HAVE_LIBRPM */
++      {
++	/* We do not collect and flush these messages as each such message
++	   already requires its own separate lines.  */
 +
-+      CFLAGS="$CFLAGS $RPM_CFLAGS"
-+      LIBS="$LIBS $RPM_LIBS"
-+    else
-+      if $RPM_REQUIRE; then
-+	as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
-+      else
-+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
-+$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
-+      fi
-+    fi
-+  fi
-+fi
++	fprintf_unfiltered (gdb_stdlog,
++			    _("Missing separate debuginfo for %s\n"), binary);
++        if (debug != NULL)
++	  fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
++#ifdef DNF_DEBUGINFO_INSTALL
++			      "dnf"
++#else
++			      "yum"
++#endif
++			      " --enablerepo='*debug*' install", debug);
++      }
+ }
+ 
+ /* See build-id.h.  */
+diff --git a/gdb/config.in b/gdb/config.in
+index 1d11a97080..edd7028f76 100644
+--- a/gdb/config.in
++++ b/gdb/config.in
+@@ -33,6 +33,9 @@
+ /* Define to BFD's default target vector. */
+ #undef DEFAULT_BFD_VEC
+ 
++/* librpm version specific library name to dlopen. */
++#undef DLOPEN_LIBRPM
 +
+ /* Define to 1 if translation of program messages to the user's native
+    language is requested. */
+ #undef ENABLE_NLS
+@@ -264,6 +267,9 @@
+ /* Define if Python 2.7 is being used. */
+ #undef HAVE_LIBPYTHON2_7
  
++/* Define if librpm library is being used. */
++#undef HAVE_LIBRPM
++
+ /* Define to 1 if you have the <libunwind-ia64.h> header file. */
+ #undef HAVE_LIBUNWIND_IA64_H
  
- subdirs="$subdirs testsuite"
-Index: gdb-7.11.50.20160630/gdb/configure.ac
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/configure.ac	2016-07-02 23:43:24.085214144 +0200
-+++ gdb-7.11.50.20160630/gdb/configure.ac	2016-07-03 14:37:12.582130819 +0200
-@@ -177,6 +177,199 @@
- 	      [Directories safe to hold auto-loaded files.])
- AC_MSG_RESULT([$with_auto_load_safe_path])
+diff --git a/gdb/configure b/gdb/configure
+index 092893d757..1cecdbc3b5 100755
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -716,6 +716,11 @@ PKGVERSION
+ HAVE_NATIVE_GCORE_TARGET
+ TARGET_OBS
+ subdirs
++RPM_LIBS
++RPM_CFLAGS
++PKG_CONFIG_LIBDIR
++PKG_CONFIG_PATH
++PKG_CONFIG
+ GDB_DATADIR
+ DEBUGDIR
+ MAKEINFO_EXTRA_FLAGS
+@@ -820,6 +825,7 @@ with_gdb_datadir
+ with_relocated_sources
+ with_auto_load_dir
+ with_auto_load_safe_path
++with_rpm
+ enable_targets
+ enable_64_bit_bfd
+ enable_gdbcli
+@@ -878,6 +884,11 @@ CCC
+ CPP
+ MAKEINFO
+ MAKEINFOFLAGS
++PKG_CONFIG
++PKG_CONFIG_PATH
++PKG_CONFIG_LIBDIR
++RPM_CFLAGS
++RPM_LIBS
+ YACC
+ YFLAGS
+ XMKMF'
+@@ -1548,6 +1559,8 @@ Optional Packages:
+                           [--with-auto-load-dir]
+   --without-auto-load-safe-path
+                           do not restrict auto-loaded files locations
++  --with-rpm              query rpm database for missing debuginfos (yes/no,
++                          def. auto=librpm.so)
+   --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
+   --with-curses           use the curses library instead of the termcap
+                           library
+@@ -1605,6 +1618,13 @@ Some influential environment variables:
+   MAKEINFO    Parent configure detects if it is of sufficient version.
+   MAKEINFOFLAGS
+               Parameters for MAKEINFO.
++  PKG_CONFIG  path to pkg-config utility
++  PKG_CONFIG_PATH
++              directories to add to pkg-config's search path
++  PKG_CONFIG_LIBDIR
++              path overriding pkg-config's built-in search path
++  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
++  RPM_LIBS    linker flags for RPM, overriding pkg-config
+   YACC        The `Yet Another C Compiler' implementation to use. Defaults to
+               the first program found out of: `bison -y', `byacc', `yacc'.
+   YFLAGS      The list of arguments that will be passed by default to $YACC.
+@@ -6486,6 +6506,494 @@ _ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
+ $as_echo "$with_auto_load_safe_path" >&6; }
  
 +# Integration with rpm library to support missing debuginfo suggestions.
 +# --without-rpm: Disable any rpm support.
@@ -872,12 +792,17 @@ Index: gdb-7.11.50.20160630/gdb/configure.ac
 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
 +#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
 +
-+AC_ARG_WITH([rpm],
-+  [AS_HELP_STRING([--with-rpm],
-+                  [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
 +
-+m4_pattern_allow([^AC_MSG_ERROR$])
-+m4_pattern_allow([^AC_MSG_WARN$])
++# Check whether --with-rpm was given.
++if test "${with_rpm+set}" = set; then :
++  withval=$with_rpm;
++else
++  with_rpm="auto"
++fi
++
++
++
++
 +if test "x$with_rpm" != "xno"; then
 +  if test "x$with_rpm" = "xyes"; then
 +    LIBRPM="librpm.so"
@@ -894,15 +819,28 @@ Index: gdb-7.11.50.20160630/gdb/configure.ac
 +  fi
 +  LIBRPM_STRING='"'"$LIBRPM"'"'
 +
-+  AC_MSG_CHECKING([specific librpm version])
++  { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
++$as_echo_n "checking specific librpm version... " >&6; }
 +  HAVE_DLOPEN_LIBRPM=false
 +  save_LIBS="$LIBS"
 +  LIBS="$LIBS -ldl"
-+  AC_RUN_IFELSE(AC_LANG_PROGRAM([[
++  if test "$cross_compiling" = yes; then :
++  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error "cannot run test program while cross compiling
++See \`config.log' for more details." "$LINENO" 5; }
++else
++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
 +#include <rpm/rpmlib.h>
 +#include <dlfcn.h>
 +#include <errno.h>
-+  ]], [[
++
++int
++main ()
++{
++
 +    void *h;
 +    const char *const *rpmverp;
 +    FILE *f;
@@ -970,21 +908,39 @@ Index: gdb-7.11.50.20160630/gdb/configure.ac
 +	fprintf (f, "%s\n", h2_name);
 +	return 0;
 +      }
-+  ]]), [
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++
 +    DLOPEN_LIBRPM="`cat conftest.out`"
 +    if test "x$DLOPEN_LIBRPM" != "x"; then
 +      HAVE_DLOPEN_LIBRPM=true
-+      AC_MSG_RESULT($DLOPEN_LIBRPM)
++      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
++$as_echo "$DLOPEN_LIBRPM" >&6; }
 +    fi
-+  ])
++
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++  conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
 +  rm -f conftest.out
 +
-+  m4_define([CHECK_LIBRPM_COMPAT], [
-+    AC_MSG_CHECKING([rpm library API compatibility])
++
++
++  if $HAVE_DLOPEN_LIBRPM; then
++
++    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
++$as_echo_n "checking rpm library API compatibility... " >&6; }
 +    # The compilation requires -Werror to verify anything.
 +    save_CFLAGS="$CFLAGS"
 +    CFLAGS="$CFLAGS -Werror"
-+    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
++    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
 +/* Duplicate here the declarations to verify they match "elfread.c".  */
 +#include <rpm/rpmlib.h>
 +#include <rpm/rpmts.h>
@@ -998,18 +954,31 @@ Index: gdb-7.11.50.20160630/gdb/configure.ac
 +extern rpmts rpmtsFree(rpmts ts);
 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
 +					    const void * keyp, size_t keylen);
-+    ]]), [
++
++int
++main ()
++{
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++
 +      LIBRPM_COMPAT=true
-+      AC_MSG_RESULT(yes)
-+    ], [
++      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++
++else
++
 +      LIBRPM_COMPAT=false
-+      AC_MSG_RESULT(no)
-+    ])
++      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 +    CFLAGS="$save_CFLAGS"
-+  ])
 +
-+  if $HAVE_DLOPEN_LIBRPM; then
-+    CHECK_LIBRPM_COMPAT
 +    if ! $LIBRPM_COMPAT; then
 +      HAVE_DLOPEN_LIBRPM=false
 +    fi
@@ -1017,496 +986,550 @@ Index: gdb-7.11.50.20160630/gdb/configure.ac
 +
 +  if $HAVE_DLOPEN_LIBRPM; then
 +    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
-+    AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
-+    AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
-+  else
-+    AC_MSG_RESULT(no)
-+    LIBS="$save_LIBS"
-+    if $DLOPEN_REQUIRE; then
-+      AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
-+    fi
-+    PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
-+
-+    if $HAVE_LIBRPM; then
-+      CHECK_LIBRPM_COMPAT
-+      if ! $LIBRPM_COMPAT; then
-+	HAVE_LIBRPM=false
-+	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
-+      fi
-+    fi
-+
-+    if $HAVE_LIBRPM; then
-+      AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
-+      CFLAGS="$CFLAGS $RPM_CFLAGS"
-+      LIBS="$LIBS $RPM_LIBS"
-+    else
-+      if $RPM_REQUIRE; then
-+	AC_MSG_ERROR($RPM_PKG_ERRORS)
-+      else
-+	AC_MSG_WARN($RPM_PKG_ERRORS)
-+      fi
-+    fi
-+  fi
-+fi
-+ 
- AC_CONFIG_SUBDIRS(testsuite)
- 
- # Check whether to support alternative target configurations
-Index: gdb-7.11.50.20160630/gdb/corelow.c
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/corelow.c	2016-07-03 14:34:32.022753582 +0200
-+++ gdb-7.11.50.20160630/gdb/corelow.c	2016-07-03 14:37:12.582130819 +0200
-@@ -310,7 +310,7 @@
-         symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
-     }
-   else
--    debug_print_missing (_("the main executable file"), build_id_filename);
-+    debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
- 
-   do_cleanups (back_to);
- 
-Index: gdb-7.11.50.20160630/gdb/build-id.c
-===================================================================
---- gdb-7.11.50.20160630.orig/gdb/build-id.c	2016-07-03 14:36:50.124938187 +0200
-+++ gdb-7.11.50.20160630/gdb/build-id.c	2016-07-03 14:42:25.171812134 +0200
-@@ -35,6 +35,7 @@
- #include "elf/common.h"
- #include "elf-bfd.h"
- #include <sys/stat.h>
-+#include "elf/external.h"
- 
- #define BUILD_ID_VERBOSE_NONE 0
- #define BUILD_ID_VERBOSE_FILENAMES 1
-@@ -665,8 +666,366 @@
-   return result;
- }
- 
-+#ifdef HAVE_LIBRPM
-+
-+#include <rpm/rpmlib.h>
-+#include <rpm/rpmts.h>
-+#include <rpm/rpmdb.h>
-+#include <rpm/header.h>
-+#ifdef DLOPEN_LIBRPM
-+#include <dlfcn.h>
-+#endif
-+
-+/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
-+   and avoid their duplicities during a single inferior run.  */
-+
-+static struct htab *missing_rpm_hash;
-+
-+/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
-+   all the rpms right before the nearest GDB prompt.  It gets cleared after
-+   each such print (it is questionable if we should clear it after the print).
-+   */
-+
-+struct missing_rpm
-+  {
-+    struct missing_rpm *next;
-+    char rpm[1];
-+  };
-+static struct missing_rpm *missing_rpm_list;
-+static int missing_rpm_list_entries;
-+
-+/* Returns the count of newly added rpms.  */
-+
-+static int
-+missing_rpm_enlist (const char *filename)
-+{
-+  static int rpm_init_done = 0;
-+  rpmts ts;
-+  rpmdbMatchIterator mi;
-+  int count = 0;
 +
-+#ifdef DLOPEN_LIBRPM
-+  /* Duplicate here the declarations to verify they match.  The same sanity
-+     check is present also in `configure.ac'.  */
-+  extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
-+  static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
-+  extern int rpmReadConfigFiles(const char * file, const char * target);
-+  static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
-+  extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
-+  static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
-+  extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
-+  static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
-+  extern rpmts rpmtsCreate(void);
-+  static rpmts (*rpmtsCreate_p) (void);
-+  extern rpmts rpmtsFree(rpmts ts);
-+  static rpmts (*rpmtsFree_p) (rpmts ts);
-+  extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
-+                                              const void * keyp, size_t keylen);
-+  static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
-+						    rpmTag rpmtag,
-+						    const void *keyp,
-+						    size_t keylen);
-+#else	/* !DLOPEN_LIBRPM */
-+# define headerFormat_p headerFormat
-+# define rpmReadConfigFiles_p rpmReadConfigFiles
-+# define rpmdbFreeIterator_p rpmdbFreeIterator
-+# define rpmdbNextIterator_p rpmdbNextIterator
-+# define rpmtsCreate_p rpmtsCreate
-+# define rpmtsFree_p rpmtsFree
-+# define rpmtsInitIterator_p rpmtsInitIterator
-+#endif	/* !DLOPEN_LIBRPM */
++cat >>confdefs.h <<_ACEOF
++#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
++_ACEOF
 +
-+  gdb_assert (filename != NULL);
 +
-+  if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
-+    return 0;
++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
 +
-+  if (is_target_filename (filename))
-+    return 0;
++  else
++    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++    LIBS="$save_LIBS"
++    if $DLOPEN_REQUIRE; then
++      as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
++    fi
 +
-+  if (filename[0] != '/')
-+    {
-+      warning (_("Ignoring non-absolute filename: <%s>"), filename);
-+      return 0;
-+    }
 +
-+  if (!rpm_init_done)
-+    {
-+      static int init_tried;
 +
-+      /* Already failed the initialization before?  */
-+      if (init_tried)
-+      	return 0;
-+      init_tried = 1;
 +
-+#ifdef DLOPEN_LIBRPM
-+      {
-+	void *h;
 +
-+	h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
-+	if (!h)
-+	  {
-+	    warning (_("Unable to open \"%s\" (%s), "
-+		      "missing debuginfos notifications will not be displayed"),
-+		     DLOPEN_LIBRPM, dlerror ());
-+	    return 0;
-+	  }
 +
-+	if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat"))
-+	      && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles"))
-+	      && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator"))
-+	      && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
-+	      && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
-+	      && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
-+	      && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
-+	  {
-+	    warning (_("Opened library \"%s\" is incompatible (%s), "
-+		      "missing debuginfos notifications will not be displayed"),
-+		     DLOPEN_LIBRPM, dlerror ());
-+	    if (dlclose (h))
-+	      warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
-+		       dlerror ());
-+	    return 0;
-+	  }
-+      }
-+#endif	/* DLOPEN_LIBRPM */
 +
-+      if (rpmReadConfigFiles_p (NULL, NULL) != 0)
-+	{
-+	  warning (_("Error reading the rpm configuration files"));
-+	  return 0;
-+	}
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++	if test -n "$ac_tool_prefix"; then
++  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
++set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  case $PKG_CONFIG in
++  [\\/]* | ?:[\\/]*)
++  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
++  ;;
++  *)
++  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++    for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
++    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++  done
++IFS=$as_save_IFS
 +
-+      rpm_init_done = 1;
-+    }
++  ;;
++esac
++fi
++PKG_CONFIG=$ac_cv_path_PKG_CONFIG
++if test -n "$PKG_CONFIG"; then
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
++$as_echo "$PKG_CONFIG" >&6; }
++else
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
 +
-+  ts = rpmtsCreate_p ();
 +
-+  mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
-+  if (mi != NULL)
-+    {
-+      for (;;)
-+	{
-+	  Header h;
-+	  char *debuginfo, **slot, *s, *s2;
-+	  errmsg_t err;
-+	  size_t srcrpmlen = sizeof (".src.rpm") - 1;
-+	  size_t debuginfolen = sizeof ("-debuginfo") - 1;
-+	  rpmdbMatchIterator mi_debuginfo;
++fi
++if test -z "$ac_cv_path_PKG_CONFIG"; then
++  ac_pt_PKG_CONFIG=$PKG_CONFIG
++  # Extract the first word of "pkg-config", so it can be a program name with args.
++set dummy pkg-config; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
++  $as_echo_n "(cached) " >&6
++else
++  case $ac_pt_PKG_CONFIG in
++  [\\/]* | ?:[\\/]*)
++  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
++  ;;
++  *)
++  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++  IFS=$as_save_IFS
++  test -z "$as_dir" && as_dir=.
++    for ac_exec_ext in '' $ac_executable_extensions; do
++  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
++    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++    break 2
++  fi
++done
++  done
++IFS=$as_save_IFS
 +
-+	  h = rpmdbNextIterator_p (mi);
-+	  if (h == NULL)
-+	    break;
++  ;;
++esac
++fi
++ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
++if test -n "$ac_pt_PKG_CONFIG"; then
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
++$as_echo "$ac_pt_PKG_CONFIG" >&6; }
++else
++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
 +
-+	  /* Verify the debuginfo file is not already installed.  */
++  if test "x$ac_pt_PKG_CONFIG" = x; then
++    PKG_CONFIG=""
++  else
++    case $cross_compiling:$ac_tool_warned in
++yes:)
++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
++ac_tool_warned=yes ;;
++esac
++    PKG_CONFIG=$ac_pt_PKG_CONFIG
++  fi
++else
++  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
++fi
 +
-+	  debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
-+				      &err);
-+	  if (!debuginfo)
-+	    {
-+	      warning (_("Error querying the rpm file `%s': %s"), filename,
-+	               err);
-+	      continue;
-+	    }
-+	  /* s = `.src.rpm-debuginfo.%{arch}' */
-+	  s = strrchr (debuginfo, '-') - srcrpmlen;
-+	  s2 = NULL;
-+	  if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
-+	    {
-+	      /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
-+	      s2 = (char *) memrchr (debuginfo, '-', s - debuginfo);
-+	    }
-+	  if (s2)
-+	    {
-+	      /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
-+	      s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo);
-+	    }
-+	  if (!s2)
-+	    {
-+	      warning (_("Error querying the rpm file `%s': %s"), filename,
-+	               debuginfo);
-+	      xfree (debuginfo);
-+	      continue;
-+	    }
-+	  /* s = `.src.rpm-debuginfo.%{arch}' */
-+	  /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
-+	  memmove (s2 + debuginfolen, s2, s - s2);
-+	  memcpy (s2, "-debuginfo", debuginfolen);
-+	  /* s = `XXXX.%{arch}' */
-+	  /* strlen ("XXXX") == srcrpmlen + debuginfolen */
-+	  /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
-+	  /* strlen ("XX") == srcrpmlen */
-+	  memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
-+		   strlen (s + srcrpmlen + debuginfolen) + 1);
-+	  /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
++fi
++if test -n "$PKG_CONFIG"; then
++	_pkg_min_version=0.9.0
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
++$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
++	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++	else
++		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++		PKG_CONFIG=""
++	fi
++fi
++
++pkg_failed=no
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
++$as_echo_n "checking for RPM... " >&6; }
++
++if test -n "$RPM_CFLAGS"; then
++    pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
++ elif test -n "$PKG_CONFIG"; then
++    if test -n "$PKG_CONFIG" && \
++    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
++  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
++  ac_status=$?
++  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++  test $ac_status = 0; }; then
++  pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
++		      test "x$?" != "x0" && pkg_failed=yes
++else
++  pkg_failed=yes
++fi
++ else
++    pkg_failed=untried
++fi
++if test -n "$RPM_LIBS"; then
++    pkg_cv_RPM_LIBS="$RPM_LIBS"
++ elif test -n "$PKG_CONFIG"; then
++    if test -n "$PKG_CONFIG" && \
++    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
++  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
++  ac_status=$?
++  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++  test $ac_status = 0; }; then
++  pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
++		      test "x$?" != "x0" && pkg_failed=yes
++else
++  pkg_failed=yes
++fi
++ else
++    pkg_failed=untried
++fi
 +
-+	  /* RPMDBI_PACKAGES requires keylen == sizeof (int).  */
-+	  /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel().  */
-+	  mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
-+	  xfree (debuginfo);
-+	  if (mi_debuginfo)
-+	    {
-+	      rpmdbFreeIterator_p (mi_debuginfo);
-+	      count = 0;
-+	      break;
-+	    }
 +
-+	  /* The allocated memory gets utilized below for MISSING_RPM_HASH.  */
-+	  debuginfo = headerFormat_p (h,
-+				      "%{name}-%{version}-%{release}.%{arch}",
-+				      &err);
-+	  if (!debuginfo)
-+	    {
-+	      warning (_("Error querying the rpm file `%s': %s"), filename,
-+	               err);
-+	      continue;
-+	    }
 +
-+	  /* Base package name for `debuginfo-install'.  We do not use the
-+	     `yum' command directly as the line
-+		 yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
-+	     would be more complicated than just:
-+		 debuginfo-install NAME-VERSION-RELEASE.ARCH
-+	     Do not supply the rpm base name (derived from .src.rpm name) as
-+	     debuginfo-install is unable to install the debuginfo package if
-+	     the base name PKG binary rpm is not installed while for example
-+	     PKG-libs would be installed (RH Bug 467901).
-+	     FUTURE: After multiple debuginfo versions simultaneously installed
-+	     get supported the support for the VERSION-RELEASE tags handling
-+	     may need an update.  */
++if test $pkg_failed = yes; then
++   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
 +
-+	  if (missing_rpm_hash == NULL)
-+	    {
-+	      /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
-+		 should not deallocate the entries.  */
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++        _pkg_short_errors_supported=yes
++else
++        _pkg_short_errors_supported=no
++fi
++        if test $_pkg_short_errors_supported = yes; then
++	        RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
++        else
++	        RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
++        fi
++	# Put the nasty error message in config.log where it belongs
++	echo "$RPM_PKG_ERRORS" >&5
 +
-+	      missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
-+			       (int (*) (const void *, const void *)) streq,
-+						    NULL, xcalloc, xfree);
-+	    }
-+	  slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
-+	  /* XCALLOC never returns NULL.  */
-+	  gdb_assert (slot != NULL);
-+	  if (*slot == NULL)
-+	    {
-+	      struct missing_rpm *missing_rpm;
++	HAVE_LIBRPM=false
++elif test $pkg_failed = untried; then
++     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++	HAVE_LIBRPM=false
++else
++	RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
++	RPM_LIBS=$pkg_cv_RPM_LIBS
++        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++	HAVE_LIBRPM=true
++fi
 +
-+	      *slot = debuginfo;
++    if $HAVE_LIBRPM; then
 +
-+	      missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
-+	      strcpy (missing_rpm->rpm, debuginfo);
-+	      missing_rpm->next = missing_rpm_list;
-+	      missing_rpm_list = missing_rpm;
-+	      missing_rpm_list_entries++;
-+	    }
-+	  else
-+	    xfree (debuginfo);
-+	  count++;
-+	}
++    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
++$as_echo_n "checking rpm library API compatibility... " >&6; }
++    # The compilation requires -Werror to verify anything.
++    save_CFLAGS="$CFLAGS"
++    CFLAGS="$CFLAGS -Werror"
++    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
 +
-+      rpmdbFreeIterator_p (mi);
-+    }
++/* Duplicate here the declarations to verify they match "elfread.c".  */
++#include <rpm/rpmlib.h>
++#include <rpm/rpmts.h>
++#include <rpm/rpmdb.h>
++#include <rpm/header.h>
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++					    const void * keyp, size_t keylen);
 +
-+  rpmtsFree_p (ts);
++int
++main ()
++{
 +
-+  return count;
++  ;
++  return 0;
 +}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
 +
-+static int
-+missing_rpm_list_compar (const char *const *ap, const char *const *bp)
-+{
-+  return strcoll (*ap, *bp);
-+}
++      LIBRPM_COMPAT=true
++      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
 +
-+/* It returns a NULL-terminated array of strings needing to be FREEd.  It may
-+   also return only NULL.  */
++else
 +
-+static void
-+missing_rpm_list_print (void)
-+{
-+  char **array, **array_iter;
-+  struct missing_rpm *list_iter;
-+  struct cleanup *cleanups;
++      LIBRPM_COMPAT=false
++      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
 +
-+  if (missing_rpm_list_entries == 0)
-+    return;
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++    CFLAGS="$save_CFLAGS"
 +
-+  array = (char **) xmalloc (sizeof (*array) * missing_rpm_list_entries);
-+  cleanups = make_cleanup (xfree, array);
++      if ! $LIBRPM_COMPAT; then
++	HAVE_LIBRPM=false
++	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
++      fi
++    fi
 +
-+  array_iter = array;
-+  for (list_iter = missing_rpm_list; list_iter != NULL;
-+       list_iter = list_iter->next)
-+    {
-+      *array_iter++ = list_iter->rpm;
-+    }
-+  gdb_assert (array_iter == array + missing_rpm_list_entries);
++    if $HAVE_LIBRPM; then
 +
-+  qsort (array, missing_rpm_list_entries, sizeof (*array),
-+	 (int (*) (const void *, const void *)) missing_rpm_list_compar);
++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
 +
-+  printf_unfiltered (_("Missing separate debuginfos, use: %s"),
-+#ifdef DNF_DEBUGINFO_INSTALL
-+		     "dnf "
-+#endif
-+		     "debuginfo-install");
-+  for (array_iter = array; array_iter < array + missing_rpm_list_entries;
-+       array_iter++)
-+    {
-+      putchar_unfiltered (' ');
-+      puts_unfiltered (*array_iter);
-+    }
-+  putchar_unfiltered ('\n');
++      CFLAGS="$CFLAGS $RPM_CFLAGS"
++      LIBS="$LIBS $RPM_LIBS"
++    else
++      if $RPM_REQUIRE; then
++	as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
++      else
++	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
++$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
++      fi
++    fi
++  fi
++fi
++
+ 
+ 
+ subdirs="$subdirs testsuite"
+diff --git a/gdb/configure.ac b/gdb/configure.ac
+index d4133ea71e..e232c1adcb 100644
+--- a/gdb/configure.ac
++++ b/gdb/configure.ac
+@@ -167,6 +167,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
+ 	      [Directories safe to hold auto-loaded files.])
+ AC_MSG_RESULT([$with_auto_load_safe_path])
+ 
++# Integration with rpm library to support missing debuginfo suggestions.
++# --without-rpm: Disable any rpm support.
++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
++#   Even with runtime missing `libname.so' GDB will still other run correctly.
++#   Missing `libname.so' during ./configure will abort the configuration.
++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
++#   minor version first such as `librpm-4.6.so' as minor version differences
++#   mean API+ABI incompatibility.  If the specific match versioned library name
++#   could not be found still open dynamically at least `librpm.so'.
++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
++#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
++#   be probably linked with the version specific library (as `librpm-4.6.so').
++#   Failure to find librpm by pkg-config will abort the configuration.
++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
++#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
++
++AC_ARG_WITH([rpm],
++  [AS_HELP_STRING([--with-rpm],
++                  [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
++
++m4_pattern_allow([^AC_MSG_ERROR$])
++m4_pattern_allow([^AC_MSG_WARN$])
++if test "x$with_rpm" != "xno"; then
++  if test "x$with_rpm" = "xyes"; then
++    LIBRPM="librpm.so"
++    RPM_REQUIRE=true
++    DLOPEN_REQUIRE=false
++  elif test "x$with_rpm" = "xauto"; then
++    LIBRPM="librpm.so"
++    RPM_REQUIRE=false
++    DLOPEN_REQUIRE=false
++  else
++    LIBRPM="$with_rpm"
++    RPM_REQUIRE=true
++    DLOPEN_REQUIRE=true
++  fi
++  LIBRPM_STRING='"'"$LIBRPM"'"'
++
++  AC_MSG_CHECKING([specific librpm version])
++  HAVE_DLOPEN_LIBRPM=false
++  save_LIBS="$LIBS"
++  LIBS="$LIBS -ldl"
++  AC_RUN_IFELSE(AC_LANG_PROGRAM([[
++#include <rpm/rpmlib.h>
++#include <dlfcn.h>
++#include <errno.h>
++  ]], [[
++    void *h;
++    const char *const *rpmverp;
++    FILE *f;
++
++    f = fopen ("conftest.out", "w");
++    if (!f)
++      {
++	fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
++		 strerror (errno));
++	return 1;
++      }
++    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
++    if (!h)
++      {
++	fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
++	return 1;
++      }
++    rpmverp = dlsym (h, "RPMVERSION");
++    if (!rpmverp)
++      {
++	fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
++	return 1;
++      }
++    fprintf (stderr, "RPMVERSION is: \"");
++    fprintf (stderr, "%s\"\n", *rpmverp);
 +
-+  while (missing_rpm_list != NULL)
-+    {
-+      list_iter = missing_rpm_list;
-+      missing_rpm_list = list_iter->next;
-+      xfree (list_iter);
-+    }
-+  missing_rpm_list_entries = 0;
++    /* Try to find the specific librpm version only for "librpm.so" as we do
++       not know how to assemble the version string otherwise.  */
 +
-+  do_cleanups (cleanups);
-+}
++    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
++      {
++	fprintf (f, "%s\n", $LIBRPM_STRING);
++	return 0;
++      }
++    else
++      {
++	char *h2_name;
++	void *h2;
++	int major, minor;
 +
-+static void
-+missing_rpm_change (void)
-+{
-+  debug_flush_missing ();
++	if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
++	  {
++	    fprintf (stderr, "Unable to parse RPMVERSION.\n");
++	    fprintf (f, "%s\n", $LIBRPM_STRING);
++	    return 0;
++	  }
++	/* Avoid the square brackets by malloc.  */
++	h2_name = malloc (64);
++	sprintf (h2_name, "librpm-%d.%d.so", major, minor);
++	h2 = dlopen (h2_name, RTLD_LAZY);
++	if (!h2)
++	  {
++	    fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
++	    fprintf (f, "%s\n", $LIBRPM_STRING);
++	    return 0;
++	  }
++	if (h2 != h)
++	  {
++	    fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
++		     $LIBRPM_STRING, h2_name);
++	    fprintf (f, "%s\n", $LIBRPM_STRING);
++	    return 0;
++	  }
++	/* Found the valid .so name with a specific version.  */
++	fprintf (f, "%s\n", h2_name);
++	return 0;
++      }
++  ]]), [
++    DLOPEN_LIBRPM="`cat conftest.out`"
++    if test "x$DLOPEN_LIBRPM" != "x"; then
++      HAVE_DLOPEN_LIBRPM=true
++      AC_MSG_RESULT($DLOPEN_LIBRPM)
++    fi
++  ])
++  rm -f conftest.out
 +
-+  gdb_assert (missing_rpm_list == NULL);
-+  if (missing_rpm_hash != NULL)
-+    {
-+      htab_delete (missing_rpm_hash);
-+      missing_rpm_hash = NULL;
-+    }
-+}
++  m4_define([CHECK_LIBRPM_COMPAT], [
++    AC_MSG_CHECKING([rpm library API compatibility])
++    # The compilation requires -Werror to verify anything.
++    save_CFLAGS="$CFLAGS"
++    CFLAGS="$CFLAGS -Werror"
++    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
++/* Duplicate here the declarations to verify they match "elfread.c".  */
++#include <rpm/rpmlib.h>
++#include <rpm/rpmts.h>
++#include <rpm/rpmdb.h>
++#include <rpm/header.h>
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++					    const void * keyp, size_t keylen);
++    ]]), [
++      LIBRPM_COMPAT=true
++      AC_MSG_RESULT(yes)
++    ], [
++      LIBRPM_COMPAT=false
++      AC_MSG_RESULT(no)
++    ])
++    CFLAGS="$save_CFLAGS"
++  ])
 +
-+enum missing_exec
-+  {
-+    /* Init state.  EXEC_BFD also still could be NULL.  */
-+    MISSING_EXEC_NOT_TRIED,
-+    /* We saw a non-NULL EXEC_BFD but RPM has no info about it.  */
-+    MISSING_EXEC_NOT_FOUND,
-+    /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
-+       or separate) or the main executable's RPM is now contained in
-+       MISSING_RPM_HASH.  */
-+    MISSING_EXEC_ENLISTED
-+  };
-+static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
++  if $HAVE_DLOPEN_LIBRPM; then
++    CHECK_LIBRPM_COMPAT
++    if ! $LIBRPM_COMPAT; then
++      HAVE_DLOPEN_LIBRPM=false
++    fi
++  fi
 +
-+#endif	/* HAVE_LIBRPM */
++  if $HAVE_DLOPEN_LIBRPM; then
++    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
++    AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
++    AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
++  else
++    AC_MSG_RESULT(no)
++    LIBS="$save_LIBS"
++    if $DLOPEN_REQUIRE; then
++      AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
++    fi
++    PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
 +
-+void
-+debug_flush_missing (void)
-+{
-+#ifdef HAVE_LIBRPM
-+  missing_rpm_list_print ();
-+#endif
-+}
++    if $HAVE_LIBRPM; then
++      CHECK_LIBRPM_COMPAT
++      if ! $LIBRPM_COMPAT; then
++	HAVE_LIBRPM=false
++	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
++      fi
++    fi
 +
- /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
--     Try to install the hash file ...
-+     yum --enablerepo='*debug*' install ...
-    avoidance.  */
++    if $HAVE_LIBRPM; then
++      AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
++      CFLAGS="$CFLAGS $RPM_CFLAGS"
++      LIBS="$LIBS $RPM_LIBS"
++    else
++      if $RPM_REQUIRE; then
++	AC_MSG_ERROR($RPM_PKG_ERRORS)
++      else
++	AC_MSG_WARN($RPM_PKG_ERRORS)
++      fi
++    fi
++  fi
++fi
++ 
+ AC_CONFIG_SUBDIRS(testsuite)
  
- struct missing_filepair
-@@ -720,11 +1079,17 @@
-       /* All their memory came just from missing_filepair_OBSTACK.  */
-       missing_filepair_hash = NULL;
+ # Check whether to support alternative target configurations
+diff --git a/gdb/corelow.c b/gdb/corelow.c
+index c5b642db81..6e027c12e2 100644
+--- a/gdb/corelow.c
++++ b/gdb/corelow.c
+@@ -309,7 +309,7 @@ build_id_locate_exec (int from_tty)
+         symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
      }
-+#ifdef HAVE_LIBRPM
-+  missing_exec = MISSING_EXEC_NOT_TRIED;
-+#endif
- }
+   else
+-    debug_print_missing (_("the main executable file"), build_id_filename);
++    debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
  
- static void
- debug_print_executable_changed (void)
- {
-+#ifdef HAVE_LIBRPM
-+  missing_rpm_change ();
-+#endif
-   missing_filepair_change ();
- }
+   do_cleanups (back_to);
  
-@@ -791,14 +1156,39 @@
+diff --git a/gdb/event-top.c b/gdb/event-top.c
+index 0c1528e5eb..0d668f35e0 100644
+--- a/gdb/event-top.c
++++ b/gdb/event-top.c
+@@ -40,6 +40,7 @@
+ #include "buffer.h"
+ #include "ser-event.h"
+ #include "gdb_select.h"
++#include "symfile.h"
  
-   *slot = missing_filepair;
+ /* readline include files.  */
+ #include "readline/readline.h"
+@@ -359,6 +360,8 @@ display_gdb_prompt (const char *new_prompt)
+   /* Reset the nesting depth used when trace-commands is set.  */
+   reset_command_nest_depth ();
  
--  /* We do not collect and flush these messages as each such message
--     already requires its own separate lines.  */
-+#ifdef HAVE_LIBRPM
-+  if (missing_exec == MISSING_EXEC_NOT_TRIED)
-+    {
-+      char *execfilename;
++  debug_flush_missing ();
++
+   /* Do not call the python hook on an explicit prompt change as
+      passed to this function, as this forms a secondary/local prompt,
+      IE, displayed but not set.  */
+@@ -774,7 +777,10 @@ command_line_handler (char *rl)
+       command_handler (cmd);
  
--  fprintf_unfiltered (gdb_stdlog,
--		      _("Missing separate debuginfo for %s\n"), binary);
--  if (debug != NULL)
--    fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
--			debug);
-+      execfilename = get_exec_file (0);
-+      if (execfilename != NULL)
+       if (ui->prompt_state != PROMPTED)
+-	display_gdb_prompt (0);
 +	{
-+	  if (missing_rpm_enlist (execfilename) == 0)
-+	    missing_exec = MISSING_EXEC_NOT_FOUND;
-+	  else
-+	    missing_exec = MISSING_EXEC_ENLISTED;
++	  debug_flush_missing ();
++	  display_gdb_prompt (0);
 +	}
-+    }
-+  if (missing_exec != MISSING_EXEC_ENLISTED)
-+    if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
-+	&& (debug == NULL || missing_rpm_enlist (debug) == 0))
-+#endif	/* HAVE_LIBRPM */
-+      {
-+	/* We do not collect and flush these messages as each such message
-+	   already requires its own separate lines.  */
-+
-+	fprintf_unfiltered (gdb_stdlog,
-+			    _("Missing separate debuginfo for %s\n"), binary);
-+        if (debug != NULL)
-+	  fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
-+#ifdef DNF_DEBUGINFO_INSTALL
-+			      "dnf"
-+#else
-+			      "yum"
-+#endif
-+			      " --enablerepo='*debug*' install", debug);
-+      }
+     }
  }
  
- /* See build-id.h.  */
+diff --git a/gdb/symfile.h b/gdb/symfile.h
+index 0d51f46d78..82c76431e1 100644
+--- a/gdb/symfile.h
++++ b/gdb/symfile.h
+@@ -546,6 +546,8 @@ void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
+ /* build-id support.  */
+ extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
+ extern void debug_print_missing (const char *binary, const char *debug);
++extern void debug_flush_missing (void);
++#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
+ 
+ /* From dwarf2read.c */
+ 
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate-solib-missing-ids.patch b/gdb-6.6-buildid-locate-solib-missing-ids.patch
index f4dccc9..6afc250 100644
--- a/gdb-6.6-buildid-locate-solib-missing-ids.patch
+++ b/gdb-6.6-buildid-locate-solib-missing-ids.patch
@@ -1,11 +1,32 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: gdb-6.6-buildid-locate-solib-missing-ids.patch
+
+FileName: gdb-6.6-buildid-locate-solib-missing-ids.patch
+
+;; Fix loading of core files without build-ids but with build-ids in executables.
+;; Load strictly build-id-checked core files only if no executable is specified
+;; (Jan Kratochvil, RH BZ 1339862).
+;;=push+jan
+
 gdb returns an incorrect back trace when applying a debuginfo
 https://bugzilla.redhat.com/show_bug.cgi?id=1339862
+---
+ gdb/solib-svr4.c                                   |  35 ++++---
+ .../gcore-buildid-exec-but-not-solib-lib.c         |  21 +++++
+ .../gcore-buildid-exec-but-not-solib-main.c        |  25 +++++
+ .../gdb.base/gcore-buildid-exec-but-not-solib.exp  | 105 +++++++++++++++++++++
+ 4 files changed, 167 insertions(+), 19 deletions(-)
+ create mode 100644 gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
+ create mode 100644 gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
+ create mode 100644 gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
 
-Index: gdb-7.9.90.20150709/gdb/solib-svr4.c
-===================================================================
---- gdb-7.9.90.20150709.orig/gdb/solib-svr4.c	2015-07-09 18:18:54.526417766 +0200
-+++ gdb-7.9.90.20150709/gdb/solib-svr4.c	2015-07-09 18:19:33.074746586 +0200
-@@ -1381,14 +1381,27 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
+diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
+index a3399ad8f7..d7eeb6350d 100644
+--- a/gdb/solib-svr4.c
++++ b/gdb/solib-svr4.c
+@@ -1387,14 +1387,27 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
  	}
  
        {
@@ -31,11 +52,11 @@ Index: gdb-7.9.90.20150709/gdb/solib-svr4.c
 +	   to the only existing file loaded that time - the executable.  */
 +	if (symfile_objfile != NULL
 +	    && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0)
-+	  build_id = build_id_addr_get (newobj->lm_info->l_ld);
++	  build_id = build_id_addr_get (li->l_ld);
  	if (build_id != NULL)
  	  {
  	    char *name, *build_id_filename;
-@@ -1403,23 +1416,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
+@@ -1409,23 +1422,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
  		xfree (name);
  	      }
  	    else
@@ -60,8 +81,69 @@ Index: gdb-7.9.90.20150709/gdb/solib-svr4.c
  
  	    xfree (build_id_filename);
  	    xfree (build_id);
---- /dev/null	2016-07-02 20:29:01.679404943 +0200
-+++ gdb-7.11.50.20160721/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp	2016-07-31 23:04:49.062753722 +0200
+diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
+new file mode 100644
+index 0000000000..d74b690c73
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c
+@@ -0,0 +1,21 @@
++/* Copyright 2010 Free Software Foundation, Inc.
++
++   This file is part of GDB.
++
++   This program is free software; you can redistribute it and/or modify
++   it under the terms of the GNU General Public License as published by
++   the Free Software Foundation; either version 3 of the License, or
++   (at your option) any later version.
++
++   This program is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++   GNU General Public License for more details.
++
++   You should have received a copy of the GNU General Public License
++   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
++
++void
++lib (void)
++{
++}
+diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
+new file mode 100644
+index 0000000000..46b9dfe161
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c
+@@ -0,0 +1,25 @@
++/* Copyright 2010 Free Software Foundation, Inc.
++
++   This file is part of GDB.
++
++   This program is free software; you can redistribute it and/or modify
++   it under the terms of the GNU General Public License as published by
++   the Free Software Foundation; either version 3 of the License, or
++   (at your option) any later version.
++
++   This program is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++   GNU General Public License for more details.
++
++   You should have received a copy of the GNU General Public License
++   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
++
++extern void lib (void);
++
++int
++main (void)
++{
++  lib ();
++  return 0;
++}
+diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
+new file mode 100644
+index 0000000000..0c46489f31
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp
 @@ -0,0 +1,105 @@
 +# Copyright 2016 Free Software Foundation, Inc.
 +
@@ -168,55 +250,6 @@ Index: gdb-7.9.90.20150709/gdb/solib-svr4.c
 +
 +gdb_test "bt"
 +gdb_test "info shared"
---- /dev/null	2016-07-02 20:29:01.679404943 +0200
-+++ gdb-7.11.50.20160721/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c	2016-07-28 21:06:40.977786922 +0200
-@@ -0,0 +1,25 @@
-+/* Copyright 2010 Free Software Foundation, Inc.
-+
-+   This file is part of GDB.
-+
-+   This program is free software; you can redistribute it and/or modify
-+   it under the terms of the GNU General Public License as published by
-+   the Free Software Foundation; either version 3 of the License, or
-+   (at your option) any later version.
-+
-+   This program is distributed in the hope that it will be useful,
-+   but WITHOUT ANY WARRANTY; without even the implied warranty of
-+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+   GNU General Public License for more details.
-+
-+   You should have received a copy of the GNU General Public License
-+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-+
-+extern void lib (void);
-+
-+int
-+main (void)
-+{
-+  lib ();
-+  return 0;
-+}
---- /dev/null	2016-07-02 20:29:01.679404943 +0200
-+++ gdb-7.11.50.20160721/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c	2016-07-28 21:06:40.977786922 +0200
-@@ -0,0 +1,21 @@
-+/* Copyright 2010 Free Software Foundation, Inc.
-+
-+   This file is part of GDB.
-+
-+   This program is free software; you can redistribute it and/or modify
-+   it under the terms of the GNU General Public License as published by
-+   the Free Software Foundation; either version 3 of the License, or
-+   (at your option) any later version.
-+
-+   This program is distributed in the hope that it will be useful,
-+   but WITHOUT ANY WARRANTY; without even the implied warranty of
-+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+   GNU General Public License for more details.
-+
-+   You should have received a copy of the GNU General Public License
-+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-+
-+void
-+lib (void)
-+{
-+}
+-- 
+2.14.3
+
diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch
index 3ab89cf..947a752 100644
--- a/gdb-6.6-buildid-locate.patch
+++ b/gdb-6.6-buildid-locate.patch
@@ -1,352 +1,34 @@
-Index: gdb-7.99.90.20170420/gdb/corelow.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/corelow.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/corelow.c	2017-04-20 23:00:43.358629183 +0200
-@@ -45,6 +45,10 @@
- #include "gdb_bfd.h"
- #include "completer.h"
- #include "filestuff.h"
-+#include "auxv.h"
-+#include "elf/common.h"
-+#include "gdbcmd.h"
-+#include "build-id.h"
- 
- #ifndef O_LARGEFILE
- #define O_LARGEFILE 0
-@@ -266,6 +270,54 @@
-     inferior_ptid = ptid;			/* Yes, make it current.  */
- }
- 
-+static int build_id_core_loads = 1;
-+
-+static void
-+build_id_locate_exec (int from_tty)
-+{
-+  CORE_ADDR at_entry;
-+  struct bfd_build_id *build_id;
-+  char *execfilename, *debug_filename;
-+  char *build_id_filename;
-+  struct cleanup *back_to;
-+
-+  if (exec_bfd != NULL || symfile_objfile != NULL)
-+    return;
-+
-+  if (target_auxv_search (&current_target, AT_ENTRY, &at_entry) <= 0)
-+    return;
-+
-+  build_id = build_id_addr_get (at_entry);
-+  if (build_id == NULL)
-+    return;
-+  back_to = make_cleanup (xfree, build_id);
-+
-+  /* SYMFILE_OBJFILE should refer to the main executable (not only to its
-+     separate debug info file).  gcc44+ keeps .eh_frame only in the main
-+     executable without its duplicate .debug_frame in the separate debug info
-+     file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer
-+     directly to the separate debug info file.  */
-+
-+  execfilename = build_id_to_filename (build_id, &build_id_filename);
-+  make_cleanup (xfree, build_id_filename);
-+
-+  if (execfilename != NULL)
-+    {
-+      make_cleanup (xfree, execfilename);
-+      exec_file_attach (execfilename, from_tty);
-+      symbol_file_add_main (execfilename,
-+			    symfile_add_flag (!from_tty ? 0 : SYMFILE_VERBOSE));
-+      if (symfile_objfile != NULL)
-+        symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
-+    }
-+  else
-+    debug_print_missing (_("the main executable file"), build_id_filename);
-+
-+  do_cleanups (back_to);
-+
-+  /* No automatic SOLIB_ADD as the libraries would get read twice.  */
-+}
-+
- /* This routine opens and sets up the core file bfd.  */
- 
- static void
-@@ -402,6 +454,14 @@
- 	switch_to_thread (thread->ptid);
-     }
- 
-+  /* Find the build_id identifiers.  If it gets executed after
-+     POST_CREATE_INFERIOR we would clash with asking to discard the already
-+     loaded VDSO symbols.  If it gets executed before bfd_map_over_sections
-+     INFERIOR_PTID is still not set and libthread_db initialization crashes on
-+     PID == 0 in ps_pglobal_lookup.  */
-+  if (build_id_core_loads != 0)
-+    build_id_locate_exec (from_tty);
-+
-   post_create_inferior (&core_ops, from_tty);
- 
-   /* Now go through the target stack looking for threads since there
-@@ -1079,4 +1139,11 @@
-   init_core_ops ();
- 
-   add_target_with_completer (&core_ops, filename_completer);
-+
-+  add_setshow_boolean_cmd ("build-id-core-loads", class_files,
-+			   &build_id_core_loads, _("\
-+Set whether CORE-FILE loads the build-id associated files automatically."), _("\
-+Show whether CORE-FILE loads the build-id associated files automatically."),
-+			   NULL, NULL, NULL,
-+			   &setlist, &showlist);
- }
-Index: gdb-7.99.90.20170420/gdb/doc/gdb.texinfo
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/doc/gdb.texinfo	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/doc/gdb.texinfo	2017-04-20 23:00:43.366629228 +0200
-@@ -18987,6 +18987,27 @@
- 
- @end table
- 
-+You can also adjust the current verbosity of the @dfn{build id} locating.
-+
-+ at table @code
-+
-+ at kindex set build-id-verbose
-+ at item set build-id-verbose 0
-+No additional messages are printed.
-+
-+ at item set build-id-verbose 1
-+Missing separate debug filenames are printed.
-+
-+ at item set build-id-verbose 2
-+Missing separate debug filenames are printed and also all the parsing of the
-+binaries to find their @dfn{build id} content is printed.
-+
-+ at kindex show build-id-verbose
-+ at item show build-id-verbose
-+Show the current verbosity value for the @dfn{build id} content locating.
-+
-+ at end table
-+
- @cindex @code{.gnu_debuglink} sections
- @cindex debug link sections
- A debug link is a special section of the executable file named
-Index: gdb-7.99.90.20170420/gdb/solib-svr4.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/solib-svr4.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/solib-svr4.c	2017-04-20 23:00:43.367629234 +0200
-@@ -45,6 +45,7 @@
- #include "auxv.h"
- #include "gdb_bfd.h"
- #include "probe.h"
-+#include "build-id.h"
- 
- static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
- static int svr4_have_link_map_offsets (void);
-@@ -1420,9 +1421,52 @@
- 	  continue;
- 	}
- 
--      strncpy (newobj->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
--      newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
--      strcpy (newobj->so_original_name, newobj->so_name);
-+      {
-+	struct bfd_build_id *build_id;
-+
-+	strncpy (newobj->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
-+	newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
-+	/* May get overwritten below.  */
-+	strcpy (newobj->so_name, newobj->so_original_name);
-+
-+	build_id = build_id_addr_get (newobj->lm_info->l_ld);
-+	if (build_id != NULL)
-+	  {
-+	    char *name, *build_id_filename;
-+
-+	    /* Missing the build-id matching separate debug info file
-+	       would be handled while SO_NAME gets loaded.  */
-+	    name = build_id_to_filename (build_id, &build_id_filename);
-+	    if (name != NULL)
-+	      {
-+		strncpy (newobj->so_name, name, SO_NAME_MAX_PATH_SIZE - 1);
-+		newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
-+		xfree (name);
-+	      }
-+	    else
-+	      {
-+		debug_print_missing (newobj->so_name, build_id_filename);
-+
-+		/* In the case the main executable was found according to
-+		   its build-id (from a core file) prevent loading
-+		   a different build of a library with accidentally the
-+		   same SO_NAME.
-+
-+		   It suppresses bogus backtraces (and prints "??" there
-+		   instead) if the on-disk files no longer match the
-+		   running program version.  */
-+
-+		if (symfile_objfile != NULL
-+		    && (symfile_objfile->flags
-+			& OBJF_BUILD_ID_CORE_LOADED) != 0)
-+		  newobj->so_name[0] = 0;
-+	      }
-+
-+	    xfree (build_id_filename);
-+	    xfree (build_id);
-+	  }
-+      }
-+
-       xfree (buffer);
- 
-       /* If this entry has no name, or its name matches the name
-Index: gdb-7.99.90.20170420/gdb/elfread.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/elfread.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/elfread.c	2017-04-20 23:00:43.367629234 +0200
-@@ -1265,8 +1265,9 @@
- 	   && objfile->separate_debug_objfile == NULL
- 	   && objfile->separate_debug_objfile_backlink == NULL)
-     {
-+      gdb::unique_xmalloc_ptr<char> build_id_filename;
-       gdb::unique_xmalloc_ptr<char> debugfile
--	(find_separate_debug_file_by_buildid (objfile));
-+	(find_separate_debug_file_by_buildid (objfile, &build_id_filename));
- 
-       if (debugfile == NULL)
- 	debugfile.reset (find_separate_debug_file_by_debuglink (objfile));
-@@ -1278,6 +1279,10 @@
- 	  symbol_file_add_separate (abfd.get (), debugfile.get (),
- 				    symfile_flags, objfile);
- 	}
-+      /* Check if any separate debug info has been extracted out.  */
-+      else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink")
-+	       != NULL)
-+	debug_print_missing (objfile_name (objfile), build_id_filename.get ());
-     }
- }
- 
-Index: gdb-7.99.90.20170420/gdb/symfile.h
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/symfile.h	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/symfile.h	2017-04-20 23:00:43.368629240 +0200
-@@ -567,6 +567,10 @@
- void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
- 			   int need_fullname);
- 
-+/* build-id support.  */
-+extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
-+extern void debug_print_missing (const char *binary, const char *debug);
-+
- /* From dwarf2read.c */
- 
- /* Names for a dwarf2 debugging section.  The field NORMAL is the normal
-Index: gdb-7.99.90.20170420/gdb/testsuite/lib/gdb.exp
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/testsuite/lib/gdb.exp	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/testsuite/lib/gdb.exp	2017-04-20 23:00:43.369629245 +0200
-@@ -1646,6 +1646,16 @@
- 	    warning "Couldn't set the width to 0."
- 	}
-     }
-+    # Turn off the missing warnings as the testsuite does not expect it.
-+    send_gdb "set build-id-verbose 0\n"
-+    gdb_expect 10 {
-+	-re "$gdb_prompt $" {
-+	    verbose "Disabled the missing debug infos warnings." 2
-+	}
-+	timeout {
-+	    warning "Could not disable the missing debug infos warnings.."
-+	}
-+    }
-     return 0
- }
- 
-Index: gdb-7.99.90.20170420/gdb/testsuite/lib/mi-support.exp
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/testsuite/lib/mi-support.exp	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/testsuite/lib/mi-support.exp	2017-04-20 23:00:43.369629245 +0200
-@@ -309,6 +309,16 @@
- 	    warning "Couldn't set the width to 0."
- 	}
-     }
-+    # Turn off the missing warnings as the testsuite does not expect it.
-+    send_gdb "190-gdb-set build-id-verbose 0\n"
-+    gdb_expect 10 {
-+	-re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
-+	    verbose "Disabled the missing debug infos warnings." 2
-+	}
-+	timeout {
-+	    warning "Could not disable the missing debug infos warnings.."
-+	}
-+    }
- 
-     if { $separate_inferior_pty } {
- 	mi_create_inferior_pty
-Index: gdb-7.99.90.20170420/gdb/testsuite/gdb.base/new-ui-pending-input.exp
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/testsuite/gdb.base/new-ui-pending-input.exp	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/testsuite/gdb.base/new-ui-pending-input.exp	2017-04-20 23:00:43.369629245 +0200
-@@ -62,6 +62,7 @@
-     set options ""
-     append options " -iex \"set height 0\""
-     append options " -iex \"set width 0\""
-+    append options " -iex \"set build-id-verbose 0\""
-     append options " -iex \"new-ui console $extra_tty_name\""
-     append options " -ex \"b $bpline\""
-     append options " -ex \"run\""
-Index: gdb-7.99.90.20170420/gdb/objfiles.h
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/objfiles.h	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/objfiles.h	2017-04-20 23:00:43.370629251 +0200
-@@ -444,6 +444,10 @@
-   htab_t static_links;
- };
- 
-+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules.  */
-+
-+#define OBJF_BUILD_ID_CORE_LOADED static_cast<enum objfile_flag>(1 << 12)
-+
- /* Declarations for functions defined in objfiles.c */
- 
- extern struct objfile *allocate_objfile (bfd *, const char *name,
-Index: gdb-7.99.90.20170420/gdb/testsuite/gdb.base/corefile.exp
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/testsuite/gdb.base/corefile.exp	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/testsuite/gdb.base/corefile.exp	2017-04-20 23:00:43.370629251 +0200
-@@ -293,3 +293,33 @@
- 	pass $test
-     }
- }
-+
-+
-+# Test auto-loading of binary files through build-id from the core file.
-+set buildid [build_id_debug_filename_get $binfile]
-+set wholetest "binfile found by build-id"
-+if {$buildid == ""} {
-+    untested "$wholetest (binary has no build-id)"
-+} else {
-+    gdb_exit
-+    gdb_start
-+
-+    regsub {\.debug$} $buildid {} buildid
-+    set debugdir [standard_output_file ${testfile}-debugdir]
-+    file delete -force -- $debugdir
-+    file mkdir $debugdir/[file dirname $buildid]
-+    file copy $binfile $debugdir/$buildid
-+
-+    set test "show debug-file-directory"
-+    gdb_test_multiple $test $test {
-+	-re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" {
-+	    set debugdir_orig $expect_out(1,string)
-+	    pass $test
-+	}
-+    }
-+    gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory"
-+    gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.}
-+    gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable"
-+    gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*"
-+    pass $wholetest
-+}
-Index: gdb-7.99.90.20170420/gdb/build-id.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/build-id.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/build-id.c	2017-04-20 23:03:00.060399474 +0200
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Fedora GDB patches <invalid at email.com>
+Date: Fri, 27 Oct 2017 21:07:50 +0200
+Subject: gdb-6.6-buildid-locate.patch
+
+FileName: gdb-6.6-buildid-locate.patch
+
+;; New locating of the matching binaries from the pure core file (build-id).
+;;=push+jan
+---
+ gdb/build-id.c                                  | 753 +++++++++++++++++++++++-
+ gdb/build-id.h                                  |  15 +-
+ gdb/coffread.c                                  |   2 +-
+ gdb/corelow.c                                   |  67 +++
+ gdb/doc/gdb.texinfo                             |  21 +
+ gdb/dwarf2read.c                                |   2 +-
+ gdb/elfread.c                                   |   7 +-
+ gdb/objfiles.h                                  |   4 +
+ gdb/python/py-objfile.c                         |   4 +-
+ gdb/solib-svr4.c                                |  50 +-
+ gdb/symfile.h                                   |   4 +
+ gdb/testsuite/gdb.base/corefile.exp             |  30 +
+ gdb/testsuite/gdb.base/new-ui-pending-input.exp |   1 +
+ gdb/testsuite/lib/gdb.exp                       |  10 +
+ gdb/testsuite/lib/mi-support.exp                |  10 +
+ 15 files changed, 940 insertions(+), 40 deletions(-)
+
+diff --git a/gdb/build-id.c b/gdb/build-id.c
+index 945da4f3cf..5740628386 100644
+--- a/gdb/build-id.c
++++ b/gdb/build-id.c
 @@ -26,11 +26,67 @@
  #include "objfiles.h"
  #include "filenames.h"
@@ -416,7 +98,7 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
  {
    if (!bfd_check_format (abfd, bfd_object))
      return NULL;
-@@ -42,6 +98,348 @@
+@@ -42,6 +98,348 @@ build_id_bfd_get (bfd *abfd)
    return NULL;
  }
  
@@ -765,7 +447,7 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
  /* See build-id.h.  */
  
  int
-@@ -50,7 +448,7 @@
+@@ -50,7 +448,7 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
    const struct bfd_build_id *found;
    int retval = 0;
  
@@ -774,7 +456,7 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
  
    if (found == NULL)
      warning (_("File \"%s\" has no build-id, file skipped"),
-@@ -65,23 +463,54 @@
+@@ -65,23 +463,54 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
    return retval;
  }
  
@@ -836,7 +518,7 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
  
    /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
       cause "/.build-id/..." lookups.  */
-@@ -94,9 +523,12 @@
+@@ -94,9 +523,12 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
        size_t debugdir_len = strlen (debugdir);
        const gdb_byte *data = build_id;
        size_t size = build_id_len;
@@ -850,18 +532,22 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
  
        memcpy (link, debugdir, debugdir_len);
        s = &link[debugdir_len];
-@@ -110,45 +542,290 @@
+@@ -110,52 +542,299 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
  	*s++ = '/';
        while (size-- > 0)
  	s += sprintf (s, "%02x", (unsigned) *data++);
 -      strcpy (s, ".debug");
-+      for (seqno = 0;; seqno++)
-+	{
-+	  char *s2;
+ 
+       if (separate_debug_file_debug)
+ 	printf_unfiltered (_("  Trying %s\n"), link);
  
 -      /* lrealpath() is expensive even for the usually non-existent files.  */
 -      if (access (link, F_OK) == 0)
 -	filename = lrealpath (link);
++      for (seqno = 0;; seqno++)
++	{
++	  char *s2;
++
 +	  if (seqno)
 +	    {
 +	      /* There can be multiple build-id symlinks pointing to real files
@@ -903,25 +589,17 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
 +
 +	  if (abfd == NULL)
 +	    continue;
- 
--      if (filename == NULL)
--	continue;
++
 +	  if (build_id_verify (abfd.get(), build_id_len, build_id))
 +	    break;
- 
--      /* We expect to be silent on the non-existing files.  */
--      inner = make_cleanup (xfree, filename);
--      abfd = gdb_bfd_open (filename, gnutarget, -1);
--      do_cleanups (inner);
++
 +	  abfd.release ();
- 
--      if (abfd == NULL)
--	continue;
++
 +	  filename = NULL;
 +	}
  
--      if (build_id_verify (abfd.get(), build_id_len, build_id))
--	break;
+-      if (filename == NULL)
+-	continue;
 +      if (filename != NULL)
 +	{
 +	  /* LINK_ALL is not used below in this non-NULL FILENAME case.  */
@@ -929,22 +607,30 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
 +	  break;
 +	}
  
--      abfd.release ();
+-      /* We expect to be silent on the non-existing files.  */
+-      inner = make_cleanup (xfree, filename);
+-      abfd = gdb_bfd_open (filename, gnutarget, -1);
+-      do_cleanups (inner);
 +      /* If the symlink has target request to install the target.
 +         BASE-debuginfo.rpm contains the symlink but BASE.rpm may be missing.
 +         https://bugzilla.redhat.com/show_bug.cgi?id=981154  */
 +      link0_resolved = link_resolve (link0, 0);
 +      xfree (link0);
-+
+ 
+-      if (abfd == NULL)
+-	continue;
 +      if (link_all == NULL)
 +	link_all = link0_resolved;
 +      else
 +	{
 +	  size_t len_orig = strlen (link_all);
-+
+ 
+-      if (build_id_verify (abfd.get(), build_id_len, build_id))
+-	break;
 +	  link_all = (char *) xrealloc (link_all,
 +					len_orig + 1 + strlen (link0_resolved) + 1);
-+
+ 
+-      abfd.release ();
 +	  /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with
 +	     its possible use as an argument for installation command.  */
 +	  link_all[len_orig] = ' ';
@@ -1141,6 +827,10 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
 +  build_id = build_id_bfd_shdr_get (objfile->obfd);
    if (build_id != NULL)
      {
+       if (separate_debug_file_debug)
+ 	printf_unfiltered (_("\nLooking for separate debug info (build-id) for "
+ 			     "%s\n"), objfile_name (objfile));
+ 
 +      char *build_id_filename_cstr = NULL;
        gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
 -						   build_id->data));
@@ -1156,10 +846,11 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
 +	      build_id_filename_cstr = NULL;
 +	    }
 +	}
++
        /* Prevent looping on a stripped .debug file.  */
        if (abfd != NULL
  	  && filename_cmp (bfd_get_filename (abfd.get ()),
-@@ -160,3 +837,21 @@
+@@ -167,3 +846,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
      }
    return NULL;
  }
@@ -1179,52 +870,194 @@ Index: gdb-7.99.90.20170420/gdb/build-id.c
 +			    show_build_id_verbose,
 +			    &setlist, &showlist);
 +
-+  observer_attach_executable_changed (debug_print_executable_changed);
++  observer_attach_executable_changed (debug_print_executable_changed);
++}
+diff --git a/gdb/build-id.h b/gdb/build-id.h
+index 0f13c7d4cf..2d105dba88 100644
+--- a/gdb/build-id.h
++++ b/gdb/build-id.h
+@@ -22,9 +22,10 @@
+ 
+ #include "gdb_bfd.h"
+ 
+-/* Locate NT_GNU_BUILD_ID from ABFD and return its content.  */
++/* Separate debuginfo files have corrupted PHDR but SHDR is correct there.
++   Locate NT_GNU_BUILD_ID from ABFD and return its content.  */
+ 
+-extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd);
++extern const struct bfd_build_id *build_id_bfd_shdr_get (bfd *abfd);
+ 
+ /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value.
+    Otherwise, issue a warning and return false.  */
+@@ -38,13 +39,19 @@ extern int build_id_verify (bfd *abfd,
+    the caller.  */
+ 
+ extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
+-					      const bfd_byte *build_id);
++					      const bfd_byte *build_id,
++					      char **link_return,
++					      int add_debug_suffix);
++
++extern char *build_id_to_filename (const struct bfd_build_id *build_id,
++				   char **link_return);
+ 
+ /* Find the separate debug file for OBJFILE, by using the build-id
+    associated with OBJFILE's BFD.  If successful, returns a malloc'd
+    file name for the separate debug file.  The caller must free this.
+    Otherwise, returns NULL.  */
+ 
+-extern char *find_separate_debug_file_by_buildid (struct objfile *objfile);
++extern char *find_separate_debug_file_by_buildid (struct objfile *objfile,
++		       gdb::unique_xmalloc_ptr<char> *build_id_filename_return);
+ 
+ #endif /* BUILD_ID_H */
+diff --git a/gdb/coffread.c b/gdb/coffread.c
+index fbbbb68f71..9698ec2191 100644
+--- a/gdb/coffread.c
++++ b/gdb/coffread.c
+@@ -735,7 +735,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+     {
+       char *debugfile;
+ 
+-      debugfile = find_separate_debug_file_by_buildid (objfile);
++      debugfile = find_separate_debug_file_by_buildid (objfile, NULL);
+ 
+       if (debugfile == NULL)
+ 	debugfile = find_separate_debug_file_by_debuglink (objfile);
+diff --git a/gdb/corelow.c b/gdb/corelow.c
+index 3a5256cb17..c5b642db81 100644
+--- a/gdb/corelow.c
++++ b/gdb/corelow.c
+@@ -45,6 +45,10 @@
+ #include "gdb_bfd.h"
+ #include "completer.h"
+ #include "filestuff.h"
++#include "auxv.h"
++#include "elf/common.h"
++#include "gdbcmd.h"
++#include "build-id.h"
+ 
+ #ifndef O_LARGEFILE
+ #define O_LARGEFILE 0
+@@ -264,6 +268,54 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
+     inferior_ptid = ptid;			/* Yes, make it current.  */
+ }
+ 
++static int build_id_core_loads = 1;
++
++static void
++build_id_locate_exec (int from_tty)
++{
++  CORE_ADDR at_entry;
++  struct bfd_build_id *build_id;
++  char *execfilename, *debug_filename;
++  char *build_id_filename;
++  struct cleanup *back_to;
++
++  if (exec_bfd != NULL || symfile_objfile != NULL)
++    return;
++
++  if (target_auxv_search (&current_target, AT_ENTRY, &at_entry) <= 0)
++    return;
++
++  build_id = build_id_addr_get (at_entry);
++  if (build_id == NULL)
++    return;
++  back_to = make_cleanup (xfree, build_id);
++
++  /* SYMFILE_OBJFILE should refer to the main executable (not only to its
++     separate debug info file).  gcc44+ keeps .eh_frame only in the main
++     executable without its duplicate .debug_frame in the separate debug info
++     file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer
++     directly to the separate debug info file.  */
++
++  execfilename = build_id_to_filename (build_id, &build_id_filename);
++  make_cleanup (xfree, build_id_filename);
++
++  if (execfilename != NULL)
++    {
++      make_cleanup (xfree, execfilename);
++      exec_file_attach (execfilename, from_tty);
++      symbol_file_add_main (execfilename,
++			    symfile_add_flag (!from_tty ? 0 : SYMFILE_VERBOSE));
++      if (symfile_objfile != NULL)
++        symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
++    }
++  else
++    debug_print_missing (_("the main executable file"), build_id_filename);
++
++  do_cleanups (back_to);
++
++  /* No automatic SOLIB_ADD as the libraries would get read twice.  */
 +}
-Index: gdb-7.99.90.20170420/gdb/build-id.h
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/build-id.h	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/build-id.h	2017-04-20 23:00:43.371629257 +0200
-@@ -22,9 +22,10 @@
- 
- #include "gdb_bfd.h"
++
+ /* This routine opens and sets up the core file bfd.  */
  
--/* Locate NT_GNU_BUILD_ID from ABFD and return its content.  */
-+/* Separate debuginfo files have corrupted PHDR but SHDR is correct there.
-+   Locate NT_GNU_BUILD_ID from ABFD and return its content.  */
+ static void
+@@ -391,6 +443,14 @@ core_open (const char *arg, int from_tty)
+ 	switch_to_thread (thread->ptid);
+     }
  
--extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd);
-+extern const struct bfd_build_id *build_id_bfd_shdr_get (bfd *abfd);
++  /* Find the build_id identifiers.  If it gets executed after
++     POST_CREATE_INFERIOR we would clash with asking to discard the already
++     loaded VDSO symbols.  If it gets executed before bfd_map_over_sections
++     INFERIOR_PTID is still not set and libthread_db initialization crashes on
++     PID == 0 in ps_pglobal_lookup.  */
++  if (build_id_core_loads != 0)
++    build_id_locate_exec (from_tty);
++
+   post_create_inferior (&core_ops, from_tty);
  
- /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value.
-    Otherwise, issue a warning and return false.  */
-@@ -38,13 +39,19 @@
-    the caller.  */
+   /* Now go through the target stack looking for threads since there
+@@ -1040,4 +1100,11 @@ _initialize_corelow (void)
+   init_core_ops ();
  
- extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
--					      const bfd_byte *build_id);
-+					      const bfd_byte *build_id,
-+					      char **link_return,
-+					      int add_debug_suffix);
+   add_target_with_completer (&core_ops, filename_completer);
 +
-+extern char *build_id_to_filename (const struct bfd_build_id *build_id,
-+				   char **link_return);
- 
- /* Find the separate debug file for OBJFILE, by using the build-id
-    associated with OBJFILE's BFD.  If successful, returns a malloc'd
-    file name for the separate debug file.  The caller must free this.
-    Otherwise, returns NULL.  */
++  add_setshow_boolean_cmd ("build-id-core-loads", class_files,
++			   &build_id_core_loads, _("\
++Set whether CORE-FILE loads the build-id associated files automatically."), _("\
++Show whether CORE-FILE loads the build-id associated files automatically."),
++			   NULL, NULL, NULL,
++			   &setlist, &showlist);
+ }
+diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
+index 8bdafb0ba4..2f2cbd3dea 100644
+--- a/gdb/doc/gdb.texinfo
++++ b/gdb/doc/gdb.texinfo
+@@ -19447,6 +19447,27 @@ information files.
  
--extern char *find_separate_debug_file_by_buildid (struct objfile *objfile);
-+extern char *find_separate_debug_file_by_buildid (struct objfile *objfile,
-+		       gdb::unique_xmalloc_ptr<char> *build_id_filename_return);
+ @end table
  
- #endif /* BUILD_ID_H */
-Index: gdb-7.99.90.20170420/gdb/dwarf2read.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/dwarf2read.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/dwarf2read.c	2017-04-20 23:00:43.375629279 +0200
-@@ -2671,7 +2671,7 @@
++You can also adjust the current verbosity of the @dfn{build id} locating.
++
++ at table @code
++
++ at kindex set build-id-verbose
++ at item set build-id-verbose 0
++No additional messages are printed.
++
++ at item set build-id-verbose 1
++Missing separate debug filenames are printed.
++
++ at item set build-id-verbose 2
++Missing separate debug filenames are printed and also all the parsing of the
++binaries to find their @dfn{build id} content is printed.
++
++ at kindex show build-id-verbose
++ at item show build-id-verbose
++Show the current verbosity value for the @dfn{build id} content locating.
++
++ at end table
++
+ @cindex @code{.gnu_debuglink} sections
+ @cindex debug link sections
+ A debug link is a special section of the executable file named
+diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
+index 98e7d842f0..c8db955f2f 100644
+--- a/gdb/dwarf2read.c
++++ b/gdb/dwarf2read.c
+@@ -2907,7 +2907,7 @@ dwarf2_get_dwz_file (void)
      }
  
    if (dwz_bfd == NULL)
@@ -1233,11 +1066,52 @@ Index: gdb-7.99.90.20170420/gdb/dwarf2read.c
  
    if (dwz_bfd == NULL)
      error (_("could not find '.gnu_debugaltlink' file for %s"),
-Index: gdb-7.99.90.20170420/gdb/python/py-objfile.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/python/py-objfile.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/python/py-objfile.c	2017-04-20 23:00:43.375629279 +0200
-@@ -137,7 +137,7 @@
+diff --git a/gdb/elfread.c b/gdb/elfread.c
+index 103b2144c3..fb32e03af5 100644
+--- a/gdb/elfread.c
++++ b/gdb/elfread.c
+@@ -1259,8 +1259,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+ 	   && objfile->separate_debug_objfile == NULL
+ 	   && objfile->separate_debug_objfile_backlink == NULL)
+     {
++      gdb::unique_xmalloc_ptr<char> build_id_filename;
+       gdb::unique_xmalloc_ptr<char> debugfile
+-	(find_separate_debug_file_by_buildid (objfile));
++	(find_separate_debug_file_by_buildid (objfile, &build_id_filename));
+ 
+       if (debugfile == NULL)
+ 	debugfile.reset (find_separate_debug_file_by_debuglink (objfile));
+@@ -1272,6 +1273,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+ 	  symbol_file_add_separate (abfd.get (), debugfile.get (),
+ 				    symfile_flags, objfile);
+ 	}
++      /* Check if any separate debug info has been extracted out.  */
++      else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink")
++	       != NULL)
++	debug_print_missing (objfile_name (objfile), build_id_filename.get ());
+     }
+ }
+ 
+diff --git a/gdb/objfiles.h b/gdb/objfiles.h
+index 28e66eca36..5ab0e33fb6 100644
+--- a/gdb/objfiles.h
++++ b/gdb/objfiles.h
+@@ -470,6 +470,10 @@ struct objfile
+   htab_t static_links {};
+ };
+ 
++/* This file was loaded according to the BUILD_ID_CORE_LOADS rules.  */
++
++#define OBJF_BUILD_ID_CORE_LOADED static_cast<enum objfile_flag>(1 << 12)
++
+ /* Declarations for functions defined in objfiles.c */
+ 
+ extern struct gdbarch *get_objfile_arch (const struct objfile *);
+diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
+index c2b40ff535..112cbf6560 100644
+--- a/gdb/python/py-objfile.c
++++ b/gdb/python/py-objfile.c
+@@ -137,7 +137,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
  
    TRY
      {
@@ -1246,7 +1120,7 @@ Index: gdb-7.99.90.20170420/gdb/python/py-objfile.c
      }
    CATCH (except, RETURN_MASK_ALL)
      {
-@@ -544,7 +544,7 @@
+@@ -544,7 +544,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
        /* Don't return separate debug files.  */
        if (objfile->separate_debug_objfile_backlink != NULL)
  	continue;
@@ -1255,16 +1129,181 @@ Index: gdb-7.99.90.20170420/gdb/python/py-objfile.c
        if (obfd_build_id == NULL)
  	continue;
        if (objfpy_build_id_matches (obfd_build_id, build_id))
-Index: gdb-7.99.90.20170420/gdb/coffread.c
-===================================================================
---- gdb-7.99.90.20170420.orig/gdb/coffread.c	2017-04-20 23:00:35.415584426 +0200
-+++ gdb-7.99.90.20170420/gdb/coffread.c	2017-04-20 23:00:43.376629285 +0200
-@@ -734,7 +734,7 @@
-     {
-       char *debugfile;
+diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
+index 4973cc2f25..a3399ad8f7 100644
+--- a/gdb/solib-svr4.c
++++ b/gdb/solib-svr4.c
+@@ -45,6 +45,7 @@
+ #include "auxv.h"
+ #include "gdb_bfd.h"
+ #include "probe.h"
++#include "build-id.h"
  
--      debugfile = find_separate_debug_file_by_buildid (objfile);
-+      debugfile = find_separate_debug_file_by_buildid (objfile, NULL);
+ static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
+ static int svr4_have_link_map_offsets (void);
+@@ -1385,9 +1386,52 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
+ 	  continue;
+ 	}
  
-       if (debugfile == NULL)
- 	debugfile = find_separate_debug_file_by_debuglink (objfile);
+-      strncpy (newobj->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
+-      newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
+-      strcpy (newobj->so_original_name, newobj->so_name);
++      {
++	struct bfd_build_id *build_id;
<Skipped 3068 lines>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gdb.git/commitdiff/4b0e5c1bdb8bb8711a8994ccd38895107a2fe662




More information about the pld-cvs-commit mailing list