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

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