1 From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2 From: Kevin Buettner <kevinb@redhat.com>
3 Date: Wed, 22 Feb 2023 22:30:40 -0700
4 Subject: gdb-6.6-buildid-locate-rpm.patch
8 diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
12 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
16 +# serial 1 (pkg-config-0.24)
18 +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
20 +# This program is free software; you can redistribute it and/or modify
21 +# it under the terms of the GNU General Public License as published by
22 +# the Free Software Foundation; either version 2 of the License, or
23 +# (at your option) any later version.
25 +# This program is distributed in the hope that it will be useful, but
26 +# WITHOUT ANY WARRANTY; without even the implied warranty of
27 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 +# General Public License for more details.
30 +# You should have received a copy of the GNU General Public License
31 +# along with this program; if not, write to the Free Software
32 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 +# As a special exception to the GNU General Public License, if you
35 +# distribute this file as part of a program that contains a
36 +# configuration script generated by Autoconf, you may include it under
37 +# the same distribution terms that you use for the rest of that program.
39 +# PKG_PROG_PKG_CONFIG([MIN-VERSION])
40 +# ----------------------------------
41 +AC_DEFUN([PKG_PROG_PKG_CONFIG],
42 +[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
43 +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
44 +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
45 +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
46 +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
47 +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
49 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
50 + AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
52 +if test -n "$PKG_CONFIG"; then
53 + _pkg_min_version=m4_default([$1], [0.9.0])
54 + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
55 + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
56 + AC_MSG_RESULT([yes])
62 +])# PKG_PROG_PKG_CONFIG
64 +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
66 +# Check to see whether a particular set of modules exists. Similar
67 +# to PKG_CHECK_MODULES(), but does not set variables or print errors.
69 +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
70 +# only at the first occurence in configure.ac, so if the first place
71 +# it's called might be skipped (such as if it is within an "if", you
72 +# have to call PKG_CHECK_EXISTS manually
73 +# --------------------------------------------------------------
74 +AC_DEFUN([PKG_CHECK_EXISTS],
75 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
76 +if test -n "$PKG_CONFIG" && \
77 + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
78 + m4_default([$2], [:])
79 +m4_ifvaln([$3], [else
83 +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
84 +# ---------------------------------------------
85 +m4_define([_PKG_CONFIG],
86 +[if test -n "$$1"; then
88 + elif test -n "$PKG_CONFIG"; then
89 + PKG_CHECK_EXISTS([$3],
90 + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
91 + test "x$?" != "x0" && pkg_failed=yes ],
98 +# _PKG_SHORT_ERRORS_SUPPORTED
99 +# -----------------------------
100 +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
101 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
102 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
103 + _pkg_short_errors_supported=yes
105 + _pkg_short_errors_supported=no
107 +])# _PKG_SHORT_ERRORS_SUPPORTED
110 +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
111 +# [ACTION-IF-NOT-FOUND])
114 +# Note that if there is a possibility the first call to
115 +# PKG_CHECK_MODULES might not happen, you should be sure to include an
116 +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
119 +# --------------------------------------------------------------
120 +AC_DEFUN([PKG_CHECK_MODULES],
121 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
122 +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
123 +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
126 +AC_MSG_CHECKING([for $1])
128 +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
129 +_PKG_CONFIG([$1][_LIBS], [libs], [$2])
131 +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
132 +and $1[]_LIBS to avoid the need to call pkg-config.
133 +See the pkg-config man page for more details.])
135 +if test $pkg_failed = yes; then
136 + AC_MSG_RESULT([no])
137 + _PKG_SHORT_ERRORS_SUPPORTED
138 + if test $_pkg_short_errors_supported = yes; then
139 + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
141 + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
143 + # Put the nasty error message in config.log where it belongs
144 + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
146 + m4_default([$4], [AC_MSG_ERROR(
147 +[Package requirements ($2) were not met:
151 +Consider adjusting the PKG_CONFIG_PATH environment variable if you
152 +installed software in a non-standard prefix.
156 +elif test $pkg_failed = untried; then
157 + AC_MSG_RESULT([no])
158 + m4_default([$4], [AC_MSG_FAILURE(
159 +[The pkg-config script could not be found or is too old. Make sure it
160 +is in your PATH or set the PKG_CONFIG environment variable to the full
165 +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
168 + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
169 + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
170 + AC_MSG_RESULT([yes])
173 +])# PKG_CHECK_MODULES
176 +# PKG_INSTALLDIR(DIRECTORY)
177 +# -------------------------
178 +# Substitutes the variable pkgconfigdir as the location where a module
179 +# should install pkg-config .pc files. By default the directory is
180 +# $libdir/pkgconfig, but the default can be changed by passing
181 +# DIRECTORY. The user can override through the --with-pkgconfigdir
183 +AC_DEFUN([PKG_INSTALLDIR],
184 +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
185 +m4_pushdef([pkg_description],
186 + [pkg-config installation directory @<:@]pkg_default[@:>@])
187 +AC_ARG_WITH([pkgconfigdir],
188 + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
189 + [with_pkgconfigdir=]pkg_default)
190 +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
191 +m4_popdef([pkg_default])
192 +m4_popdef([pkg_description])
193 +]) dnl PKG_INSTALLDIR
196 +# PKG_NOARCH_INSTALLDIR(DIRECTORY)
197 +# -------------------------
198 +# Substitutes the variable noarch_pkgconfigdir as the location where a
199 +# module should install arch-independent pkg-config .pc files. By
200 +# default the directory is $datadir/pkgconfig, but the default can be
201 +# changed by passing DIRECTORY. The user can override through the
202 +# --with-noarch-pkgconfigdir parameter.
203 +AC_DEFUN([PKG_NOARCH_INSTALLDIR],
204 +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
205 +m4_pushdef([pkg_description],
206 + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
207 +AC_ARG_WITH([noarch-pkgconfigdir],
208 + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
209 + [with_noarch_pkgconfigdir=]pkg_default)
210 +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
211 +m4_popdef([pkg_default])
212 +m4_popdef([pkg_description])
213 +]) dnl PKG_NOARCH_INSTALLDIR
216 +# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
217 +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
218 +# -------------------------------------------
219 +# Retrieves the value of the pkg-config variable for the given module.
220 +AC_DEFUN([PKG_CHECK_VAR],
221 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
222 +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
224 +_PKG_CONFIG([$1], [variable="][$3]["], [$2])
225 +AS_VAR_COPY([$1], [pkg_cv_][$1])
227 +AS_VAR_IF([$1], [""], [$5], [$4])dnl
230 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
232 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
234 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
235 diff --git a/gdb/build-id.c b/gdb/build-id.c
238 @@ -780,10 +780,10 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
239 static rpmts (*rpmtsCreate_p) (void);
240 extern rpmts rpmtsFree(rpmts ts);
241 static rpmts (*rpmtsFree_p) (rpmts ts);
242 - extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
243 + extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
244 const void * keyp, size_t keylen);
245 static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
247 + rpmDbiTagVal rpmtag,
250 #else /* !DLOPEN_LIBRPM */
251 @@ -838,7 +838,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
252 && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
253 && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
254 && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
255 - && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
256 + && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmDbiTagVal rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
258 warning (_("Opened library \"%s\" is incompatible (%s), "
259 "missing debuginfos notifications will not be displayed"),
260 @@ -926,7 +926,7 @@ missing_rpm_enlist_1 (const char *filename, int verify_vendor)
262 /* RPMDBI_PACKAGES requires keylen == sizeof (int). */
263 /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
264 - mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
265 + mi_debuginfo = rpmtsInitIterator_p (ts, (rpmDbiTagVal) RPMDBI_LABEL, debuginfo, 0);
269 diff --git a/gdb/config.in b/gdb/config.in
273 /* Handle .ctf type-info sections */
276 +/* librpm version specific library name to dlopen. */
277 +#undef DLOPEN_LIBRPM
279 /* Define to 1 if translation of program messages to the user's native
280 language is requested. */
283 /* Define to 1 if you have the `m' library (-lm). */
286 +/* Define if librpm library is being used. */
289 /* Define to 1 if you have the <libunwind-ia64.h> header file. */
290 #undef HAVE_LIBUNWIND_IA64_H
292 diff --git a/gdb/configure b/gdb/configure
295 @@ -778,6 +778,11 @@ AMD_DBGAPI_CFLAGS
296 ENABLE_BFD_64_BIT_FALSE
297 ENABLE_BFD_64_BIT_TRUE
307 @@ -911,6 +916,7 @@ with_gdb_datadir
308 with_relocated_sources
310 with_auto_load_safe_path
315 @@ -988,6 +994,8 @@ AMD_DBGAPI_CFLAGS
324 @@ -1679,6 +1687,8 @@ Optional Packages:
325 --with-amd-dbgapi support for the amd-dbgapi target (yes / no / auto)
326 --with-debuginfod Enable debuginfo lookups with debuginfod
328 + --with-rpm query rpm database for missing debuginfos (yes/no,
329 + def. auto=librpm.so)
330 --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
331 --with-curses use the curses library instead of the termcap
333 @@ -1759,6 +1769,8 @@ Some influential environment variables:
334 C compiler flags for DEBUGINFOD, overriding pkg-config
336 linker flags for DEBUGINFOD, overriding pkg-config
337 + RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
338 + RPM_LIBS linker flags for RPM, overriding pkg-config
339 YACC The `Yet Another Compiler Compiler' implementation to use.
340 Defaults to the first program found out of: `bison -y', `byacc',
342 @@ -18039,6 +18051,495 @@ _ACEOF
343 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
344 $as_echo "$with_auto_load_safe_path" >&6; }
346 +# Integration with rpm library to support missing debuginfo suggestions.
347 +# --without-rpm: Disable any rpm support.
348 +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
349 +# Even with runtime missing `libname.so' GDB will still other run correctly.
350 +# Missing `libname.so' during ./configure will abort the configuration.
351 +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
352 +# minor version first such as `librpm-4.6.so' as minor version differences
353 +# mean API+ABI incompatibility. If the specific match versioned library name
354 +# could not be found still open dynamically at least `librpm.so'.
355 +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
356 +# to find librpm for compilation-time linking by pkg-config. GDB binary will
357 +# be probably linked with the version specific library (as `librpm-4.6.so').
358 +# Failure to find librpm by pkg-config will abort the configuration.
359 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
360 +# cannot find librpm use to the rpmless compilation (like `--without-rpm').
363 +# Check whether --with-rpm was given.
364 +if test "${with_rpm+set}" = set; then :
373 +if test "x$with_rpm" != "xno"; then
374 + if test "x$with_rpm" = "xyes"; then
377 + DLOPEN_REQUIRE=false
378 + elif test "x$with_rpm" = "xauto"; then
381 + DLOPEN_REQUIRE=false
385 + DLOPEN_REQUIRE=true
387 + LIBRPM_STRING='"'"$LIBRPM"'"'
389 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
390 +$as_echo_n "checking specific librpm version... " >&6; }
391 + HAVE_DLOPEN_LIBRPM=false
394 + if test "$cross_compiling" = yes; then :
395 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
396 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
397 +as_fn_error "cannot run test program while cross compiling
398 +See \`config.log' for more details." "$LINENO" 5; }
400 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
401 +/* end confdefs.h. */
403 +#include <rpm/rpmlib.h>
413 + const char *const *rpmverp;
416 + f = fopen ("conftest.out", "w");
419 + fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
423 + h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
426 + fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
429 + rpmverp = dlsym (h, "RPMVERSION");
432 + fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
435 + fprintf (stderr, "RPMVERSION is: \"");
436 + fprintf (stderr, "%s\"\n", *rpmverp);
438 + /* Try to find the specific librpm version only for "librpm.so" as we do
439 + not know how to assemble the version string otherwise. */
441 + if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
443 + fprintf (f, "%s\n", $LIBRPM_STRING);
452 + if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
454 + fprintf (stderr, "Unable to parse RPMVERSION.\n");
455 + fprintf (f, "%s\n", $LIBRPM_STRING);
458 + /* Avoid the square brackets by malloc. */
459 + h2_name = malloc (64);
460 + sprintf (h2_name, "librpm-%d.%d.so", major, minor);
461 + h2 = dlopen (h2_name, RTLD_LAZY);
464 + fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
465 + fprintf (f, "%s\n", $LIBRPM_STRING);
470 + fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
471 + $LIBRPM_STRING, h2_name);
472 + fprintf (f, "%s\n", $LIBRPM_STRING);
475 + /* Found the valid .so name with a specific version. */
476 + fprintf (f, "%s\n", h2_name);
484 +if ac_fn_c_try_run "$LINENO"; then :
486 + DLOPEN_LIBRPM="`cat conftest.out`"
487 + if test "x$DLOPEN_LIBRPM" != "x"; then
488 + HAVE_DLOPEN_LIBRPM=true
489 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
490 +$as_echo "$DLOPEN_LIBRPM" >&6; }
494 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
495 + conftest.$ac_objext conftest.beam conftest.$ac_ext
502 + if $HAVE_DLOPEN_LIBRPM; then
504 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
505 +$as_echo_n "checking rpm library API compatibility... " >&6; }
506 + # The compilation requires -Werror to verify anything.
507 + save_CFLAGS="$CFLAGS"
508 + CFLAGS="$CFLAGS -Werror"
509 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
510 +/* end confdefs.h. */
512 +/* Duplicate here the declarations to verify they match "elfread.c". */
513 +#include <rpm/rpmlib.h>
514 +#include <rpm/rpmts.h>
515 +#include <rpm/rpmdb.h>
516 +#include <rpm/header.h>
517 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
518 +extern int rpmReadConfigFiles(const char * file, const char * target);
519 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
520 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
521 +extern rpmts rpmtsCreate(void);
522 +extern rpmts rpmtsFree(rpmts ts);
523 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
524 + const void * keyp, size_t keylen);
534 +if ac_fn_c_try_compile "$LINENO"; then :
537 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
538 +$as_echo "yes" >&6; }
542 + LIBRPM_COMPAT=false
543 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
544 +$as_echo "no" >&6; }
547 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
548 + CFLAGS="$save_CFLAGS"
550 + if ! $LIBRPM_COMPAT; then
551 + HAVE_DLOPEN_LIBRPM=false
555 + if $HAVE_DLOPEN_LIBRPM; then
556 + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
558 +cat >>confdefs.h <<_ACEOF
559 +#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
563 +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
566 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
567 +$as_echo "no" >&6; }
569 + if $DLOPEN_REQUIRE; then
570 + as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
579 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
580 + if test -n "$ac_tool_prefix"; then
581 + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
582 +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
583 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
584 +$as_echo_n "checking for $ac_word... " >&6; }
585 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
586 + $as_echo_n "(cached) " >&6
588 + case $PKG_CONFIG in
590 + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
593 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
597 + test -z "$as_dir" && as_dir=.
598 + for ac_exec_ext in '' $ac_executable_extensions; do
599 + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
600 + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
601 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
611 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
612 +if test -n "$PKG_CONFIG"; then
613 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
614 +$as_echo "$PKG_CONFIG" >&6; }
616 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
617 +$as_echo "no" >&6; }
622 +if test -z "$ac_cv_path_PKG_CONFIG"; then
623 + ac_pt_PKG_CONFIG=$PKG_CONFIG
624 + # Extract the first word of "pkg-config", so it can be a program name with args.
625 +set dummy pkg-config; ac_word=$2
626 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
627 +$as_echo_n "checking for $ac_word... " >&6; }
628 +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
629 + $as_echo_n "(cached) " >&6
631 + case $ac_pt_PKG_CONFIG in
633 + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
636 + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
640 + test -z "$as_dir" && as_dir=.
641 + for ac_exec_ext in '' $ac_executable_extensions; do
642 + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
643 + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
644 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
654 +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
655 +if test -n "$ac_pt_PKG_CONFIG"; then
656 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
657 +$as_echo "$ac_pt_PKG_CONFIG" >&6; }
659 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
660 +$as_echo "no" >&6; }
663 + if test "x$ac_pt_PKG_CONFIG" = x; then
666 + case $cross_compiling:$ac_tool_warned in
668 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
669 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
670 +ac_tool_warned=yes ;;
672 + PKG_CONFIG=$ac_pt_PKG_CONFIG
675 + PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
679 +if test -n "$PKG_CONFIG"; then
680 + _pkg_min_version=0.9.0
681 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
682 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
683 + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
684 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
685 +$as_echo "yes" >&6; }
687 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
688 +$as_echo "no" >&6; }
694 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
695 +$as_echo_n "checking for RPM... " >&6; }
697 +if test -n "$RPM_CFLAGS"; then
698 + pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
699 + elif test -n "$PKG_CONFIG"; then
700 + if test -n "$PKG_CONFIG" && \
701 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
702 + ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
704 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
705 + test $ac_status = 0; }; then
706 + pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
707 + test "x$?" != "x0" && pkg_failed=yes
714 +if test -n "$RPM_LIBS"; then
715 + pkg_cv_RPM_LIBS="$RPM_LIBS"
716 + elif test -n "$PKG_CONFIG"; then
717 + if test -n "$PKG_CONFIG" && \
718 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
719 + ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
721 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
722 + test $ac_status = 0; }; then
723 + pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
724 + test "x$?" != "x0" && pkg_failed=yes
734 +if test $pkg_failed = yes; then
735 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
736 +$as_echo "no" >&6; }
738 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
739 + _pkg_short_errors_supported=yes
741 + _pkg_short_errors_supported=no
743 + if test $_pkg_short_errors_supported = yes; then
744 + RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
746 + RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
748 + # Put the nasty error message in config.log where it belongs
749 + echo "$RPM_PKG_ERRORS" >&5
752 +elif test $pkg_failed = untried; then
753 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
754 +$as_echo "no" >&6; }
757 + RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
758 + RPM_LIBS=$pkg_cv_RPM_LIBS
759 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
760 +$as_echo "yes" >&6; }
764 + if $HAVE_LIBRPM; then
766 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
767 +$as_echo_n "checking rpm library API compatibility... " >&6; }
768 + # The compilation requires -Werror to verify anything.
769 + save_CFLAGS="$CFLAGS"
770 + CFLAGS="$CFLAGS -Werror"
771 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
772 +/* end confdefs.h. */
774 +/* Duplicate here the declarations to verify they match "elfread.c". */
775 +#include <rpm/rpmlib.h>
776 +#include <rpm/rpmts.h>
777 +#include <rpm/rpmdb.h>
778 +#include <rpm/header.h>
779 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
780 +extern int rpmReadConfigFiles(const char * file, const char * target);
781 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
782 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
783 +extern rpmts rpmtsCreate(void);
784 +extern rpmts rpmtsFree(rpmts ts);
785 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
786 + const void * keyp, size_t keylen);
796 +if ac_fn_c_try_compile "$LINENO"; then :
799 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
800 +$as_echo "yes" >&6; }
804 + LIBRPM_COMPAT=false
805 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
806 +$as_echo "no" >&6; }
809 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
810 + CFLAGS="$save_CFLAGS"
812 + if ! $LIBRPM_COMPAT; then
814 + RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
818 + if $HAVE_LIBRPM; then
820 +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
822 + CFLAGS="$CFLAGS $RPM_CFLAGS"
823 + LIBS="$LIBS $RPM_LIBS"
825 + if $RPM_REQUIRE; then
826 + as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
828 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
829 +$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
837 subdirs="$subdirs testsuite"
838 diff --git a/gdb/configure.ac b/gdb/configure.ac
839 --- a/gdb/configure.ac
840 +++ b/gdb/configure.ac
841 @@ -173,6 +173,200 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
842 [Directories safe to hold auto-loaded files.])
843 AC_MSG_RESULT([$with_auto_load_safe_path])
845 +# Integration with rpm library to support missing debuginfo suggestions.
846 +# --without-rpm: Disable any rpm support.
847 +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
848 +# Even with runtime missing `libname.so' GDB will still other run correctly.
849 +# Missing `libname.so' during ./configure will abort the configuration.
850 +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
851 +# minor version first such as `librpm-4.6.so' as minor version differences
852 +# mean API+ABI incompatibility. If the specific match versioned library name
853 +# could not be found still open dynamically at least `librpm.so'.
854 +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
855 +# to find librpm for compilation-time linking by pkg-config. GDB binary will
856 +# be probably linked with the version specific library (as `librpm-4.6.so').
857 +# Failure to find librpm by pkg-config will abort the configuration.
858 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
859 +# cannot find librpm use to the rpmless compilation (like `--without-rpm').
862 + [AS_HELP_STRING([--with-rpm],
863 + [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
865 +m4_pattern_allow([^AC_MSG_ERROR$])
866 +m4_pattern_allow([^AC_MSG_WARN$])
867 +if test "x$with_rpm" != "xno"; then
868 + if test "x$with_rpm" = "xyes"; then
871 + DLOPEN_REQUIRE=false
872 + elif test "x$with_rpm" = "xauto"; then
875 + DLOPEN_REQUIRE=false
879 + DLOPEN_REQUIRE=true
881 + LIBRPM_STRING='"'"$LIBRPM"'"'
883 + AC_MSG_CHECKING([specific librpm version])
884 + HAVE_DLOPEN_LIBRPM=false
887 + AC_RUN_IFELSE(AC_LANG_PROGRAM([[
888 +#include <rpm/rpmlib.h>
894 + const char *const *rpmverp;
897 + f = fopen ("conftest.out", "w");
900 + fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
904 + h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
907 + fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
910 + rpmverp = dlsym (h, "RPMVERSION");
913 + fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
916 + fprintf (stderr, "RPMVERSION is: \"");
917 + fprintf (stderr, "%s\"\n", *rpmverp);
919 + /* Try to find the specific librpm version only for "librpm.so" as we do
920 + not know how to assemble the version string otherwise. */
922 + if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
924 + fprintf (f, "%s\n", $LIBRPM_STRING);
933 + if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
935 + fprintf (stderr, "Unable to parse RPMVERSION.\n");
936 + fprintf (f, "%s\n", $LIBRPM_STRING);
939 + /* Avoid the square brackets by malloc. */
940 + h2_name = malloc (64);
941 + sprintf (h2_name, "librpm-%d.%d.so", major, minor);
942 + h2 = dlopen (h2_name, RTLD_LAZY);
945 + fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
946 + fprintf (f, "%s\n", $LIBRPM_STRING);
951 + fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
952 + $LIBRPM_STRING, h2_name);
953 + fprintf (f, "%s\n", $LIBRPM_STRING);
956 + /* Found the valid .so name with a specific version. */
957 + fprintf (f, "%s\n", h2_name);
961 + DLOPEN_LIBRPM="`cat conftest.out`"
962 + if test "x$DLOPEN_LIBRPM" != "x"; then
963 + HAVE_DLOPEN_LIBRPM=true
964 + AC_MSG_RESULT($DLOPEN_LIBRPM)
969 + m4_define([CHECK_LIBRPM_COMPAT], [
970 + AC_MSG_CHECKING([rpm library API compatibility])
971 + # The compilation requires -Werror to verify anything.
972 + save_CFLAGS="$CFLAGS"
973 + CFLAGS="$CFLAGS -Werror"
974 + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
975 +/* Duplicate here the declarations to verify they match "elfread.c". */
976 +#include <rpm/rpmlib.h>
977 +#include <rpm/rpmts.h>
978 +#include <rpm/rpmdb.h>
979 +#include <rpm/header.h>
980 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
981 +extern int rpmReadConfigFiles(const char * file, const char * target);
982 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
983 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
984 +extern rpmts rpmtsCreate(void);
985 +extern rpmts rpmtsFree(rpmts ts);
986 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
987 + const void * keyp, size_t keylen);
992 + LIBRPM_COMPAT=false
995 + CFLAGS="$save_CFLAGS"
998 + if $HAVE_DLOPEN_LIBRPM; then
999 + CHECK_LIBRPM_COMPAT
1000 + if ! $LIBRPM_COMPAT; then
1001 + HAVE_DLOPEN_LIBRPM=false
1005 + if $HAVE_DLOPEN_LIBRPM; then
1006 + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
1007 + AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
1008 + AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
1012 + if $DLOPEN_REQUIRE; then
1013 + AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
1015 + PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
1017 + if $HAVE_LIBRPM; then
1018 + CHECK_LIBRPM_COMPAT
1019 + if ! $LIBRPM_COMPAT; then
1021 + RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
1025 + if $HAVE_LIBRPM; then
1026 + AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
1027 + CFLAGS="$CFLAGS $RPM_CFLAGS"
1028 + LIBS="$LIBS $RPM_LIBS"
1030 + if $RPM_REQUIRE; then
1031 + AC_MSG_ERROR($RPM_PKG_ERRORS)
1033 + AC_MSG_WARN($RPM_PKG_ERRORS)
1039 AC_CONFIG_SUBDIRS(testsuite)
1041 # Check whether to support alternative target configurations
1042 diff --git a/gdb/event-top.c b/gdb/event-top.c
1043 --- a/gdb/event-top.c
1044 +++ b/gdb/event-top.c
1046 #include "async-event.h"
1047 #include "bt-utils.h"
1049 +#include "symfile.h"
1051 /* readline include files. */
1052 #include "readline/readline.h"
1053 @@ -404,6 +405,8 @@ display_gdb_prompt (const char *new_prompt)
1054 /* Reset the nesting depth used when trace-commands is set. */
1055 reset_command_nest_depth ();
1057 + debug_flush_missing ();
1059 /* Do not call the python hook on an explicit prompt change as
1060 passed to this function, as this forms a secondary/local prompt,
1061 IE, displayed but not set. */
1062 @@ -788,7 +791,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
1063 command_handler (cmd);
1065 if (ui->prompt_state != PROMPTED)
1066 - display_gdb_prompt (0);
1068 + debug_flush_missing ();
1069 + display_gdb_prompt (0);
1074 diff --git a/gdb/symfile.h b/gdb/symfile.h
1077 @@ -367,6 +367,7 @@ extern void generic_load (const char *args, int from_tty);
1078 /* build-id support. */
1079 extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
1080 extern void debug_print_missing (const char *binary, const char *debug);
1081 +extern void debug_flush_missing (void);
1082 #define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
1084 /* From minidebug.c. */