1 Index: gdb-7.10.50.20160106/gdb/event-top.c
2 ===================================================================
3 --- gdb-7.10.50.20160106.orig/gdb/event-top.c
4 +++ gdb-7.10.50.20160106/gdb/event-top.c
6 #include "gdbcmd.h" /* for dont_repeat() */
11 /* readline include files. */
12 #include "readline/readline.h"
13 @@ -180,6 +181,8 @@ rl_callback_read_char_wrapper (gdb_clien
15 cli_command_loop (void *data)
17 + debug_flush_missing ();
19 display_gdb_prompt (0);
21 /* Now it's time to start the event loop. */
22 @@ -298,6 +301,8 @@ display_gdb_prompt (const char *new_prom
23 /* Reset the nesting depth used when trace-commands is set. */
24 reset_command_nest_depth ();
26 + debug_flush_missing ();
28 old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
30 /* Do not call the python hook on an explicit prompt change as
31 Index: gdb-7.10.50.20160106/gdb/symfile.h
32 ===================================================================
33 --- gdb-7.10.50.20160106.orig/gdb/symfile.h
34 +++ gdb-7.10.50.20160106/gdb/symfile.h
35 @@ -587,6 +587,8 @@ void map_symbol_filenames (symbol_filena
36 /* build-id support. */
37 extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
38 extern void debug_print_missing (const char *binary, const char *debug);
39 +extern void debug_flush_missing (void);
40 +#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
42 /* From dwarf2read.c */
44 Index: gdb-7.10.50.20160106/gdb/testsuite/lib/gdb.exp
45 ===================================================================
46 --- gdb-7.10.50.20160106.orig/gdb/testsuite/lib/gdb.exp
47 +++ gdb-7.10.50.20160106/gdb/testsuite/lib/gdb.exp
48 @@ -1642,7 +1642,7 @@ proc default_gdb_start { } {
49 warning "Couldn't set the width to 0."
52 - # Turn off the missing warnings as the testsuite does not expect it.
53 + # Turn off the missing RPMs warnings as the testsuite does not expect it.
54 send_gdb "set build-id-verbose 0\n"
57 Index: gdb-7.10.50.20160106/gdb/testsuite/lib/mi-support.exp
58 ===================================================================
59 --- gdb-7.10.50.20160106.orig/gdb/testsuite/lib/mi-support.exp
60 +++ gdb-7.10.50.20160106/gdb/testsuite/lib/mi-support.exp
61 @@ -204,7 +204,7 @@ proc default_mi_gdb_start { args } {
62 warning "Couldn't set the width to 0."
65 - # Turn off the missing warnings as the testsuite does not expect it.
66 + # Turn off the missing RPMs warnings as the testsuite does not expect it.
67 send_gdb "190-gdb-set build-id-verbose 0\n"
69 -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
70 Index: gdb-7.10.50.20160106/gdb/tui/tui-interp.c
71 ===================================================================
72 --- gdb-7.10.50.20160106.orig/gdb/tui/tui-interp.c
73 +++ gdb-7.10.50.20160106/gdb/tui/tui-interp.c
75 #include "tui/tui-io.h"
80 static struct ui_out *tui_ui_out (struct interp *self);
82 Index: gdb-7.10.50.20160106/gdb/aclocal.m4
83 ===================================================================
84 --- gdb-7.10.50.20160106.orig/gdb/aclocal.m4
85 +++ gdb-7.10.50.20160106/gdb/aclocal.m4
87 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
90 +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
91 +# serial 1 (pkg-config-0.24)
93 +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
95 +# This program is free software; you can redistribute it and/or modify
96 +# it under the terms of the GNU General Public License as published by
97 +# the Free Software Foundation; either version 2 of the License, or
98 +# (at your option) any later version.
100 +# This program is distributed in the hope that it will be useful, but
101 +# WITHOUT ANY WARRANTY; without even the implied warranty of
102 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
103 +# General Public License for more details.
105 +# You should have received a copy of the GNU General Public License
106 +# along with this program; if not, write to the Free Software
107 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
109 +# As a special exception to the GNU General Public License, if you
110 +# distribute this file as part of a program that contains a
111 +# configuration script generated by Autoconf, you may include it under
112 +# the same distribution terms that you use for the rest of that program.
114 +# PKG_PROG_PKG_CONFIG([MIN-VERSION])
115 +# ----------------------------------
116 +AC_DEFUN([PKG_PROG_PKG_CONFIG],
117 +[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
118 +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
119 +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
120 +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
121 +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
122 +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
124 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
125 + AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
127 +if test -n "$PKG_CONFIG"; then
128 + _pkg_min_version=m4_default([$1], [0.9.0])
129 + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
130 + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
131 + AC_MSG_RESULT([yes])
133 + AC_MSG_RESULT([no])
137 +])# PKG_PROG_PKG_CONFIG
139 +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
141 +# Check to see whether a particular set of modules exists. Similar
142 +# to PKG_CHECK_MODULES(), but does not set variables or print errors.
144 +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
145 +# only at the first occurence in configure.ac, so if the first place
146 +# it's called might be skipped (such as if it is within an "if", you
147 +# have to call PKG_CHECK_EXISTS manually
148 +# --------------------------------------------------------------
149 +AC_DEFUN([PKG_CHECK_EXISTS],
150 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
151 +if test -n "$PKG_CONFIG" && \
152 + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
153 + m4_default([$2], [:])
154 +m4_ifvaln([$3], [else
158 +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
159 +# ---------------------------------------------
160 +m4_define([_PKG_CONFIG],
161 +[if test -n "$$1"; then
163 + elif test -n "$PKG_CONFIG"; then
164 + PKG_CHECK_EXISTS([$3],
165 + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
166 + test "x$?" != "x0" && pkg_failed=yes ],
173 +# _PKG_SHORT_ERRORS_SUPPORTED
174 +# -----------------------------
175 +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
176 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
177 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
178 + _pkg_short_errors_supported=yes
180 + _pkg_short_errors_supported=no
182 +])# _PKG_SHORT_ERRORS_SUPPORTED
185 +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
186 +# [ACTION-IF-NOT-FOUND])
189 +# Note that if there is a possibility the first call to
190 +# PKG_CHECK_MODULES might not happen, you should be sure to include an
191 +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
194 +# --------------------------------------------------------------
195 +AC_DEFUN([PKG_CHECK_MODULES],
196 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
197 +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
198 +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
201 +AC_MSG_CHECKING([for $1])
203 +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
204 +_PKG_CONFIG([$1][_LIBS], [libs], [$2])
206 +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
207 +and $1[]_LIBS to avoid the need to call pkg-config.
208 +See the pkg-config man page for more details.])
210 +if test $pkg_failed = yes; then
211 + AC_MSG_RESULT([no])
212 + _PKG_SHORT_ERRORS_SUPPORTED
213 + if test $_pkg_short_errors_supported = yes; then
214 + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
216 + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
218 + # Put the nasty error message in config.log where it belongs
219 + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
221 + m4_default([$4], [AC_MSG_ERROR(
222 +[Package requirements ($2) were not met:
226 +Consider adjusting the PKG_CONFIG_PATH environment variable if you
227 +installed software in a non-standard prefix.
231 +elif test $pkg_failed = untried; then
232 + AC_MSG_RESULT([no])
233 + m4_default([$4], [AC_MSG_FAILURE(
234 +[The pkg-config script could not be found or is too old. Make sure it
235 +is in your PATH or set the PKG_CONFIG environment variable to the full
240 +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
243 + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
244 + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
245 + AC_MSG_RESULT([yes])
248 +])# PKG_CHECK_MODULES
251 +# PKG_INSTALLDIR(DIRECTORY)
252 +# -------------------------
253 +# Substitutes the variable pkgconfigdir as the location where a module
254 +# should install pkg-config .pc files. By default the directory is
255 +# $libdir/pkgconfig, but the default can be changed by passing
256 +# DIRECTORY. The user can override through the --with-pkgconfigdir
258 +AC_DEFUN([PKG_INSTALLDIR],
259 +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
260 +m4_pushdef([pkg_description],
261 + [pkg-config installation directory @<:@]pkg_default[@:>@])
262 +AC_ARG_WITH([pkgconfigdir],
263 + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
264 + [with_pkgconfigdir=]pkg_default)
265 +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
266 +m4_popdef([pkg_default])
267 +m4_popdef([pkg_description])
268 +]) dnl PKG_INSTALLDIR
271 +# PKG_NOARCH_INSTALLDIR(DIRECTORY)
272 +# -------------------------
273 +# Substitutes the variable noarch_pkgconfigdir as the location where a
274 +# module should install arch-independent pkg-config .pc files. By
275 +# default the directory is $datadir/pkgconfig, but the default can be
276 +# changed by passing DIRECTORY. The user can override through the
277 +# --with-noarch-pkgconfigdir parameter.
278 +AC_DEFUN([PKG_NOARCH_INSTALLDIR],
279 +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
280 +m4_pushdef([pkg_description],
281 + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
282 +AC_ARG_WITH([noarch-pkgconfigdir],
283 + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
284 + [with_noarch_pkgconfigdir=]pkg_default)
285 +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
286 +m4_popdef([pkg_default])
287 +m4_popdef([pkg_description])
288 +]) dnl PKG_NOARCH_INSTALLDIR
291 +# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
292 +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
293 +# -------------------------------------------
294 +# Retrieves the value of the pkg-config variable for the given module.
295 +AC_DEFUN([PKG_CHECK_VAR],
296 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
297 +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
299 +_PKG_CONFIG([$1], [variable="][$3]["], [$2])
300 +AS_VAR_COPY([$1], [pkg_cv_][$1])
302 +AS_VAR_IF([$1], [""], [$5], [$4])dnl
305 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
307 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
308 Index: gdb-7.10.50.20160106/gdb/config.in
309 ===================================================================
310 --- gdb-7.10.50.20160106.orig/gdb/config.in
311 +++ gdb-7.10.50.20160106/gdb/config.in
313 /* Define to BFD's default target vector. */
314 #undef DEFAULT_BFD_VEC
316 +/* librpm version specific library name to dlopen. */
317 +#undef DLOPEN_LIBRPM
319 /* Define to 1 if translation of program messages to the user's native
320 language is requested. */
323 /* Define if Python 2.7 is being used. */
324 #undef HAVE_LIBPYTHON2_7
326 +/* Define if librpm library is being used. */
329 /* Define to 1 if you have the <libunwind-ia64.h> header file. */
330 #undef HAVE_LIBUNWIND_IA64_H
332 Index: gdb-7.10.50.20160106/gdb/configure
333 ===================================================================
334 --- gdb-7.10.50.20160106.orig/gdb/configure
335 +++ gdb-7.10.50.20160106/gdb/configure
336 @@ -705,6 +705,11 @@ PKGVERSION
337 HAVE_NATIVE_GCORE_TARGET
348 @@ -813,6 +818,7 @@ with_gdb_datadir
349 with_relocated_sources
351 with_auto_load_safe_path
356 @@ -869,6 +875,11 @@ CCC
368 @@ -1540,6 +1551,8 @@ Optional Packages:
369 [--with-auto-load-dir]
370 --without-auto-load-safe-path
371 do not restrict auto-loaded files locations
372 + --with-rpm query rpm database for missing debuginfos (yes/no,
373 + def. auto=librpm.so)
374 --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
375 --with-curses use the curses library instead of the termcap
377 @@ -1595,6 +1608,13 @@ Some influential environment variables:
378 MAKEINFO Parent configure detects if it is of sufficient version.
380 Parameters for MAKEINFO.
381 + PKG_CONFIG path to pkg-config utility
383 + directories to add to pkg-config's search path
385 + path overriding pkg-config's built-in search path
386 + RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
387 + RPM_LIBS linker flags for RPM, overriding pkg-config
388 YACC The `Yet Another C Compiler' implementation to use. Defaults to
389 the first program found out of: `bison -y', `byacc', `yacc'.
390 YFLAGS The list of arguments that will be passed by default to $YACC.
391 @@ -5655,6 +5675,494 @@ _ACEOF
392 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
393 $as_echo "$with_auto_load_safe_path" >&6; }
395 +# Integration with rpm library to support missing debuginfo suggestions.
396 +# --without-rpm: Disable any rpm support.
397 +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
398 +# Even with runtime missing `libname.so' GDB will still other run correctly.
399 +# Missing `libname.so' during ./configure will abort the configuration.
400 +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
401 +# minor version first such as `librpm-4.6.so' as minor version differences
402 +# mean API+ABI incompatibility. If the specific match versioned library name
403 +# could not be found still open dynamically at least `librpm.so'.
404 +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
405 +# to find librpm for compilation-time linking by pkg-config. GDB binary will
406 +# be probably linked with the version specific library (as `librpm-4.6.so').
407 +# Failure to find librpm by pkg-config will abort the configuration.
408 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
409 +# cannot find librpm use to the rpmless compilation (like `--without-rpm').
412 +# Check whether --with-rpm was given.
413 +if test "${with_rpm+set}" = set; then :
422 +if test "x$with_rpm" != "xno"; then
423 + if test "x$with_rpm" = "xyes"; then
426 + DLOPEN_REQUIRE=false
427 + elif test "x$with_rpm" = "xauto"; then
430 + DLOPEN_REQUIRE=false
434 + DLOPEN_REQUIRE=true
436 + LIBRPM_STRING='"'"$LIBRPM"'"'
438 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
439 +$as_echo_n "checking specific librpm version... " >&6; }
440 + HAVE_DLOPEN_LIBRPM=false
443 + if test "$cross_compiling" = yes; then :
444 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
445 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
446 +as_fn_error "cannot run test program while cross compiling
447 +See \`config.log' for more details." "$LINENO" 5; }
449 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
450 +/* end confdefs.h. */
452 +#include <rpm/rpmlib.h>
461 + const char *const *rpmverp;
464 + f = fopen ("conftest.out", "w");
467 + fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
471 + h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
474 + fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
477 + rpmverp = dlsym (h, "RPMVERSION");
480 + fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
483 + fprintf (stderr, "RPMVERSION is: \"");
484 + fprintf (stderr, "%s\"\n", *rpmverp);
486 + /* Try to find the specific librpm version only for "librpm.so" as we do
487 + not know how to assemble the version string otherwise. */
489 + if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
491 + fprintf (f, "%s\n", $LIBRPM_STRING);
500 + if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
502 + fprintf (stderr, "Unable to parse RPMVERSION.\n");
503 + fprintf (f, "%s\n", $LIBRPM_STRING);
506 + /* Avoid the square brackets by malloc. */
507 + h2_name = malloc (64);
508 + sprintf (h2_name, "librpm-%d.%d.so", major, minor);
509 + h2 = dlopen (h2_name, RTLD_LAZY);
512 + fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
513 + fprintf (f, "%s\n", $LIBRPM_STRING);
518 + fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
519 + $LIBRPM_STRING, h2_name);
520 + fprintf (f, "%s\n", $LIBRPM_STRING);
523 + /* Found the valid .so name with a specific version. */
524 + fprintf (f, "%s\n", h2_name);
532 +if ac_fn_c_try_run "$LINENO"; then :
534 + DLOPEN_LIBRPM="`cat conftest.out`"
535 + if test "x$DLOPEN_LIBRPM" != "x"; then
536 + HAVE_DLOPEN_LIBRPM=true
537 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
538 +$as_echo "$DLOPEN_LIBRPM" >&6; }
542 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
543 + conftest.$ac_objext conftest.beam conftest.$ac_ext
550 + if $HAVE_DLOPEN_LIBRPM; then
552 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
553 +$as_echo_n "checking rpm library API compatibility... " >&6; }
554 + # The compilation requires -Werror to verify anything.
555 + save_CFLAGS="$CFLAGS"
556 + CFLAGS="$CFLAGS -Werror"
557 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
558 +/* end confdefs.h. */
560 +/* Duplicate here the declarations to verify they match "elfread.c". */
561 +#include <rpm/rpmlib.h>
562 +#include <rpm/rpmts.h>
563 +#include <rpm/rpmdb.h>
564 +#include <rpm/header.h>
565 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
566 +extern int rpmReadConfigFiles(const char * file, const char * target);
567 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
568 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
569 +extern rpmts rpmtsCreate(void);
570 +extern rpmts rpmtsFree(rpmts ts);
571 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
572 + const void * keyp, size_t keylen);
582 +if ac_fn_c_try_compile "$LINENO"; then :
585 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
586 +$as_echo "yes" >&6; }
590 + LIBRPM_COMPAT=false
591 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
592 +$as_echo "no" >&6; }
595 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
596 + CFLAGS="$save_CFLAGS"
598 + if ! $LIBRPM_COMPAT; then
599 + HAVE_DLOPEN_LIBRPM=false
603 + if $HAVE_DLOPEN_LIBRPM; then
604 + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
606 +cat >>confdefs.h <<_ACEOF
607 +#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
611 +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
614 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
615 +$as_echo "no" >&6; }
617 + if $DLOPEN_REQUIRE; then
618 + as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
627 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
628 + if test -n "$ac_tool_prefix"; then
629 + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
630 +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
631 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
632 +$as_echo_n "checking for $ac_word... " >&6; }
633 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
634 + $as_echo_n "(cached) " >&6
636 + case $PKG_CONFIG in
638 + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
641 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
645 + test -z "$as_dir" && as_dir=.
646 + for ac_exec_ext in '' $ac_executable_extensions; do
647 + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
648 + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
649 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
659 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
660 +if test -n "$PKG_CONFIG"; then
661 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
662 +$as_echo "$PKG_CONFIG" >&6; }
664 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
665 +$as_echo "no" >&6; }
670 +if test -z "$ac_cv_path_PKG_CONFIG"; then
671 + ac_pt_PKG_CONFIG=$PKG_CONFIG
672 + # Extract the first word of "pkg-config", so it can be a program name with args.
673 +set dummy pkg-config; ac_word=$2
674 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
675 +$as_echo_n "checking for $ac_word... " >&6; }
676 +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
677 + $as_echo_n "(cached) " >&6
679 + case $ac_pt_PKG_CONFIG in
681 + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
684 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
688 + test -z "$as_dir" && as_dir=.
689 + for ac_exec_ext in '' $ac_executable_extensions; do
690 + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
691 + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
692 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
702 +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
703 +if test -n "$ac_pt_PKG_CONFIG"; then
704 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
705 +$as_echo "$ac_pt_PKG_CONFIG" >&6; }
707 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
708 +$as_echo "no" >&6; }
711 + if test "x$ac_pt_PKG_CONFIG" = x; then
714 + case $cross_compiling:$ac_tool_warned in
716 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
717 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
718 +ac_tool_warned=yes ;;
720 + PKG_CONFIG=$ac_pt_PKG_CONFIG
723 + PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
727 +if test -n "$PKG_CONFIG"; then
728 + _pkg_min_version=0.9.0
729 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
730 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
731 + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
732 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
733 +$as_echo "yes" >&6; }
735 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
736 +$as_echo "no" >&6; }
742 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
743 +$as_echo_n "checking for RPM... " >&6; }
745 +if test -n "$RPM_CFLAGS"; then
746 + pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
747 + elif test -n "$PKG_CONFIG"; then
748 + if test -n "$PKG_CONFIG" && \
749 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
750 + ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
752 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
753 + test $ac_status = 0; }; then
754 + pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
755 + test "x$?" != "x0" && pkg_failed=yes
762 +if test -n "$RPM_LIBS"; then
763 + pkg_cv_RPM_LIBS="$RPM_LIBS"
764 + elif test -n "$PKG_CONFIG"; then
765 + if test -n "$PKG_CONFIG" && \
766 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
767 + ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
769 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
770 + test $ac_status = 0; }; then
771 + pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
772 + test "x$?" != "x0" && pkg_failed=yes
782 +if test $pkg_failed = yes; then
783 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
784 +$as_echo "no" >&6; }
786 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
787 + _pkg_short_errors_supported=yes
789 + _pkg_short_errors_supported=no
791 + if test $_pkg_short_errors_supported = yes; then
792 + RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
794 + RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
796 + # Put the nasty error message in config.log where it belongs
797 + echo "$RPM_PKG_ERRORS" >&5
800 +elif test $pkg_failed = untried; then
801 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
802 +$as_echo "no" >&6; }
805 + RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
806 + RPM_LIBS=$pkg_cv_RPM_LIBS
807 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
808 +$as_echo "yes" >&6; }
812 + if $HAVE_LIBRPM; then
814 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
815 +$as_echo_n "checking rpm library API compatibility... " >&6; }
816 + # The compilation requires -Werror to verify anything.
817 + save_CFLAGS="$CFLAGS"
818 + CFLAGS="$CFLAGS -Werror"
819 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
820 +/* end confdefs.h. */
822 +/* Duplicate here the declarations to verify they match "elfread.c". */
823 +#include <rpm/rpmlib.h>
824 +#include <rpm/rpmts.h>
825 +#include <rpm/rpmdb.h>
826 +#include <rpm/header.h>
827 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
828 +extern int rpmReadConfigFiles(const char * file, const char * target);
829 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
830 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
831 +extern rpmts rpmtsCreate(void);
832 +extern rpmts rpmtsFree(rpmts ts);
833 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
834 + const void * keyp, size_t keylen);
844 +if ac_fn_c_try_compile "$LINENO"; then :
847 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
848 +$as_echo "yes" >&6; }
852 + LIBRPM_COMPAT=false
853 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
854 +$as_echo "no" >&6; }
857 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
858 + CFLAGS="$save_CFLAGS"
860 + if ! $LIBRPM_COMPAT; then
862 + RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
866 + if $HAVE_LIBRPM; then
868 +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
870 + CFLAGS="$CFLAGS $RPM_CFLAGS"
871 + LIBS="$LIBS $RPM_LIBS"
873 + if $RPM_REQUIRE; then
874 + as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
876 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
877 +$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
885 subdirs="$subdirs testsuite"
886 Index: gdb-7.10.50.20160106/gdb/configure.ac
887 ===================================================================
888 --- gdb-7.10.50.20160106.orig/gdb/configure.ac
889 +++ gdb-7.10.50.20160106/gdb/configure.ac
890 @@ -177,6 +177,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap
891 [Directories safe to hold auto-loaded files.])
892 AC_MSG_RESULT([$with_auto_load_safe_path])
894 +# Integration with rpm library to support missing debuginfo suggestions.
895 +# --without-rpm: Disable any rpm support.
896 +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
897 +# Even with runtime missing `libname.so' GDB will still other run correctly.
898 +# Missing `libname.so' during ./configure will abort the configuration.
899 +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
900 +# minor version first such as `librpm-4.6.so' as minor version differences
901 +# mean API+ABI incompatibility. If the specific match versioned library name
902 +# could not be found still open dynamically at least `librpm.so'.
903 +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
904 +# to find librpm for compilation-time linking by pkg-config. GDB binary will
905 +# be probably linked with the version specific library (as `librpm-4.6.so').
906 +# Failure to find librpm by pkg-config will abort the configuration.
907 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
908 +# cannot find librpm use to the rpmless compilation (like `--without-rpm').
911 + [AS_HELP_STRING([--with-rpm],
912 + [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
914 +m4_pattern_allow([^AC_MSG_ERROR$])
915 +m4_pattern_allow([^AC_MSG_WARN$])
916 +if test "x$with_rpm" != "xno"; then
917 + if test "x$with_rpm" = "xyes"; then
920 + DLOPEN_REQUIRE=false
921 + elif test "x$with_rpm" = "xauto"; then
924 + DLOPEN_REQUIRE=false
928 + DLOPEN_REQUIRE=true
930 + LIBRPM_STRING='"'"$LIBRPM"'"'
932 + AC_MSG_CHECKING([specific librpm version])
933 + HAVE_DLOPEN_LIBRPM=false
936 + AC_RUN_IFELSE(AC_LANG_PROGRAM([[
937 +#include <rpm/rpmlib.h>
942 + const char *const *rpmverp;
945 + f = fopen ("conftest.out", "w");
948 + fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
952 + h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
955 + fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
958 + rpmverp = dlsym (h, "RPMVERSION");
961 + fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
964 + fprintf (stderr, "RPMVERSION is: \"");
965 + fprintf (stderr, "%s\"\n", *rpmverp);
967 + /* Try to find the specific librpm version only for "librpm.so" as we do
968 + not know how to assemble the version string otherwise. */
970 + if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
972 + fprintf (f, "%s\n", $LIBRPM_STRING);
981 + if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
983 + fprintf (stderr, "Unable to parse RPMVERSION.\n");
984 + fprintf (f, "%s\n", $LIBRPM_STRING);
987 + /* Avoid the square brackets by malloc. */
988 + h2_name = malloc (64);
989 + sprintf (h2_name, "librpm-%d.%d.so", major, minor);
990 + h2 = dlopen (h2_name, RTLD_LAZY);
993 + fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
994 + fprintf (f, "%s\n", $LIBRPM_STRING);
999 + fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
1000 + $LIBRPM_STRING, h2_name);
1001 + fprintf (f, "%s\n", $LIBRPM_STRING);
1004 + /* Found the valid .so name with a specific version. */
1005 + fprintf (f, "%s\n", h2_name);
1009 + DLOPEN_LIBRPM="`cat conftest.out`"
1010 + if test "x$DLOPEN_LIBRPM" != "x"; then
1011 + HAVE_DLOPEN_LIBRPM=true
1012 + AC_MSG_RESULT($DLOPEN_LIBRPM)
1015 + rm -f conftest.out
1017 + m4_define([CHECK_LIBRPM_COMPAT], [
1018 + AC_MSG_CHECKING([rpm library API compatibility])
1019 + # The compilation requires -Werror to verify anything.
1020 + save_CFLAGS="$CFLAGS"
1021 + CFLAGS="$CFLAGS -Werror"
1022 + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
1023 +/* Duplicate here the declarations to verify they match "elfread.c". */
1024 +#include <rpm/rpmlib.h>
1025 +#include <rpm/rpmts.h>
1026 +#include <rpm/rpmdb.h>
1027 +#include <rpm/header.h>
1028 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
1029 +extern int rpmReadConfigFiles(const char * file, const char * target);
1030 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
1031 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
1032 +extern rpmts rpmtsCreate(void);
1033 +extern rpmts rpmtsFree(rpmts ts);
1034 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
1035 + const void * keyp, size_t keylen);
1037 + LIBRPM_COMPAT=true
1038 + AC_MSG_RESULT(yes)
1040 + LIBRPM_COMPAT=false
1043 + CFLAGS="$save_CFLAGS"
1046 + if $HAVE_DLOPEN_LIBRPM; then
1047 + CHECK_LIBRPM_COMPAT
1048 + if ! $LIBRPM_COMPAT; then
1049 + HAVE_DLOPEN_LIBRPM=false
1053 + if $HAVE_DLOPEN_LIBRPM; then
1054 + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
1055 + AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
1056 + AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
1060 + if $DLOPEN_REQUIRE; then
1061 + AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
1063 + PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
1065 + if $HAVE_LIBRPM; then
1066 + CHECK_LIBRPM_COMPAT
1067 + if ! $LIBRPM_COMPAT; then
1069 + RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
1073 + if $HAVE_LIBRPM; then
1074 + AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
1075 + CFLAGS="$CFLAGS $RPM_CFLAGS"
1076 + LIBS="$LIBS $RPM_LIBS"
1078 + if $RPM_REQUIRE; then
1079 + AC_MSG_ERROR($RPM_PKG_ERRORS)
1081 + AC_MSG_WARN($RPM_PKG_ERRORS)
1087 AC_CONFIG_SUBDIRS(testsuite)
1089 # Check whether to support alternative target configurations
1090 Index: gdb-7.10.50.20160106/gdb/corelow.c
1091 ===================================================================
1092 --- gdb-7.10.50.20160106.orig/gdb/corelow.c
1093 +++ gdb-7.10.50.20160106/gdb/corelow.c
1094 @@ -310,7 +310,7 @@ build_id_locate_exec (int from_tty)
1095 symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
1098 - debug_print_missing (_("the main executable file"), build_id_filename);
1099 + debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
1101 do_cleanups (back_to);
1103 Index: gdb-7.10.50.20160106/gdb/build-id.c
1104 ===================================================================
1105 --- gdb-7.10.50.20160106.orig/gdb/build-id.c
1106 +++ gdb-7.10.50.20160106/gdb/build-id.c
1108 #include "elf/common.h"
1109 #include "elf-bfd.h"
1110 #include <sys/stat.h>
1111 +#include "elf/external.h"
1113 #define BUILD_ID_VERBOSE_NONE 0
1114 #define BUILD_ID_VERBOSE_FILENAMES 1
1115 @@ -665,8 +666,366 @@ build_id_to_filename (const struct bfd_b
1121 +#include <rpm/rpmlib.h>
1122 +#include <rpm/rpmts.h>
1123 +#include <rpm/rpmdb.h>
1124 +#include <rpm/header.h>
1125 +#ifdef DLOPEN_LIBRPM
1129 +/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
1130 + and avoid their duplicities during a single inferior run. */
1132 +static struct htab *missing_rpm_hash;
1134 +/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
1135 + all the rpms right before the nearest GDB prompt. It gets cleared after
1136 + each such print (it is questionable if we should clear it after the print).
1141 + struct missing_rpm *next;
1144 +static struct missing_rpm *missing_rpm_list;
1145 +static int missing_rpm_list_entries;
1147 +/* Returns the count of newly added rpms. */
1150 +missing_rpm_enlist (const char *filename)
1152 + static int rpm_init_done = 0;
1154 + rpmdbMatchIterator mi;
1157 +#ifdef DLOPEN_LIBRPM
1158 + /* Duplicate here the declarations to verify they match. The same sanity
1159 + check is present also in `configure.ac'. */
1160 + extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
1161 + static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
1162 + extern int rpmReadConfigFiles(const char * file, const char * target);
1163 + static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
1164 + extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
1165 + static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
1166 + extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
1167 + static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
1168 + extern rpmts rpmtsCreate(void);
1169 + static rpmts (*rpmtsCreate_p) (void);
1170 + extern rpmts rpmtsFree(rpmts ts);
1171 + static rpmts (*rpmtsFree_p) (rpmts ts);
1172 + extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
1173 + const void * keyp, size_t keylen);
1174 + static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
1178 +#else /* !DLOPEN_LIBRPM */
1179 +# define headerFormat_p headerFormat
1180 +# define rpmReadConfigFiles_p rpmReadConfigFiles
1181 +# define rpmdbFreeIterator_p rpmdbFreeIterator
1182 +# define rpmdbNextIterator_p rpmdbNextIterator
1183 +# define rpmtsCreate_p rpmtsCreate
1184 +# define rpmtsFree_p rpmtsFree
1185 +# define rpmtsInitIterator_p rpmtsInitIterator
1186 +#endif /* !DLOPEN_LIBRPM */
1188 + gdb_assert (filename != NULL);
1190 + if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
1193 + if (is_target_filename (filename))
1196 + if (filename[0] != '/')
1198 + warning (_("Ignoring non-absolute filename: <%s>"), filename);
1202 + if (!rpm_init_done)
1204 + static int init_tried;
1206 + /* Already failed the initialization before? */
1211 +#ifdef DLOPEN_LIBRPM
1215 + h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
1218 + warning (_("Unable to open \"%s\" (%s), "
1219 + "missing debuginfos notifications will not be displayed"),
1220 + DLOPEN_LIBRPM, dlerror ());
1224 + if (!((headerFormat_p = dlsym (h, "headerFormat"))
1225 + && (rpmReadConfigFiles_p = dlsym (h, "rpmReadConfigFiles"))
1226 + && (rpmdbFreeIterator_p = dlsym (h, "rpmdbFreeIterator"))
1227 + && (rpmdbNextIterator_p = dlsym (h, "rpmdbNextIterator"))
1228 + && (rpmtsCreate_p = dlsym (h, "rpmtsCreate"))
1229 + && (rpmtsFree_p = dlsym (h, "rpmtsFree"))
1230 + && (rpmtsInitIterator_p = dlsym (h, "rpmtsInitIterator"))))
1232 + warning (_("Opened library \"%s\" is incompatible (%s), "
1233 + "missing debuginfos notifications will not be displayed"),
1234 + DLOPEN_LIBRPM, dlerror ());
1236 + warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
1241 +#endif /* DLOPEN_LIBRPM */
1243 + if (rpmReadConfigFiles_p (NULL, NULL) != 0)
1245 + warning (_("Error reading the rpm configuration files"));
1249 + rpm_init_done = 1;
1252 + ts = rpmtsCreate_p ();
1254 + mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
1260 + char *debuginfo, **slot, *s, *s2;
1262 + size_t srcrpmlen = sizeof (".src.rpm") - 1;
1263 + size_t debuginfolen = sizeof ("-debuginfo") - 1;
1264 + rpmdbMatchIterator mi_debuginfo;
1266 + h = rpmdbNextIterator_p (mi);
1270 + /* Verify the debuginfo file is not already installed. */
1272 + debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
1276 + warning (_("Error querying the rpm file `%s': %s"), filename,
1280 + /* s = `.src.rpm-debuginfo.%{arch}' */
1281 + s = strrchr (debuginfo, '-') - srcrpmlen;
1283 + if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
1285 + /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
1286 + s2 = memrchr (debuginfo, '-', s - debuginfo);
1290 + /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
1291 + s2 = memrchr (debuginfo, '-', s2 - debuginfo);
1295 + warning (_("Error querying the rpm file `%s': %s"), filename,
1297 + xfree (debuginfo);
1300 + /* s = `.src.rpm-debuginfo.%{arch}' */
1301 + /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
1302 + memmove (s2 + debuginfolen, s2, s - s2);
1303 + memcpy (s2, "-debuginfo", debuginfolen);
1304 + /* s = `XXXX.%{arch}' */
1305 + /* strlen ("XXXX") == srcrpmlen + debuginfolen */
1306 + /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
1307 + /* strlen ("XX") == srcrpmlen */
1308 + memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
1309 + strlen (s + srcrpmlen + debuginfolen) + 1);
1310 + /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
1312 + /* RPMDBI_PACKAGES requires keylen == sizeof (int). */
1313 + /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
1314 + mi_debuginfo = rpmtsInitIterator_p (ts, RPMDBI_LABEL, debuginfo, 0);
1315 + xfree (debuginfo);
1318 + rpmdbFreeIterator_p (mi_debuginfo);
1323 + /* The allocated memory gets utilized below for MISSING_RPM_HASH. */
1324 + debuginfo = headerFormat_p (h,
1325 + "%{name}-%{version}-%{release}.%{arch}",
1329 + warning (_("Error querying the rpm file `%s': %s"), filename,
1334 + /* Base package name for `debuginfo-install'. We do not use the
1335 + `yum' command directly as the line
1336 + yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
1337 + would be more complicated than just:
1338 + debuginfo-install NAME-VERSION-RELEASE.ARCH
1339 + Do not supply the rpm base name (derived from .src.rpm name) as
1340 + debuginfo-install is unable to install the debuginfo package if
1341 + the base name PKG binary rpm is not installed while for example
1342 + PKG-libs would be installed (RH Bug 467901).
1343 + FUTURE: After multiple debuginfo versions simultaneously installed
1344 + get supported the support for the VERSION-RELEASE tags handling
1345 + may need an update. */
1347 + if (missing_rpm_hash == NULL)
1349 + /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
1350 + should not deallocate the entries. */
1352 + missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
1353 + (int (*) (const void *, const void *)) streq,
1354 + NULL, xcalloc, xfree);
1356 + slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
1357 + /* XCALLOC never returns NULL. */
1358 + gdb_assert (slot != NULL);
1359 + if (*slot == NULL)
1361 + struct missing_rpm *missing_rpm;
1363 + *slot = debuginfo;
1365 + missing_rpm = xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
1366 + strcpy (missing_rpm->rpm, debuginfo);
1367 + missing_rpm->next = missing_rpm_list;
1368 + missing_rpm_list = missing_rpm;
1369 + missing_rpm_list_entries++;
1372 + xfree (debuginfo);
1376 + rpmdbFreeIterator_p (mi);
1385 +missing_rpm_list_compar (const char *const *ap, const char *const *bp)
1387 + return strcoll (*ap, *bp);
1390 +/* It returns a NULL-terminated array of strings needing to be FREEd. It may
1391 + also return only NULL. */
1394 +missing_rpm_list_print (void)
1396 + char **array, **array_iter;
1397 + struct missing_rpm *list_iter;
1398 + struct cleanup *cleanups;
1400 + if (missing_rpm_list_entries == 0)
1403 + array = xmalloc (sizeof (*array) * missing_rpm_list_entries);
1404 + cleanups = make_cleanup (xfree, array);
1406 + array_iter = array;
1407 + for (list_iter = missing_rpm_list; list_iter != NULL;
1408 + list_iter = list_iter->next)
1410 + *array_iter++ = list_iter->rpm;
1412 + gdb_assert (array_iter == array + missing_rpm_list_entries);
1414 + qsort (array, missing_rpm_list_entries, sizeof (*array),
1415 + (int (*) (const void *, const void *)) missing_rpm_list_compar);
1417 + printf_unfiltered (_("Missing separate debuginfos, use: %s"),
1418 +#ifdef DNF_DEBUGINFO_INSTALL
1421 + "debuginfo-install");
1422 + for (array_iter = array; array_iter < array + missing_rpm_list_entries;
1425 + putchar_unfiltered (' ');
1426 + puts_unfiltered (*array_iter);
1428 + putchar_unfiltered ('\n');
1430 + while (missing_rpm_list != NULL)
1432 + list_iter = missing_rpm_list;
1433 + missing_rpm_list = list_iter->next;
1434 + xfree (list_iter);
1436 + missing_rpm_list_entries = 0;
1438 + do_cleanups (cleanups);
1442 +missing_rpm_change (void)
1444 + debug_flush_missing ();
1446 + gdb_assert (missing_rpm_list == NULL);
1447 + if (missing_rpm_hash != NULL)
1449 + htab_delete (missing_rpm_hash);
1450 + missing_rpm_hash = NULL;
1456 + /* Init state. EXEC_BFD also still could be NULL. */
1457 + MISSING_EXEC_NOT_TRIED,
1458 + /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */
1459 + MISSING_EXEC_NOT_FOUND,
1460 + /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
1461 + or separate) or the main executable's RPM is now contained in
1462 + MISSING_RPM_HASH. */
1463 + MISSING_EXEC_ENLISTED
1465 +static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
1467 +#endif /* HAVE_LIBRPM */
1470 +debug_flush_missing (void)
1473 + missing_rpm_list_print ();
1477 /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
1478 - Try to install the hash file ...
1479 + yum --enablerepo='*debug*' install ...
1482 struct missing_filepair
1483 @@ -720,11 +1079,17 @@ missing_filepair_change (void)
1484 /* All their memory came just from missing_filepair_OBSTACK. */
1485 missing_filepair_hash = NULL;
1488 + missing_exec = MISSING_EXEC_NOT_TRIED;
1493 debug_print_executable_changed (void)
1496 + missing_rpm_change ();
1498 missing_filepair_change ();
1501 @@ -791,14 +1156,39 @@ debug_print_missing (const char *binary,
1503 *slot = missing_filepair;
1505 - /* We do not collect and flush these messages as each such message
1506 - already requires its own separate lines. */
1508 + if (missing_exec == MISSING_EXEC_NOT_TRIED)
1510 + char *execfilename;
1512 - fprintf_unfiltered (gdb_stdlog,
1513 - _("Missing separate debuginfo for %s\n"), binary);
1514 - if (debug != NULL)
1515 - fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
1517 + execfilename = get_exec_file (0);
1518 + if (execfilename != NULL)
1520 + if (missing_rpm_enlist (execfilename) == 0)
1521 + missing_exec = MISSING_EXEC_NOT_FOUND;
1523 + missing_exec = MISSING_EXEC_ENLISTED;
1526 + if (missing_exec != MISSING_EXEC_ENLISTED)
1527 + if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
1528 + && (debug == NULL || missing_rpm_enlist (debug) == 0))
1529 +#endif /* HAVE_LIBRPM */
1531 + /* We do not collect and flush these messages as each such message
1532 + already requires its own separate lines. */
1534 + fprintf_unfiltered (gdb_stdlog,
1535 + _("Missing separate debuginfo for %s\n"), binary);
1536 + if (debug != NULL)
1537 + fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
1538 +#ifdef DNF_DEBUGINFO_INSTALL
1543 + " --enablerepo='*debug*' install", debug);
1547 /* See build-id.h. */