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

7a6771
Index: gdb-7.11.50.20160630/gdb/event-top.c
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/event-top.c	2016-07-02 23:43:24.085214144 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/event-top.c	2016-07-03 14:37:12.572130734 +0200
7a6771
@@ -40,6 +40,7 @@
7a6771
 #include "buffer.h"
7a6771
 #include "ser-event.h"
7a6771
 #include "gdb_select.h"
7a6771
+#include "symfile.h"
7a6771
 
7a6771
 /* readline include files.  */
7a6771
 #include "readline/readline.h"
7a6771
@@ -347,6 +348,8 @@
7a6771
   /* Reset the nesting depth used when trace-commands is set.  */
7a6771
   reset_command_nest_depth ();
7a6771
 
7a6771
+  debug_flush_missing ();
7a6771
+
7a6771
   old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
7a6771
 
7a6771
   /* Do not call the python hook on an explicit prompt change as
7a6771
@@ -794,7 +797,10 @@
7a6771
       command_handler (cmd);
7a6771
 
7a6771
       if (ui->prompt_state != PROMPTED)
7a6771
-	display_gdb_prompt (0);
7a6771
+	{
7a6771
+	  debug_flush_missing ();
7a6771
+	  display_gdb_prompt (0);
7a6771
+	}
7a6771
     }
7a6771
 }
7a6771
 
7a6771
Index: gdb-7.11.50.20160630/gdb/symfile.h
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/symfile.h	2016-07-03 14:34:32.032753668 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/symfile.h	2016-07-03 14:37:12.573130742 +0200
7a6771
@@ -592,6 +592,8 @@
7a6771
 /* build-id support.  */
7a6771
 extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
7a6771
 extern void debug_print_missing (const char *binary, const char *debug);
7a6771
+extern void debug_flush_missing (void);
7a6771
+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
7a6771
 
7a6771
 /* From dwarf2read.c */
7a6771
 
7a6771
Index: gdb-7.11.50.20160630/gdb/aclocal.m4
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/aclocal.m4	2016-07-02 23:43:24.085214144 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/aclocal.m4	2016-07-03 14:37:12.576130768 +0200
7a6771
@@ -11,6 +11,221 @@
7a6771
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
7a6771
 # PARTICULAR PURPOSE.
7a6771
 
7a6771
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
7a6771
+# serial 1 (pkg-config-0.24)
7a6771
+# 
7a6771
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
7a6771
+#
7a6771
+# This program is free software; you can redistribute it and/or modify
7a6771
+# it under the terms of the GNU General Public License as published by
7a6771
+# the Free Software Foundation; either version 2 of the License, or
7a6771
+# (at your option) any later version.
7a6771
+#
7a6771
+# This program is distributed in the hope that it will be useful, but
7a6771
+# WITHOUT ANY WARRANTY; without even the implied warranty of
7a6771
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
7a6771
+# General Public License for more details.
7a6771
+#
7a6771
+# You should have received a copy of the GNU General Public License
7a6771
+# along with this program; if not, write to the Free Software
7a6771
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
7a6771
+#
7a6771
+# As a special exception to the GNU General Public License, if you
7a6771
+# distribute this file as part of a program that contains a
7a6771
+# configuration script generated by Autoconf, you may include it under
7a6771
+# the same distribution terms that you use for the rest of that program.
7a6771
+
7a6771
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
7a6771
+# ----------------------------------
7a6771
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
7a6771
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
7a6771
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
7a6771
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
7a6771
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
7a6771
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
7a6771
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
7a6771
+
7a6771
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
7a6771
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
7a6771
+fi
7a6771
+if test -n "$PKG_CONFIG"; then
7a6771
+	_pkg_min_version=m4_default([$1], [0.9.0])
7a6771
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
7a6771
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
7a6771
+		AC_MSG_RESULT([yes])
7a6771
+	else
7a6771
+		AC_MSG_RESULT([no])
7a6771
+		PKG_CONFIG=""
7a6771
+	fi
7a6771
+fi[]dnl
7a6771
+])# PKG_PROG_PKG_CONFIG
7a6771
+
7a6771
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
7a6771
+#
7a6771
+# Check to see whether a particular set of modules exists.  Similar
7a6771
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
7a6771
+#
7a6771
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
7a6771
+# only at the first occurence in configure.ac, so if the first place
7a6771
+# it's called might be skipped (such as if it is within an "if", you
7a6771
+# have to call PKG_CHECK_EXISTS manually
7a6771
+# --------------------------------------------------------------
7a6771
+AC_DEFUN([PKG_CHECK_EXISTS],
7a6771
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
7a6771
+if test -n "$PKG_CONFIG" && \
7a6771
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
7a6771
+  m4_default([$2], [:])
7a6771
+m4_ifvaln([$3], [else
7a6771
+  $3])dnl
7a6771
+fi])
7a6771
+
7a6771
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
7a6771
+# ---------------------------------------------
7a6771
+m4_define([_PKG_CONFIG],
7a6771
+[if test -n "$$1"; then
7a6771
+    pkg_cv_[]$1="$$1"
7a6771
+ elif test -n "$PKG_CONFIG"; then
7a6771
+    PKG_CHECK_EXISTS([$3],
7a6771
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
7a6771
+		      test "x$?" != "x0" && pkg_failed=yes ],
7a6771
+		     [pkg_failed=yes])
7a6771
+ else
7a6771
+    pkg_failed=untried
7a6771
+fi[]dnl
7a6771
+])# _PKG_CONFIG
7a6771
+
7a6771
+# _PKG_SHORT_ERRORS_SUPPORTED
7a6771
+# -----------------------------
7a6771
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
7a6771
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
7a6771
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
7a6771
+        _pkg_short_errors_supported=yes
7a6771
+else
7a6771
+        _pkg_short_errors_supported=no
7a6771
+fi[]dnl
7a6771
+])# _PKG_SHORT_ERRORS_SUPPORTED
7a6771
+
7a6771
+
7a6771
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
7a6771
+# [ACTION-IF-NOT-FOUND])
7a6771
+#
7a6771
+#
7a6771
+# Note that if there is a possibility the first call to
7a6771
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
7a6771
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
7a6771
+#
7a6771
+#
7a6771
+# --------------------------------------------------------------
7a6771
+AC_DEFUN([PKG_CHECK_MODULES],
7a6771
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
7a6771
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
7a6771
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
7a6771
+
7a6771
+pkg_failed=no
7a6771
+AC_MSG_CHECKING([for $1])
7a6771
+
7a6771
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
7a6771
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
7a6771
+
7a6771
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
7a6771
+and $1[]_LIBS to avoid the need to call pkg-config.
7a6771
+See the pkg-config man page for more details.])
7a6771
+
7a6771
+if test $pkg_failed = yes; then
7a6771
+   	AC_MSG_RESULT([no])
7a6771
+        _PKG_SHORT_ERRORS_SUPPORTED
7a6771
+        if test $_pkg_short_errors_supported = yes; then
7a6771
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
7a6771
+        else 
7a6771
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
7a6771
+        fi
7a6771
+	# Put the nasty error message in config.log where it belongs
7a6771
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
7a6771
+
7a6771
+	m4_default([$4], [AC_MSG_ERROR(
7a6771
+[Package requirements ($2) were not met:
7a6771
+
7a6771
+$$1_PKG_ERRORS
7a6771
+
7a6771
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
7a6771
+installed software in a non-standard prefix.
7a6771
+
7a6771
+_PKG_TEXT])[]dnl
7a6771
+        ])
7a6771
+elif test $pkg_failed = untried; then
7a6771
+     	AC_MSG_RESULT([no])
7a6771
+	m4_default([$4], [AC_MSG_FAILURE(
7a6771
+[The pkg-config script could not be found or is too old.  Make sure it
7a6771
+is in your PATH or set the PKG_CONFIG environment variable to the full
7a6771
+path to pkg-config.
7a6771
+
7a6771
+_PKG_TEXT
7a6771
+
7a6771
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
7a6771
+        ])
7a6771
+else
7a6771
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
7a6771
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
7a6771
+        AC_MSG_RESULT([yes])
7a6771
+	$3
7a6771
+fi[]dnl
7a6771
+])# PKG_CHECK_MODULES
7a6771
+
7a6771
+
7a6771
+# PKG_INSTALLDIR(DIRECTORY)
7a6771
+# -------------------------
7a6771
+# Substitutes the variable pkgconfigdir as the location where a module
7a6771
+# should install pkg-config .pc files. By default the directory is
7a6771
+# $libdir/pkgconfig, but the default can be changed by passing
7a6771
+# DIRECTORY. The user can override through the --with-pkgconfigdir
7a6771
+# parameter.
7a6771
+AC_DEFUN([PKG_INSTALLDIR],
7a6771
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
7a6771
+m4_pushdef([pkg_description],
7a6771
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
7a6771
+AC_ARG_WITH([pkgconfigdir],
7a6771
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
7a6771
+    [with_pkgconfigdir=]pkg_default)
7a6771
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
7a6771
+m4_popdef([pkg_default])
7a6771
+m4_popdef([pkg_description])
7a6771
+]) dnl PKG_INSTALLDIR
7a6771
+
7a6771
+
7a6771
+# PKG_NOARCH_INSTALLDIR(DIRECTORY)
7a6771
+# -------------------------
7a6771
+# Substitutes the variable noarch_pkgconfigdir as the location where a
7a6771
+# module should install arch-independent pkg-config .pc files. By
7a6771
+# default the directory is $datadir/pkgconfig, but the default can be
7a6771
+# changed by passing DIRECTORY. The user can override through the
7a6771
+# --with-noarch-pkgconfigdir parameter.
7a6771
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
7a6771
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
7a6771
+m4_pushdef([pkg_description],
7a6771
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
7a6771
+AC_ARG_WITH([noarch-pkgconfigdir],
7a6771
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
7a6771
+    [with_noarch_pkgconfigdir=]pkg_default)
7a6771
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
7a6771
+m4_popdef([pkg_default])
7a6771
+m4_popdef([pkg_description])
7a6771
+]) dnl PKG_NOARCH_INSTALLDIR
7a6771
+
7a6771
+
7a6771
+# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
7a6771
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
7a6771
+# -------------------------------------------
7a6771
+# Retrieves the value of the pkg-config variable for the given module.
7a6771
+AC_DEFUN([PKG_CHECK_VAR],
7a6771
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
7a6771
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
7a6771
+
7a6771
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
7a6771
+AS_VAR_COPY([$1], [pkg_cv_][$1])
7a6771
+
7a6771
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
7a6771
+])# PKG_CHECK_VAR
7a6771
+
7a6771
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
7a6771
 
7a6771
 # Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
7a6771
Index: gdb-7.11.50.20160630/gdb/config.in
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/config.in	2016-07-02 23:43:24.085214144 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/config.in	2016-07-03 14:37:12.576130768 +0200
7a6771
@@ -33,6 +33,9 @@
7a6771
 /* Define to BFD's default target vector. */
7a6771
 #undef DEFAULT_BFD_VEC
7a6771
 
7a6771
+/* librpm version specific library name to dlopen. */
7a6771
+#undef DLOPEN_LIBRPM
7a6771
+
7a6771
 /* Define to 1 if translation of program messages to the user's native
7a6771
    language is requested. */
7a6771
 #undef ENABLE_NLS
7a6771
@@ -261,6 +264,9 @@
7a6771
 /* Define if Python 2.7 is being used. */
7a6771
 #undef HAVE_LIBPYTHON2_7
7a6771
 
7a6771
+/* Define if librpm library is being used. */
7a6771
+#undef HAVE_LIBRPM
7a6771
+
7a6771
 /* Define to 1 if you have the <libunwind-ia64.h> header file. */
7a6771
 #undef HAVE_LIBUNWIND_IA64_H
7a6771
 
7a6771
Index: gdb-7.11.50.20160630/gdb/configure
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/configure	2016-07-02 23:43:24.085214144 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/configure	2016-07-03 14:37:12.581130811 +0200
7a6771
@@ -705,6 +705,11 @@
7a6771
 HAVE_NATIVE_GCORE_TARGET
7a6771
 TARGET_OBS
7a6771
 subdirs
7a6771
+RPM_LIBS
7a6771
+RPM_CFLAGS
7a6771
+PKG_CONFIG_LIBDIR
7a6771
+PKG_CONFIG_PATH
7a6771
+PKG_CONFIG
7a6771
 GDB_DATADIR
7a6771
 DEBUGDIR
7a6771
 MAKEINFO_EXTRA_FLAGS
7a6771
@@ -814,6 +819,7 @@
7a6771
 with_relocated_sources
7a6771
 with_auto_load_dir
7a6771
 with_auto_load_safe_path
7a6771
+with_rpm
7a6771
 enable_targets
7a6771
 enable_64_bit_bfd
7a6771
 enable_gdbcli
7a6771
@@ -870,6 +876,11 @@
7a6771
 CPP
7a6771
 MAKEINFO
7a6771
 MAKEINFOFLAGS
7a6771
+PKG_CONFIG
7a6771
+PKG_CONFIG_PATH
7a6771
+PKG_CONFIG_LIBDIR
7a6771
+RPM_CFLAGS
7a6771
+RPM_LIBS
7a6771
 YACC
7a6771
 YFLAGS
7a6771
 XMKMF'
7a6771
@@ -1541,6 +1552,8 @@
7a6771
                           [--with-auto-load-dir]
7a6771
   --without-auto-load-safe-path
7a6771
                           do not restrict auto-loaded files locations
7a6771
+  --with-rpm              query rpm database for missing debuginfos (yes/no,
7a6771
+                          def. auto=librpm.so)
7a6771
   --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
7a6771
   --with-curses           use the curses library instead of the termcap
7a6771
                           library
7a6771
@@ -1595,6 +1608,13 @@
7a6771
   MAKEINFO    Parent configure detects if it is of sufficient version.
7a6771
   MAKEINFOFLAGS
7a6771
               Parameters for MAKEINFO.
7a6771
+  PKG_CONFIG  path to pkg-config utility
7a6771
+  PKG_CONFIG_PATH
7a6771
+              directories to add to pkg-config's search path
7a6771
+  PKG_CONFIG_LIBDIR
7a6771
+              path overriding pkg-config's built-in search path
7a6771
+  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
7a6771
+  RPM_LIBS    linker flags for RPM, overriding pkg-config
7a6771
   YACC        The `Yet Another C Compiler' implementation to use. Defaults to
7a6771
               the first program found out of: `bison -y', `byacc', `yacc'.
7a6771
   YFLAGS      The list of arguments that will be passed by default to $YACC.
7a6771
@@ -5613,6 +5633,494 @@
7a6771
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
7a6771
 $as_echo "$with_auto_load_safe_path" >&6; }
7a6771
 
7a6771
+# Integration with rpm library to support missing debuginfo suggestions.
7a6771
+# --without-rpm: Disable any rpm support.
7a6771
+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
7a6771
+#   Even with runtime missing `libname.so' GDB will still other run correctly.
7a6771
+#   Missing `libname.so' during ./configure will abort the configuration.
7a6771
+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
7a6771
+#   minor version first such as `librpm-4.6.so' as minor version differences
7a6771
+#   mean API+ABI incompatibility.  If the specific match versioned library name
7a6771
+#   could not be found still open dynamically at least `librpm.so'.
7a6771
+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
7a6771
+#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
7a6771
+#   be probably linked with the version specific library (as `librpm-4.6.so').
7a6771
+#   Failure to find librpm by pkg-config will abort the configuration.
7a6771
+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
7a6771
+#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
7a6771
+
7a6771
+
7a6771
+# Check whether --with-rpm was given.
7a6771
+if test "${with_rpm+set}" = set; then :
7a6771
+  withval=$with_rpm;
7a6771
+else
7a6771
+  with_rpm="auto"
7a6771
+fi
7a6771
+
7a6771
+
7a6771
+
7a6771
+
7a6771
+if test "x$with_rpm" != "xno"; then
7a6771
+  if test "x$with_rpm" = "xyes"; then
7a6771
+    LIBRPM="librpm.so"
7a6771
+    RPM_REQUIRE=true
7a6771
+    DLOPEN_REQUIRE=false
7a6771
+  elif test "x$with_rpm" = "xauto"; then
7a6771
+    LIBRPM="librpm.so"
7a6771
+    RPM_REQUIRE=false
7a6771
+    DLOPEN_REQUIRE=false
7a6771
+  else
7a6771
+    LIBRPM="$with_rpm"
7a6771
+    RPM_REQUIRE=true
7a6771
+    DLOPEN_REQUIRE=true
7a6771
+  fi
7a6771
+  LIBRPM_STRING='"'"$LIBRPM"'"'
7a6771
+
7a6771
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
7a6771
+$as_echo_n "checking specific librpm version... " >&6; }
7a6771
+  HAVE_DLOPEN_LIBRPM=false
7a6771
+  save_LIBS="$LIBS"
7a6771
+  LIBS="$LIBS -ldl"
7a6771
+  if test "$cross_compiling" = yes; then :
7a6771
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
7a6771
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
7a6771
+as_fn_error "cannot run test program while cross compiling
7a6771
+See \`config.log' for more details." "$LINENO" 5; }
7a6771
+else
7a6771
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7a6771
+/* end confdefs.h.  */
7a6771
+
7a6771
+#include <rpm/rpmlib.h>
7a6771
+#include <dlfcn.h>
7a6771
+#include <errno.h>
7a6771
+
7a6771
+int
7a6771
+main ()
7a6771
+{
7a6771
+
7a6771
+    void *h;
7a6771
+    const char *const *rpmverp;
7a6771
+    FILE *f;
7a6771
+
7a6771
+    f = fopen ("conftest.out", "w");
7a6771
+    if (!f)
7a6771
+      {
7a6771
+	fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
7a6771
+		 strerror (errno));
7a6771
+	return 1;
7a6771
+      }
7a6771
+    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
7a6771
+    if (!h)
7a6771
+      {
7a6771
+	fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
7a6771
+	return 1;
7a6771
+      }
7a6771
+    rpmverp = dlsym (h, "RPMVERSION");
7a6771
+    if (!rpmverp)
7a6771
+      {
7a6771
+	fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
7a6771
+	return 1;
7a6771
+      }
7a6771
+    fprintf (stderr, "RPMVERSION is: \"");
7a6771
+    fprintf (stderr, "%s\"\n", *rpmverp);
7a6771
+
7a6771
+    /* Try to find the specific librpm version only for "librpm.so" as we do
7a6771
+       not know how to assemble the version string otherwise.  */
7a6771
+
7a6771
+    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
7a6771
+      {
7a6771
+	fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	return 0;
7a6771
+      }
7a6771
+    else
7a6771
+      {
7a6771
+	char *h2_name;
7a6771
+	void *h2;
7a6771
+	int major, minor;
7a6771
+
7a6771
+	if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
7a6771
+	  {
7a6771
+	    fprintf (stderr, "Unable to parse RPMVERSION.\n");
7a6771
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+	/* Avoid the square brackets by malloc.  */
7a6771
+	h2_name = malloc (64);
7a6771
+	sprintf (h2_name, "librpm-%d.%d.so", major, minor);
7a6771
+	h2 = dlopen (h2_name, RTLD_LAZY);
7a6771
+	if (!h2)
7a6771
+	  {
7a6771
+	    fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
7a6771
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+	if (h2 != h)
7a6771
+	  {
7a6771
+	    fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
7a6771
+		     $LIBRPM_STRING, h2_name);
7a6771
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+	/* Found the valid .so name with a specific version.  */
7a6771
+	fprintf (f, "%s\n", h2_name);
7a6771
+	return 0;
7a6771
+      }
7a6771
+
7a6771
+  ;
7a6771
+  return 0;
7a6771
+}
7a6771
+_ACEOF
7a6771
+if ac_fn_c_try_run "$LINENO"; then :
7a6771
+
7a6771
+    DLOPEN_LIBRPM="`cat conftest.out`"
7a6771
+    if test "x$DLOPEN_LIBRPM" != "x"; then
7a6771
+      HAVE_DLOPEN_LIBRPM=true
7a6771
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
7a6771
+$as_echo "$DLOPEN_LIBRPM" >&6; }
7a6771
+    fi
7a6771
+
7a6771
+fi
7a6771
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
7a6771
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
7a6771
+fi
7a6771
+
7a6771
+  rm -f conftest.out
7a6771
+
7a6771
+
7a6771
+
7a6771
+  if $HAVE_DLOPEN_LIBRPM; then
7a6771
+
7a6771
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
7a6771
+$as_echo_n "checking rpm library API compatibility... " >&6; }
7a6771
+    # The compilation requires -Werror to verify anything.
7a6771
+    save_CFLAGS="$CFLAGS"
7a6771
+    CFLAGS="$CFLAGS -Werror"
7a6771
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7a6771
+/* end confdefs.h.  */
7a6771
+
7a6771
+/* Duplicate here the declarations to verify they match "elfread.c".  */
7a6771
+#include <rpm/rpmlib.h>
7a6771
+#include <rpm/rpmts.h>
7a6771
+#include <rpm/rpmdb.h>
7a6771
+#include <rpm/header.h>
7a6771
+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
7a6771
+extern int rpmReadConfigFiles(const char * file, const char * target);
7a6771
+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
7a6771
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
7a6771
+extern rpmts rpmtsCreate(void);
7a6771
+extern rpmts rpmtsFree(rpmts ts);
7a6771
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
7a6771
+					    const void * keyp, size_t keylen);
7a6771
+
7a6771
+int
7a6771
+main ()
7a6771
+{
7a6771
+
7a6771
+  ;
7a6771
+  return 0;
7a6771
+}
7a6771
+_ACEOF
7a6771
+if ac_fn_c_try_compile "$LINENO"; then :
7a6771
+
7a6771
+      LIBRPM_COMPAT=true
7a6771
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7a6771
+$as_echo "yes" >&6; }
7a6771
+
7a6771
+else
7a6771
+
7a6771
+      LIBRPM_COMPAT=false
7a6771
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+
7a6771
+fi
7a6771
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7a6771
+    CFLAGS="$save_CFLAGS"
7a6771
+
7a6771
+    if ! $LIBRPM_COMPAT; then
7a6771
+      HAVE_DLOPEN_LIBRPM=false
7a6771
+    fi
7a6771
+  fi
7a6771
+
7a6771
+  if $HAVE_DLOPEN_LIBRPM; then
7a6771
+    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
7a6771
+
7a6771
+cat >>confdefs.h <<_ACEOF
7a6771
+#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
7a6771
+_ACEOF
7a6771
+
7a6771
+
7a6771
+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
7a6771
+
7a6771
+  else
7a6771
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+    LIBS="$save_LIBS"
7a6771
+    if $DLOPEN_REQUIRE; then
7a6771
+      as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
7a6771
+    fi
7a6771
+
7a6771
+
7a6771
+
7a6771
+
7a6771
+
7a6771
+
7a6771
+
7a6771
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
7a6771
+	if test -n "$ac_tool_prefix"; then
7a6771
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
7a6771
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
7a6771
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
7a6771
+$as_echo_n "checking for $ac_word... " >&6; }
7a6771
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
7a6771
+  $as_echo_n "(cached) " >&6
7a6771
+else
7a6771
+  case $PKG_CONFIG in
7a6771
+  [\\/]* | ?:[\\/]*)
7a6771
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
7a6771
+  ;;
7a6771
+  *)
7a6771
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7a6771
+for as_dir in $PATH
7a6771
+do
7a6771
+  IFS=$as_save_IFS
7a6771
+  test -z "$as_dir" && as_dir=.
7a6771
+    for ac_exec_ext in '' $ac_executable_extensions; do
7a6771
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
7a6771
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
7a6771
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
7a6771
+    break 2
7a6771
+  fi
7a6771
+done
7a6771
+  done
7a6771
+IFS=$as_save_IFS
7a6771
+
7a6771
+  ;;
7a6771
+esac
7a6771
+fi
7a6771
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
7a6771
+if test -n "$PKG_CONFIG"; then
7a6771
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
7a6771
+$as_echo "$PKG_CONFIG" >&6; }
7a6771
+else
7a6771
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+fi
7a6771
+
7a6771
+
7a6771
+fi
7a6771
+if test -z "$ac_cv_path_PKG_CONFIG"; then
7a6771
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
7a6771
+  # Extract the first word of "pkg-config", so it can be a program name with args.
7a6771
+set dummy pkg-config; ac_word=$2
7a6771
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
7a6771
+$as_echo_n "checking for $ac_word... " >&6; }
7a6771
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
7a6771
+  $as_echo_n "(cached) " >&6
7a6771
+else
7a6771
+  case $ac_pt_PKG_CONFIG in
7a6771
+  [\\/]* | ?:[\\/]*)
7a6771
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
7a6771
+  ;;
7a6771
+  *)
7a6771
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7a6771
+for as_dir in $PATH
7a6771
+do
7a6771
+  IFS=$as_save_IFS
7a6771
+  test -z "$as_dir" && as_dir=.
7a6771
+    for ac_exec_ext in '' $ac_executable_extensions; do
7a6771
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
7a6771
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
7a6771
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
7a6771
+    break 2
7a6771
+  fi
7a6771
+done
7a6771
+  done
7a6771
+IFS=$as_save_IFS
7a6771
+
7a6771
+  ;;
7a6771
+esac
7a6771
+fi
7a6771
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
7a6771
+if test -n "$ac_pt_PKG_CONFIG"; then
7a6771
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
7a6771
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
7a6771
+else
7a6771
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+fi
7a6771
+
7a6771
+  if test "x$ac_pt_PKG_CONFIG" = x; then
7a6771
+    PKG_CONFIG=""
7a6771
+  else
7a6771
+    case $cross_compiling:$ac_tool_warned in
7a6771
+yes:)
7a6771
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
7a6771
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
7a6771
+ac_tool_warned=yes ;;
7a6771
+esac
7a6771
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
7a6771
+  fi
7a6771
+else
7a6771
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
7a6771
+fi
7a6771
+
7a6771
+fi
7a6771
+if test -n "$PKG_CONFIG"; then
7a6771
+	_pkg_min_version=0.9.0
7a6771
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
7a6771
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
7a6771
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
7a6771
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7a6771
+$as_echo "yes" >&6; }
7a6771
+	else
7a6771
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+		PKG_CONFIG=""
7a6771
+	fi
7a6771
+fi
7a6771
+
7a6771
+pkg_failed=no
7a6771
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
7a6771
+$as_echo_n "checking for RPM... " >&6; }
7a6771
+
7a6771
+if test -n "$RPM_CFLAGS"; then
7a6771
+    pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
7a6771
+ elif test -n "$PKG_CONFIG"; then
7a6771
+    if test -n "$PKG_CONFIG" && \
7a6771
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
7a6771
+  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
7a6771
+  ac_status=$?
7a6771
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
7a6771
+  test $ac_status = 0; }; then
7a6771
+  pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
7a6771
+		      test "x$?" != "x0" && pkg_failed=yes
7a6771
+else
7a6771
+  pkg_failed=yes
7a6771
+fi
7a6771
+ else
7a6771
+    pkg_failed=untried
7a6771
+fi
7a6771
+if test -n "$RPM_LIBS"; then
7a6771
+    pkg_cv_RPM_LIBS="$RPM_LIBS"
7a6771
+ elif test -n "$PKG_CONFIG"; then
7a6771
+    if test -n "$PKG_CONFIG" && \
7a6771
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
7a6771
+  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
7a6771
+  ac_status=$?
7a6771
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
7a6771
+  test $ac_status = 0; }; then
7a6771
+  pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
7a6771
+		      test "x$?" != "x0" && pkg_failed=yes
7a6771
+else
7a6771
+  pkg_failed=yes
7a6771
+fi
7a6771
+ else
7a6771
+    pkg_failed=untried
7a6771
+fi
7a6771
+
7a6771
+
7a6771
+
7a6771
+if test $pkg_failed = yes; then
7a6771
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+
7a6771
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
7a6771
+        _pkg_short_errors_supported=yes
7a6771
+else
7a6771
+        _pkg_short_errors_supported=no
7a6771
+fi
7a6771
+        if test $_pkg_short_errors_supported = yes; then
7a6771
+	        RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
7a6771
+        else
7a6771
+	        RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
7a6771
+        fi
7a6771
+	# Put the nasty error message in config.log where it belongs
7a6771
+	echo "$RPM_PKG_ERRORS" >&5
7a6771
+
7a6771
+	HAVE_LIBRPM=false
7a6771
+elif test $pkg_failed = untried; then
7a6771
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+	HAVE_LIBRPM=false
7a6771
+else
7a6771
+	RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
7a6771
+	RPM_LIBS=$pkg_cv_RPM_LIBS
7a6771
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7a6771
+$as_echo "yes" >&6; }
7a6771
+	HAVE_LIBRPM=true
7a6771
+fi
7a6771
+
7a6771
+    if $HAVE_LIBRPM; then
7a6771
+
7a6771
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
7a6771
+$as_echo_n "checking rpm library API compatibility... " >&6; }
7a6771
+    # The compilation requires -Werror to verify anything.
7a6771
+    save_CFLAGS="$CFLAGS"
7a6771
+    CFLAGS="$CFLAGS -Werror"
7a6771
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7a6771
+/* end confdefs.h.  */
7a6771
+
7a6771
+/* Duplicate here the declarations to verify they match "elfread.c".  */
7a6771
+#include <rpm/rpmlib.h>
7a6771
+#include <rpm/rpmts.h>
7a6771
+#include <rpm/rpmdb.h>
7a6771
+#include <rpm/header.h>
7a6771
+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
7a6771
+extern int rpmReadConfigFiles(const char * file, const char * target);
7a6771
+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
7a6771
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
7a6771
+extern rpmts rpmtsCreate(void);
7a6771
+extern rpmts rpmtsFree(rpmts ts);
7a6771
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
7a6771
+					    const void * keyp, size_t keylen);
7a6771
+
7a6771
+int
7a6771
+main ()
7a6771
+{
7a6771
+
7a6771
+  ;
7a6771
+  return 0;
7a6771
+}
7a6771
+_ACEOF
7a6771
+if ac_fn_c_try_compile "$LINENO"; then :
7a6771
+
7a6771
+      LIBRPM_COMPAT=true
7a6771
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7a6771
+$as_echo "yes" >&6; }
7a6771
+
7a6771
+else
7a6771
+
7a6771
+      LIBRPM_COMPAT=false
7a6771
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7a6771
+$as_echo "no" >&6; }
7a6771
+
7a6771
+fi
7a6771
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7a6771
+    CFLAGS="$save_CFLAGS"
7a6771
+
7a6771
+      if ! $LIBRPM_COMPAT; then
7a6771
+	HAVE_LIBRPM=false
7a6771
+	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
7a6771
+      fi
7a6771
+    fi
7a6771
+
7a6771
+    if $HAVE_LIBRPM; then
7a6771
+
7a6771
+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
7a6771
+
7a6771
+      CFLAGS="$CFLAGS $RPM_CFLAGS"
7a6771
+      LIBS="$LIBS $RPM_LIBS"
7a6771
+    else
7a6771
+      if $RPM_REQUIRE; then
7a6771
+	as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
7a6771
+      else
7a6771
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
7a6771
+$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
7a6771
+      fi
7a6771
+    fi
7a6771
+  fi
7a6771
+fi
7a6771
+
7a6771
 
7a6771
 
7a6771
 subdirs="$subdirs testsuite"
7a6771
Index: gdb-7.11.50.20160630/gdb/configure.ac
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/configure.ac	2016-07-02 23:43:24.085214144 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/configure.ac	2016-07-03 14:37:12.582130819 +0200
7a6771
@@ -177,6 +177,199 @@
7a6771
 	      [Directories safe to hold auto-loaded files.])
7a6771
 AC_MSG_RESULT([$with_auto_load_safe_path])
7a6771
 
7a6771
+# Integration with rpm library to support missing debuginfo suggestions.
7a6771
+# --without-rpm: Disable any rpm support.
7a6771
+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
7a6771
+#   Even with runtime missing `libname.so' GDB will still other run correctly.
7a6771
+#   Missing `libname.so' during ./configure will abort the configuration.
7a6771
+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
7a6771
+#   minor version first such as `librpm-4.6.so' as minor version differences
7a6771
+#   mean API+ABI incompatibility.  If the specific match versioned library name
7a6771
+#   could not be found still open dynamically at least `librpm.so'.
7a6771
+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
7a6771
+#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
7a6771
+#   be probably linked with the version specific library (as `librpm-4.6.so').
7a6771
+#   Failure to find librpm by pkg-config will abort the configuration.
7a6771
+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
7a6771
+#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
7a6771
+
7a6771
+AC_ARG_WITH([rpm],
7a6771
+  [AS_HELP_STRING([--with-rpm],
7a6771
+                  [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
7a6771
+
7a6771
+m4_pattern_allow([^AC_MSG_ERROR$])
7a6771
+m4_pattern_allow([^AC_MSG_WARN$])
7a6771
+if test "x$with_rpm" != "xno"; then
7a6771
+  if test "x$with_rpm" = "xyes"; then
7a6771
+    LIBRPM="librpm.so"
7a6771
+    RPM_REQUIRE=true
7a6771
+    DLOPEN_REQUIRE=false
7a6771
+  elif test "x$with_rpm" = "xauto"; then
7a6771
+    LIBRPM="librpm.so"
7a6771
+    RPM_REQUIRE=false
7a6771
+    DLOPEN_REQUIRE=false
7a6771
+  else
7a6771
+    LIBRPM="$with_rpm"
7a6771
+    RPM_REQUIRE=true
7a6771
+    DLOPEN_REQUIRE=true
7a6771
+  fi
7a6771
+  LIBRPM_STRING='"'"$LIBRPM"'"'
7a6771
+
7a6771
+  AC_MSG_CHECKING([specific librpm version])
7a6771
+  HAVE_DLOPEN_LIBRPM=false
7a6771
+  save_LIBS="$LIBS"
7a6771
+  LIBS="$LIBS -ldl"
7a6771
+  AC_RUN_IFELSE(AC_LANG_PROGRAM([[
7a6771
+#include <rpm/rpmlib.h>
7a6771
+#include <dlfcn.h>
7a6771
+#include <errno.h>
7a6771
+  ]], [[
7a6771
+    void *h;
7a6771
+    const char *const *rpmverp;
7a6771
+    FILE *f;
7a6771
+
7a6771
+    f = fopen ("conftest.out", "w");
7a6771
+    if (!f)
7a6771
+      {
7a6771
+	fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
7a6771
+		 strerror (errno));
7a6771
+	return 1;
7a6771
+      }
7a6771
+    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
7a6771
+    if (!h)
7a6771
+      {
7a6771
+	fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
7a6771
+	return 1;
7a6771
+      }
7a6771
+    rpmverp = dlsym (h, "RPMVERSION");
7a6771
+    if (!rpmverp)
7a6771
+      {
7a6771
+	fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
7a6771
+	return 1;
7a6771
+      }
7a6771
+    fprintf (stderr, "RPMVERSION is: \"");
7a6771
+    fprintf (stderr, "%s\"\n", *rpmverp);
7a6771
+
7a6771
+    /* Try to find the specific librpm version only for "librpm.so" as we do
7a6771
+       not know how to assemble the version string otherwise.  */
7a6771
+
7a6771
+    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
7a6771
+      {
7a6771
+	fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	return 0;
7a6771
+      }
7a6771
+    else
7a6771
+      {
7a6771
+	char *h2_name;
7a6771
+	void *h2;
7a6771
+	int major, minor;
7a6771
+
7a6771
+	if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
7a6771
+	  {
7a6771
+	    fprintf (stderr, "Unable to parse RPMVERSION.\n");
7a6771
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+	/* Avoid the square brackets by malloc.  */
7a6771
+	h2_name = malloc (64);
7a6771
+	sprintf (h2_name, "librpm-%d.%d.so", major, minor);
7a6771
+	h2 = dlopen (h2_name, RTLD_LAZY);
7a6771
+	if (!h2)
7a6771
+	  {
7a6771
+	    fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
7a6771
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+	if (h2 != h)
7a6771
+	  {
7a6771
+	    fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
7a6771
+		     $LIBRPM_STRING, h2_name);
7a6771
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+	/* Found the valid .so name with a specific version.  */
7a6771
+	fprintf (f, "%s\n", h2_name);
7a6771
+	return 0;
7a6771
+      }
7a6771
+  ]]), [
7a6771
+    DLOPEN_LIBRPM="`cat conftest.out`"
7a6771
+    if test "x$DLOPEN_LIBRPM" != "x"; then
7a6771
+      HAVE_DLOPEN_LIBRPM=true
7a6771
+      AC_MSG_RESULT($DLOPEN_LIBRPM)
7a6771
+    fi
7a6771
+  ])
7a6771
+  rm -f conftest.out
7a6771
+
7a6771
+  m4_define([CHECK_LIBRPM_COMPAT], [
7a6771
+    AC_MSG_CHECKING([rpm library API compatibility])
7a6771
+    # The compilation requires -Werror to verify anything.
7a6771
+    save_CFLAGS="$CFLAGS"
7a6771
+    CFLAGS="$CFLAGS -Werror"
7a6771
+    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
7a6771
+/* Duplicate here the declarations to verify they match "elfread.c".  */
7a6771
+#include <rpm/rpmlib.h>
7a6771
+#include <rpm/rpmts.h>
7a6771
+#include <rpm/rpmdb.h>
7a6771
+#include <rpm/header.h>
7a6771
+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
7a6771
+extern int rpmReadConfigFiles(const char * file, const char * target);
7a6771
+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
7a6771
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
7a6771
+extern rpmts rpmtsCreate(void);
7a6771
+extern rpmts rpmtsFree(rpmts ts);
7a6771
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
7a6771
+					    const void * keyp, size_t keylen);
7a6771
+    ]]), [
7a6771
+      LIBRPM_COMPAT=true
7a6771
+      AC_MSG_RESULT(yes)
7a6771
+    ], [
7a6771
+      LIBRPM_COMPAT=false
7a6771
+      AC_MSG_RESULT(no)
7a6771
+    ])
7a6771
+    CFLAGS="$save_CFLAGS"
7a6771
+  ])
7a6771
+
7a6771
+  if $HAVE_DLOPEN_LIBRPM; then
7a6771
+    CHECK_LIBRPM_COMPAT
7a6771
+    if ! $LIBRPM_COMPAT; then
7a6771
+      HAVE_DLOPEN_LIBRPM=false
7a6771
+    fi
7a6771
+  fi
7a6771
+
7a6771
+  if $HAVE_DLOPEN_LIBRPM; then
7a6771
+    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
7a6771
+    AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
7a6771
+    AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
7a6771
+  else
7a6771
+    AC_MSG_RESULT(no)
7a6771
+    LIBS="$save_LIBS"
7a6771
+    if $DLOPEN_REQUIRE; then
7a6771
+      AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
7a6771
+    fi
7a6771
+    PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
7a6771
+
7a6771
+    if $HAVE_LIBRPM; then
7a6771
+      CHECK_LIBRPM_COMPAT
7a6771
+      if ! $LIBRPM_COMPAT; then
7a6771
+	HAVE_LIBRPM=false
7a6771
+	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
7a6771
+      fi
7a6771
+    fi
7a6771
+
7a6771
+    if $HAVE_LIBRPM; then
7a6771
+      AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
7a6771
+      CFLAGS="$CFLAGS $RPM_CFLAGS"
7a6771
+      LIBS="$LIBS $RPM_LIBS"
7a6771
+    else
7a6771
+      if $RPM_REQUIRE; then
7a6771
+	AC_MSG_ERROR($RPM_PKG_ERRORS)
7a6771
+      else
7a6771
+	AC_MSG_WARN($RPM_PKG_ERRORS)
7a6771
+      fi
7a6771
+    fi
7a6771
+  fi
7a6771
+fi
7a6771
+ 
7a6771
 AC_CONFIG_SUBDIRS(testsuite)
7a6771
 
7a6771
 # Check whether to support alternative target configurations
7a6771
Index: gdb-7.11.50.20160630/gdb/corelow.c
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/corelow.c	2016-07-03 14:34:32.022753582 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/corelow.c	2016-07-03 14:37:12.582130819 +0200
7a6771
@@ -310,7 +310,7 @@
7a6771
         symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
7a6771
     }
7a6771
   else
7a6771
-    debug_print_missing (_("the main executable file"), build_id_filename);
7a6771
+    debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
7a6771
 
7a6771
   do_cleanups (back_to);
7a6771
 
7a6771
Index: gdb-7.11.50.20160630/gdb/build-id.c
7a6771
===================================================================
7a6771
--- gdb-7.11.50.20160630.orig/gdb/build-id.c	2016-07-03 14:36:50.124938187 +0200
7a6771
+++ gdb-7.11.50.20160630/gdb/build-id.c	2016-07-03 14:42:25.171812134 +0200
7a6771
@@ -35,6 +35,7 @@
7a6771
 #include "elf/common.h"
7a6771
 #include "elf-bfd.h"
7a6771
 #include <sys/stat.h>
7a6771
+#include "elf/external.h"
7a6771
 
7a6771
 #define BUILD_ID_VERBOSE_NONE 0
7a6771
 #define BUILD_ID_VERBOSE_FILENAMES 1
7a6771
@@ -665,8 +666,366 @@
7a6771
   return result;
7a6771
 }
7a6771
 
7a6771
+#ifdef HAVE_LIBRPM
7a6771
+
7a6771
+#include <rpm/rpmlib.h>
7a6771
+#include <rpm/rpmts.h>
7a6771
+#include <rpm/rpmdb.h>
7a6771
+#include <rpm/header.h>
7a6771
+#ifdef DLOPEN_LIBRPM
7a6771
+#include <dlfcn.h>
7a6771
+#endif
7a6771
+
7a6771
+/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
7a6771
+   and avoid their duplicities during a single inferior run.  */
7a6771
+
7a6771
+static struct htab *missing_rpm_hash;
7a6771
+
7a6771
+/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
7a6771
+   all the rpms right before the nearest GDB prompt.  It gets cleared after
7a6771
+   each such print (it is questionable if we should clear it after the print).
7a6771
+   */
7a6771
+
7a6771
+struct missing_rpm
7a6771
+  {
7a6771
+    struct missing_rpm *next;
7a6771
+    char rpm[1];
7a6771
+  };
7a6771
+static struct missing_rpm *missing_rpm_list;
7a6771
+static int missing_rpm_list_entries;
7a6771
+
7a6771
+/* Returns the count of newly added rpms.  */
7a6771
+
7a6771
+static int
7a6771
+missing_rpm_enlist (const char *filename)
7a6771
+{
7a6771
+  static int rpm_init_done = 0;
7a6771
+  rpmts ts;
7a6771
+  rpmdbMatchIterator mi;
7a6771
+  int count = 0;
7a6771
+
7a6771
+#ifdef DLOPEN_LIBRPM
7a6771
+  /* Duplicate here the declarations to verify they match.  The same sanity
7a6771
+     check is present also in `configure.ac'.  */
7a6771
+  extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
7a6771
+  static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
7a6771
+  extern int rpmReadConfigFiles(const char * file, const char * target);
7a6771
+  static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
7a6771
+  extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
7a6771
+  static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
7a6771
+  extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
7a6771
+  static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
7a6771
+  extern rpmts rpmtsCreate(void);
7a6771
+  static rpmts (*rpmtsCreate_p) (void);
7a6771
+  extern rpmts rpmtsFree(rpmts ts);
7a6771
+  static rpmts (*rpmtsFree_p) (rpmts ts);
7a6771
+  extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
7a6771
+                                              const void * keyp, size_t keylen);
7a6771
+  static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
7a6771
+						    rpmTag rpmtag,
7a6771
+						    const void *keyp,
7a6771
+						    size_t keylen);
7a6771
+#else	/* !DLOPEN_LIBRPM */
7a6771
+# define headerFormat_p headerFormat
7a6771
+# define rpmReadConfigFiles_p rpmReadConfigFiles
7a6771
+# define rpmdbFreeIterator_p rpmdbFreeIterator
7a6771
+# define rpmdbNextIterator_p rpmdbNextIterator
7a6771
+# define rpmtsCreate_p rpmtsCreate
7a6771
+# define rpmtsFree_p rpmtsFree
7a6771
+# define rpmtsInitIterator_p rpmtsInitIterator
7a6771
+#endif	/* !DLOPEN_LIBRPM */
7a6771
+
7a6771
+  gdb_assert (filename != NULL);
7a6771
+
7a6771
+  if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
7a6771
+    return 0;
7a6771
+
7a6771
+  if (is_target_filename (filename))
7a6771
+    return 0;
7a6771
+
7a6771
+  if (filename[0] != '/')
7a6771
+    {
7a6771
+      warning (_("Ignoring non-absolute filename: <%s>"), filename);
7a6771
+      return 0;
7a6771
+    }
7a6771
+
7a6771
+  if (!rpm_init_done)
7a6771
+    {
7a6771
+      static int init_tried;
7a6771
+
7a6771
+      /* Already failed the initialization before?  */
7a6771
+      if (init_tried)
7a6771
+      	return 0;
7a6771
+      init_tried = 1;
7a6771
+
7a6771
+#ifdef DLOPEN_LIBRPM
7a6771
+      {
7a6771
+	void *h;
7a6771
+
7a6771
+	h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
7a6771
+	if (!h)
7a6771
+	  {
7a6771
+	    warning (_("Unable to open \"%s\" (%s), "
7a6771
+		      "missing debuginfos notifications will not be displayed"),
7a6771
+		     DLOPEN_LIBRPM, dlerror ());
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+
7a6771
+	if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat"))
7a6771
+	      && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles"))
7a6771
+	      && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator"))
7a6771
+	      && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
7a6771
+	      && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
7a6771
+	      && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
7a6771
+	      && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
7a6771
+	  {
7a6771
+	    warning (_("Opened library \"%s\" is incompatible (%s), "
7a6771
+		      "missing debuginfos notifications will not be displayed"),
7a6771
+		     DLOPEN_LIBRPM, dlerror ());
7a6771
+	    if (dlclose (h))
7a6771
+	      warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
7a6771
+		       dlerror ());
7a6771
+	    return 0;
7a6771
+	  }
7a6771
+      }
7a6771
+#endif	/* DLOPEN_LIBRPM */
7a6771
+
7a6771
+      if (rpmReadConfigFiles_p (NULL, NULL) != 0)
7a6771
+	{
7a6771
+	  warning (_("Error reading the rpm configuration files"));
7a6771
+	  return 0;
7a6771
+	}
7a6771
+
7a6771
+      rpm_init_done = 1;
7a6771
+    }
7a6771
+
7a6771
+  ts = rpmtsCreate_p ();
7a6771
+
7a6771
+  mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
7a6771
+  if (mi != NULL)
7a6771
+    {
7a6771
+      for (;;)
7a6771
+	{
7a6771
+	  Header h;
7a6771
+	  char *debuginfo, **slot, *s, *s2;
7a6771
+	  errmsg_t err;
7a6771
+	  size_t srcrpmlen = sizeof (".src.rpm") - 1;
7a6771
+	  size_t debuginfolen = sizeof ("-debuginfo") - 1;
7a6771
+	  rpmdbMatchIterator mi_debuginfo;
7a6771
+
7a6771
+	  h = rpmdbNextIterator_p (mi);
7a6771
+	  if (h == NULL)
7a6771
+	    break;
7a6771
+
7a6771
+	  /* Verify the debuginfo file is not already installed.  */
7a6771
+
7a6771
+	  debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
7a6771
+				      &err;;
7a6771
+	  if (!debuginfo)
7a6771
+	    {
7a6771
+	      warning (_("Error querying the rpm file `%s': %s"), filename,
7a6771
+	               err);
7a6771
+	      continue;
7a6771
+	    }
7a6771
+	  /* s = `.src.rpm-debuginfo.%{arch}' */
7a6771
+	  s = strrchr (debuginfo, '-') - srcrpmlen;
7a6771
+	  s2 = NULL;
7a6771
+	  if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
7a6771
+	    {
7a6771
+	      /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
7a6771
+	      s2 = (char *) memrchr (debuginfo, '-', s - debuginfo);
7a6771
+	    }
7a6771
+	  if (s2)
7a6771
+	    {
7a6771
+	      /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
7a6771
+	      s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo);
7a6771
+	    }
7a6771
+	  if (!s2)
7a6771
+	    {
7a6771
+	      warning (_("Error querying the rpm file `%s': %s"), filename,
7a6771
+	               debuginfo);
7a6771
+	      xfree (debuginfo);
7a6771
+	      continue;
7a6771
+	    }
7a6771
+	  /* s = `.src.rpm-debuginfo.%{arch}' */
7a6771
+	  /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
7a6771
+	  memmove (s2 + debuginfolen, s2, s - s2);
7a6771
+	  memcpy (s2, "-debuginfo", debuginfolen);
7a6771
+	  /* s = `XXXX.%{arch}' */
7a6771
+	  /* strlen ("XXXX") == srcrpmlen + debuginfolen */
7a6771
+	  /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
7a6771
+	  /* strlen ("XX") == srcrpmlen */
7a6771
+	  memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
7a6771
+		   strlen (s + srcrpmlen + debuginfolen) + 1);
7a6771
+	  /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
7a6771
+
7a6771
+	  /* RPMDBI_PACKAGES requires keylen == sizeof (int).  */
7a6771
+	  /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel().  */
7a6771
+	  mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
7a6771
+	  xfree (debuginfo);
7a6771
+	  if (mi_debuginfo)
7a6771
+	    {
7a6771
+	      rpmdbFreeIterator_p (mi_debuginfo);
7a6771
+	      count = 0;
7a6771
+	      break;
7a6771
+	    }
7a6771
+
7a6771
+	  /* The allocated memory gets utilized below for MISSING_RPM_HASH.  */
7a6771
+	  debuginfo = headerFormat_p (h,
7a6771
+				      "%{name}-%{version}-%{release}.%{arch}",
7a6771
+				      &err;;
7a6771
+	  if (!debuginfo)
7a6771
+	    {
7a6771
+	      warning (_("Error querying the rpm file `%s': %s"), filename,
7a6771
+	               err);
7a6771
+	      continue;
7a6771
+	    }
7a6771
+
7a6771
+	  /* Base package name for `debuginfo-install'.  We do not use the
7a6771
+	     `yum' command directly as the line
7a6771
+		 yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
7a6771
+	     would be more complicated than just:
7a6771
+		 debuginfo-install NAME-VERSION-RELEASE.ARCH
7a6771
+	     Do not supply the rpm base name (derived from .src.rpm name) as
7a6771
+	     debuginfo-install is unable to install the debuginfo package if
7a6771
+	     the base name PKG binary rpm is not installed while for example
7a6771
+	     PKG-libs would be installed (RH Bug 467901).
7a6771
+	     FUTURE: After multiple debuginfo versions simultaneously installed
7a6771
+	     get supported the support for the VERSION-RELEASE tags handling
7a6771
+	     may need an update.  */
7a6771
+
7a6771
+	  if (missing_rpm_hash == NULL)
7a6771
+	    {
7a6771
+	      /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
7a6771
+		 should not deallocate the entries.  */
7a6771
+
7a6771
+	      missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
7a6771
+			       (int (*) (const void *, const void *)) streq,
7a6771
+						    NULL, xcalloc, xfree);
7a6771
+	    }
7a6771
+	  slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
7a6771
+	  /* XCALLOC never returns NULL.  */
7a6771
+	  gdb_assert (slot != NULL);
7a6771
+	  if (*slot == NULL)
7a6771
+	    {
7a6771
+	      struct missing_rpm *missing_rpm;
7a6771
+
7a6771
+	      *slot = debuginfo;
7a6771
+
7a6771
+	      missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
7a6771
+	      strcpy (missing_rpm->rpm, debuginfo);
7a6771
+	      missing_rpm->next = missing_rpm_list;
7a6771
+	      missing_rpm_list = missing_rpm;
7a6771
+	      missing_rpm_list_entries++;
7a6771
+	    }
7a6771
+	  else
7a6771
+	    xfree (debuginfo);
7a6771
+	  count++;
7a6771
+	}
7a6771
+
7a6771
+      rpmdbFreeIterator_p (mi);
7a6771
+    }
7a6771
+
7a6771
+  rpmtsFree_p (ts);
7a6771
+
7a6771
+  return count;
7a6771
+}
7a6771
+
7a6771
+static int
7a6771
+missing_rpm_list_compar (const char *const *ap, const char *const *bp)
7a6771
+{
7a6771
+  return strcoll (*ap, *bp);
7a6771
+}
7a6771
+
7a6771
+/* It returns a NULL-terminated array of strings needing to be FREEd.  It may
7a6771
+   also return only NULL.  */
7a6771
+
7a6771
+static void
7a6771
+missing_rpm_list_print (void)
7a6771
+{
7a6771
+  char **array, **array_iter;
7a6771
+  struct missing_rpm *list_iter;
7a6771
+  struct cleanup *cleanups;
7a6771
+
7a6771
+  if (missing_rpm_list_entries == 0)
7a6771
+    return;
7a6771
+
7a6771
+  array = (char **) xmalloc (sizeof (*array) * missing_rpm_list_entries);
7a6771
+  cleanups = make_cleanup (xfree, array);
7a6771
+
7a6771
+  array_iter = array;
7a6771
+  for (list_iter = missing_rpm_list; list_iter != NULL;
7a6771
+       list_iter = list_iter->next)
7a6771
+    {
7a6771
+      *array_iter++ = list_iter->rpm;
7a6771
+    }
7a6771
+  gdb_assert (array_iter == array + missing_rpm_list_entries);
7a6771
+
7a6771
+  qsort (array, missing_rpm_list_entries, sizeof (*array),
7a6771
+	 (int (*) (const void *, const void *)) missing_rpm_list_compar);
7a6771
+
7a6771
+  printf_unfiltered (_("Missing separate debuginfos, use: %s"),
7a6771
+#ifdef DNF_DEBUGINFO_INSTALL
7a6771
+		     "dnf "
7a6771
+#endif
7a6771
+		     "debuginfo-install");
7a6771
+  for (array_iter = array; array_iter < array + missing_rpm_list_entries;
7a6771
+       array_iter++)
7a6771
+    {
7a6771
+      putchar_unfiltered (' ');
7a6771
+      puts_unfiltered (*array_iter);
7a6771
+    }
7a6771
+  putchar_unfiltered ('\n');
7a6771
+
7a6771
+  while (missing_rpm_list != NULL)
7a6771
+    {
7a6771
+      list_iter = missing_rpm_list;
7a6771
+      missing_rpm_list = list_iter->next;
7a6771
+      xfree (list_iter);
7a6771
+    }
7a6771
+  missing_rpm_list_entries = 0;
7a6771
+
7a6771
+  do_cleanups (cleanups);
7a6771
+}
7a6771
+
7a6771
+static void
7a6771
+missing_rpm_change (void)
7a6771
+{
7a6771
+  debug_flush_missing ();
7a6771
+
7a6771
+  gdb_assert (missing_rpm_list == NULL);
7a6771
+  if (missing_rpm_hash != NULL)
7a6771
+    {
7a6771
+      htab_delete (missing_rpm_hash);
7a6771
+      missing_rpm_hash = NULL;
7a6771
+    }
7a6771
+}
7a6771
+
7a6771
+enum missing_exec
7a6771
+  {
7a6771
+    /* Init state.  EXEC_BFD also still could be NULL.  */
7a6771
+    MISSING_EXEC_NOT_TRIED,
7a6771
+    /* We saw a non-NULL EXEC_BFD but RPM has no info about it.  */
7a6771
+    MISSING_EXEC_NOT_FOUND,
7a6771
+    /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
7a6771
+       or separate) or the main executable's RPM is now contained in
7a6771
+       MISSING_RPM_HASH.  */
7a6771
+    MISSING_EXEC_ENLISTED
7a6771
+  };
7a6771
+static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
7a6771
+
7a6771
+#endif	/* HAVE_LIBRPM */
7a6771
+
7a6771
+void
7a6771
+debug_flush_missing (void)
7a6771
+{
7a6771
+#ifdef HAVE_LIBRPM
7a6771
+  missing_rpm_list_print ();
7a6771
+#endif
7a6771
+}
7a6771
+
7a6771
 /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
7a6771
-     Try to install the hash file ...
7a6771
+     yum --enablerepo='*debug*' install ...
7a6771
    avoidance.  */
7a6771
 
7a6771
 struct missing_filepair
7a6771
@@ -720,11 +1079,17 @@
7a6771
       /* All their memory came just from missing_filepair_OBSTACK.  */
7a6771
       missing_filepair_hash = NULL;
7a6771
     }
7a6771
+#ifdef HAVE_LIBRPM
7a6771
+  missing_exec = MISSING_EXEC_NOT_TRIED;
7a6771
+#endif
7a6771
 }
7a6771
 
7a6771
 static void
7a6771
 debug_print_executable_changed (void)
7a6771
 {
7a6771
+#ifdef HAVE_LIBRPM
7a6771
+  missing_rpm_change ();
7a6771
+#endif
7a6771
   missing_filepair_change ();
7a6771
 }
7a6771
 
7a6771
@@ -791,14 +1156,39 @@
7a6771
 
7a6771
   *slot = missing_filepair;
7a6771
 
7a6771
-  /* We do not collect and flush these messages as each such message
7a6771
-     already requires its own separate lines.  */
7a6771
+#ifdef HAVE_LIBRPM
7a6771
+  if (missing_exec == MISSING_EXEC_NOT_TRIED)
7a6771
+    {
7a6771
+      char *execfilename;
7a6771
 
7a6771
-  fprintf_unfiltered (gdb_stdlog,
7a6771
-		      _("Missing separate debuginfo for %s\n"), binary);
7a6771
-  if (debug != NULL)
7a6771
-    fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
7a6771
-			debug);
7a6771
+      execfilename = get_exec_file (0);
7a6771
+      if (execfilename != NULL)
7a6771
+	{
7a6771
+	  if (missing_rpm_enlist (execfilename) == 0)
7a6771
+	    missing_exec = MISSING_EXEC_NOT_FOUND;
7a6771
+	  else
7a6771
+	    missing_exec = MISSING_EXEC_ENLISTED;
7a6771
+	}
7a6771
+    }
7a6771
+  if (missing_exec != MISSING_EXEC_ENLISTED)
7a6771
+    if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
7a6771
+	&& (debug == NULL || missing_rpm_enlist (debug) == 0))
7a6771
+#endif	/* HAVE_LIBRPM */
7a6771
+      {
7a6771
+	/* We do not collect and flush these messages as each such message
7a6771
+	   already requires its own separate lines.  */
7a6771
+
7a6771
+	fprintf_unfiltered (gdb_stdlog,
7a6771
+			    _("Missing separate debuginfo for %s\n"), binary);
7a6771
+        if (debug != NULL)
7a6771
+	  fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
7a6771
+#ifdef DNF_DEBUGINFO_INSTALL
7a6771
+			      "dnf"
7a6771
+#else
7a6771
+			      "yum"
7a6771
+#endif
7a6771
+			      " --enablerepo='*debug*' install", debug);
7a6771
+      }
7a6771
 }
7a6771
 
7a6771
 /* See build-id.h.  */