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