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