]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.6-buildid-locate-rpm.patch
libinproctrace not built on %{arm}
[packages/gdb.git] / gdb-6.6-buildid-locate-rpm.patch
1 From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2 From: Fedora GDB patches <invalid@email.com>
3 Date: Fri, 27 Oct 2017 21:07:50 +0200
4 Subject: gdb-6.6-buildid-locate-rpm.patch
5
6 ;;=push+jan
7
8 diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
9 --- a/gdb/aclocal.m4
10 +++ b/gdb/aclocal.m4
11 @@ -11,7 +11,223 @@
12  # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  # PARTICULAR PURPOSE.
14  
15 +# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
16 +# serial 1 (pkg-config-0.24)
17 +# 
18 +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
19 +#
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.
24 +#
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.
29 +#
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.
33 +#
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.
38 +
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])
48 +
49 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
50 +       AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
51 +fi
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])
57 +       else
58 +               AC_MSG_RESULT([no])
59 +               PKG_CONFIG=""
60 +       fi
61 +fi[]dnl
62 +])# PKG_PROG_PKG_CONFIG
63 +
64 +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
65 +#
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.
68 +#
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
80 +  $3])dnl
81 +fi])
82 +
83 +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
84 +# ---------------------------------------------
85 +m4_define([_PKG_CONFIG],
86 +[if test -n "$$1"; then
87 +    pkg_cv_[]$1="$$1"
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 ],
92 +                    [pkg_failed=yes])
93 + else
94 +    pkg_failed=untried
95 +fi[]dnl
96 +])# _PKG_CONFIG
97 +
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
104 +else
105 +        _pkg_short_errors_supported=no
106 +fi[]dnl
107 +])# _PKG_SHORT_ERRORS_SUPPORTED
108 +
109 +
110 +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
111 +# [ACTION-IF-NOT-FOUND])
112 +#
113 +#
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
117 +#
118 +#
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
124 +
125 +pkg_failed=no
126 +AC_MSG_CHECKING([for $1])
127 +
128 +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
129 +_PKG_CONFIG([$1][_LIBS], [libs], [$2])
130 +
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.])
134 +
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`
140 +        else 
141 +               $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
142 +        fi
143 +       # Put the nasty error message in config.log where it belongs
144 +       echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
145 +
146 +       m4_default([$4], [AC_MSG_ERROR(
147 +[Package requirements ($2) were not met:
148 +
149 +$$1_PKG_ERRORS
150 +
151 +Consider adjusting the PKG_CONFIG_PATH environment variable if you
152 +installed software in a non-standard prefix.
153 +
154 +_PKG_TEXT])[]dnl
155 +        ])
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
161 +path to pkg-config.
162 +
163 +_PKG_TEXT
164 +
165 +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
166 +        ])
167 +else
168 +       $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
169 +       $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
170 +        AC_MSG_RESULT([yes])
171 +       $3
172 +fi[]dnl
173 +])# PKG_CHECK_MODULES
174 +
175 +
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
182 +# parameter.
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
194 +
195 +
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
214 +
215 +
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
223 +
224 +_PKG_CONFIG([$1], [variable="][$3]["], [$2])
225 +AS_VAR_COPY([$1], [pkg_cv_][$1])
226 +
227 +AS_VAR_IF([$1], [""], [$5], [$4])dnl
228 +])# PKG_CHECK_VAR
229 +
230  m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
231 +
232  # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
233  
234  # Copyright (C) 2001-2017 Free Software Foundation, Inc.
235 diff --git a/gdb/build-id.c b/gdb/build-id.c
236 --- a/gdb/build-id.c
237 +++ b/gdb/build-id.c
238 @@ -33,6 +33,7 @@
239  #include "gdb_bfd.h"
240  #include "gdbcmd.h"
241  #include "gdbcore.h"
242 +#include "inferior.h"
243  #include "libbfd.h"
244  #include "objfiles.h"
245  #include "observable.h"
246 @@ -698,8 +699,359 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
247    return result;
248  }
249  
250 +#ifdef HAVE_LIBRPM
251 +
252 +#include <rpm/rpmlib.h>
253 +#include <rpm/rpmts.h>
254 +#include <rpm/rpmdb.h>
255 +#include <rpm/header.h>
256 +#ifdef DLOPEN_LIBRPM
257 +#include <dlfcn.h>
258 +#endif
259 +
260 +/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
261 +   and avoid their duplicities during a single inferior run.  */
262 +
263 +static struct htab *missing_rpm_hash;
264 +
265 +/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
266 +   all the rpms right before the nearest GDB prompt.  It gets cleared after
267 +   each such print (it is questionable if we should clear it after the print).
268 +   */
269 +
270 +struct missing_rpm
271 +  {
272 +    struct missing_rpm *next;
273 +    char rpm[1];
274 +  };
275 +static struct missing_rpm *missing_rpm_list;
276 +static int missing_rpm_list_entries;
277 +
278 +/* Returns the count of newly added rpms.  */
279 +
280 +static int
281 +missing_rpm_enlist (const char *filename)
282 +{
283 +  static int rpm_init_done = 0;
284 +  rpmts ts;
285 +  rpmdbMatchIterator mi;
286 +  int count = 0;
287 +
288 +#ifdef DLOPEN_LIBRPM
289 +  /* Duplicate here the declarations to verify they match.  The same sanity
290 +     check is present also in `configure.ac'.  */
291 +  extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
292 +  static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
293 +  extern int rpmReadConfigFiles(const char * file, const char * target);
294 +  static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
295 +  extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
296 +  static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
297 +  extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
298 +  static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
299 +  extern rpmts rpmtsCreate(void);
300 +  static rpmts (*rpmtsCreate_p) (void);
301 +  extern rpmts rpmtsFree(rpmts ts);
302 +  static rpmts (*rpmtsFree_p) (rpmts ts);
303 +  extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
304 +                                              const void * keyp, size_t keylen);
305 +  static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
306 +                                                   rpmTag rpmtag,
307 +                                                   const void *keyp,
308 +                                                   size_t keylen);
309 +#else  /* !DLOPEN_LIBRPM */
310 +# define headerFormat_p headerFormat
311 +# define rpmReadConfigFiles_p rpmReadConfigFiles
312 +# define rpmdbFreeIterator_p rpmdbFreeIterator
313 +# define rpmdbNextIterator_p rpmdbNextIterator
314 +# define rpmtsCreate_p rpmtsCreate
315 +# define rpmtsFree_p rpmtsFree
316 +# define rpmtsInitIterator_p rpmtsInitIterator
317 +#endif /* !DLOPEN_LIBRPM */
318 +
319 +  gdb_assert (filename != NULL);
320 +
321 +  if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
322 +    return 0;
323 +
324 +  if (is_target_filename (filename))
325 +    return 0;
326 +
327 +  if (filename[0] != '/')
328 +    {
329 +      warning (_("Ignoring non-absolute filename: <%s>"), filename);
330 +      return 0;
331 +    }
332 +
333 +  if (!rpm_init_done)
334 +    {
335 +      static int init_tried;
336 +
337 +      /* Already failed the initialization before?  */
338 +      if (init_tried)
339 +       return 0;
340 +      init_tried = 1;
341 +
342 +#ifdef DLOPEN_LIBRPM
343 +      {
344 +       void *h;
345 +
346 +       h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
347 +       if (!h)
348 +         {
349 +           warning (_("Unable to open \"%s\" (%s), "
350 +                     "missing debuginfos notifications will not be displayed"),
351 +                    DLOPEN_LIBRPM, dlerror ());
352 +           return 0;
353 +         }
354 +
355 +       if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat"))
356 +             && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles"))
357 +             && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator"))
358 +             && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator"))
359 +             && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate"))
360 +             && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree"))
361 +             && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator"))))
362 +         {
363 +           warning (_("Opened library \"%s\" is incompatible (%s), "
364 +                     "missing debuginfos notifications will not be displayed"),
365 +                    DLOPEN_LIBRPM, dlerror ());
366 +           if (dlclose (h))
367 +             warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
368 +                      dlerror ());
369 +           return 0;
370 +         }
371 +      }
372 +#endif /* DLOPEN_LIBRPM */
373 +
374 +      if (rpmReadConfigFiles_p (NULL, NULL) != 0)
375 +       {
376 +         warning (_("Error reading the rpm configuration files"));
377 +         return 0;
378 +       }
379 +
380 +      rpm_init_done = 1;
381 +    }
382 +
383 +  ts = rpmtsCreate_p ();
384 +
385 +  mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
386 +  if (mi != NULL)
387 +    {
388 +      for (;;)
389 +       {
390 +         Header h;
391 +         char *debuginfo, **slot, *s, *s2;
392 +         errmsg_t err;
393 +         size_t srcrpmlen = sizeof (".src.rpm") - 1;
394 +         size_t debuginfolen = sizeof ("-debuginfo") - 1;
395 +         rpmdbMatchIterator mi_debuginfo;
396 +
397 +         h = rpmdbNextIterator_p (mi);
398 +         if (h == NULL)
399 +           break;
400 +
401 +         /* Verify the debuginfo file is not already installed.  */
402 +
403 +         debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
404 +                                     &err);
405 +         if (!debuginfo)
406 +           {
407 +             warning (_("Error querying the rpm file `%s': %s"), filename,
408 +                      err);
409 +             continue;
410 +           }
411 +         /* s = `.src.rpm-debuginfo.%{arch}' */
412 +         s = strrchr (debuginfo, '-') - srcrpmlen;
413 +         s2 = NULL;
414 +         if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
415 +           {
416 +             /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
417 +             s2 = (char *) memrchr (debuginfo, '-', s - debuginfo);
418 +           }
419 +         if (s2)
420 +           {
421 +             /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
422 +             s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo);
423 +           }
424 +         if (!s2)
425 +           {
426 +             warning (_("Error querying the rpm file `%s': %s"), filename,
427 +                      debuginfo);
428 +             xfree (debuginfo);
429 +             continue;
430 +           }
431 +         /* s = `.src.rpm-debuginfo.%{arch}' */
432 +         /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
433 +         memmove (s2 + debuginfolen, s2, s - s2);
434 +         memcpy (s2, "-debuginfo", debuginfolen);
435 +         /* s = `XXXX.%{arch}' */
436 +         /* strlen ("XXXX") == srcrpmlen + debuginfolen */
437 +         /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
438 +         /* strlen ("XX") == srcrpmlen */
439 +         memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
440 +                  strlen (s + srcrpmlen + debuginfolen) + 1);
441 +         /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
442 +
443 +         /* RPMDBI_PACKAGES requires keylen == sizeof (int).  */
444 +         /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel().  */
445 +         mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0);
446 +         xfree (debuginfo);
447 +         if (mi_debuginfo)
448 +           {
449 +             rpmdbFreeIterator_p (mi_debuginfo);
450 +             count = 0;
451 +             break;
452 +           }
453 +
454 +         /* The allocated memory gets utilized below for MISSING_RPM_HASH.  */
455 +         debuginfo = headerFormat_p (h,
456 +                                     "%{name}-%{version}-%{release}.%{arch}",
457 +                                     &err);
458 +         if (!debuginfo)
459 +           {
460 +             warning (_("Error querying the rpm file `%s': %s"), filename,
461 +                      err);
462 +             continue;
463 +           }
464 +
465 +         /* Base package name for `debuginfo-install'.  We do not use the
466 +            `yum' command directly as the line
467 +                yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
468 +            would be more complicated than just:
469 +                debuginfo-install NAME-VERSION-RELEASE.ARCH
470 +            Do not supply the rpm base name (derived from .src.rpm name) as
471 +            debuginfo-install is unable to install the debuginfo package if
472 +            the base name PKG binary rpm is not installed while for example
473 +            PKG-libs would be installed (RH Bug 467901).
474 +            FUTURE: After multiple debuginfo versions simultaneously installed
475 +            get supported the support for the VERSION-RELEASE tags handling
476 +            may need an update.  */
477 +
478 +         if (missing_rpm_hash == NULL)
479 +           {
480 +             /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
481 +                should not deallocate the entries.  */
482 +
483 +             missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
484 +                              (int (*) (const void *, const void *)) streq,
485 +                                                   NULL, xcalloc, xfree);
486 +           }
487 +         slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
488 +         /* XCALLOC never returns NULL.  */
489 +         gdb_assert (slot != NULL);
490 +         if (*slot == NULL)
491 +           {
492 +             struct missing_rpm *missing_rpm;
493 +
494 +             *slot = debuginfo;
495 +
496 +             missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
497 +             strcpy (missing_rpm->rpm, debuginfo);
498 +             missing_rpm->next = missing_rpm_list;
499 +             missing_rpm_list = missing_rpm;
500 +             missing_rpm_list_entries++;
501 +           }
502 +         else
503 +           xfree (debuginfo);
504 +         count++;
505 +       }
506 +
507 +      rpmdbFreeIterator_p (mi);
508 +    }
509 +
510 +  rpmtsFree_p (ts);
511 +
512 +  return count;
513 +}
514 +
515 +static bool
516 +missing_rpm_list_compar (const char *ap, const char *bp)
517 +{
518 +  return strcoll (ap, bp) < 0;
519 +}
520 +
521 +/* It returns a NULL-terminated array of strings needing to be FREEd.  It may
522 +   also return only NULL.  */
523 +
524 +static void
525 +missing_rpm_list_print (void)
526 +{
527 +  struct missing_rpm *list_iter;
528 +
529 +  if (missing_rpm_list_entries == 0)
530 +    return;
531 +
532 +  std::vector<const char *> array (missing_rpm_list_entries);
533 +  size_t idx = 0;
534 +
535 +  for (list_iter = missing_rpm_list; list_iter != NULL;
536 +       list_iter = list_iter->next)
537 +    {
538 +      array[idx++] = list_iter->rpm;
539 +    }
540 +  gdb_assert (idx == missing_rpm_list_entries);
541 +
542 +  std::sort (array.begin (), array.end (), missing_rpm_list_compar);
543 +
544 +  printf_unfiltered (_("Missing separate debuginfos, use: %s"),
545 +#ifdef DNF_DEBUGINFO_INSTALL
546 +                    "dnf "
547 +#endif
548 +                    "debuginfo-install");
549 +  for (const char *el : array)
550 +    {
551 +      putchar_unfiltered (' ');
552 +      puts_unfiltered (el);
553 +    }
554 +  putchar_unfiltered ('\n');
555 +
556 +  while (missing_rpm_list != NULL)
557 +    {
558 +      list_iter = missing_rpm_list;
559 +      missing_rpm_list = list_iter->next;
560 +      xfree (list_iter);
561 +    }
562 +  missing_rpm_list_entries = 0;
563 +}
564 +
565 +static void
566 +missing_rpm_change (void)
567 +{
568 +  debug_flush_missing ();
569 +
570 +  gdb_assert (missing_rpm_list == NULL);
571 +  if (missing_rpm_hash != NULL)
572 +    {
573 +      htab_delete (missing_rpm_hash);
574 +      missing_rpm_hash = NULL;
575 +    }
576 +}
577 +
578 +enum missing_exec
579 +  {
580 +    /* Init state.  EXEC_BFD also still could be NULL.  */
581 +    MISSING_EXEC_NOT_TRIED,
582 +    /* We saw a non-NULL EXEC_BFD but RPM has no info about it.  */
583 +    MISSING_EXEC_NOT_FOUND,
584 +    /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
585 +       or separate) or the main executable's RPM is now contained in
586 +       MISSING_RPM_HASH.  */
587 +    MISSING_EXEC_ENLISTED
588 +  };
589 +static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
590 +
591 +#endif /* HAVE_LIBRPM */
592 +
593 +void
594 +debug_flush_missing (void)
595 +{
596 +#ifdef HAVE_LIBRPM
597 +  missing_rpm_list_print ();
598 +#endif
599 +}
600 +
601  /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
602 -     Try to install the hash file ...
603 +     yum --enablerepo='*debug*' install ...
604     avoidance.  */
605  
606  struct missing_filepair
607 @@ -753,11 +1105,17 @@ missing_filepair_change (void)
608        /* All their memory came just from missing_filepair_OBSTACK.  */
609        missing_filepair_hash = NULL;
610      }
611 +#ifdef HAVE_LIBRPM
612 +  missing_exec = MISSING_EXEC_NOT_TRIED;
613 +#endif
614  }
615  
616  static void
617  debug_print_executable_changed (void)
618  {
619 +#ifdef HAVE_LIBRPM
620 +  missing_rpm_change ();
621 +#endif
622    missing_filepair_change ();
623  }
624  
625 @@ -824,14 +1182,38 @@ debug_print_missing (const char *binary, const char *debug)
626  
627    *slot = missing_filepair;
628  
629 -  /* We do not collect and flush these messages as each such message
630 -     already requires its own separate lines.  */
631 +#ifdef HAVE_LIBRPM
632 +  if (missing_exec == MISSING_EXEC_NOT_TRIED)
633 +    {
634 +      const char *execfilename = get_exec_file (0);
635  
636 -  fprintf_unfiltered (gdb_stdlog,
637 -                     _("Missing separate debuginfo for %s\n"), binary);
638 -  if (debug != NULL)
639 -    fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
640 -                       debug);
641 +      if (execfilename != NULL)
642 +       {
643 +         if (missing_rpm_enlist (execfilename) == 0)
644 +           missing_exec = MISSING_EXEC_NOT_FOUND;
645 +         else
646 +           missing_exec = MISSING_EXEC_ENLISTED;
647 +       }
648 +    }
649 +  if (missing_exec != MISSING_EXEC_ENLISTED)
650 +    if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
651 +       && (debug == NULL || missing_rpm_enlist (debug) == 0))
652 +#endif /* HAVE_LIBRPM */
653 +      {
654 +       /* We do not collect and flush these messages as each such message
655 +          already requires its own separate lines.  */
656 +
657 +       fprintf_unfiltered (gdb_stdlog,
658 +                           _("Missing separate debuginfo for %s\n"), binary);
659 +        if (debug != NULL)
660 +         fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
661 +#ifdef DNF_DEBUGINFO_INSTALL
662 +                             "dnf"
663 +#else
664 +                             "yum"
665 +#endif
666 +                             " --enablerepo='*debug*' install", debug);
667 +      }
668  }
669  
670  /* See build-id.h.  */
671 diff --git a/gdb/config.in b/gdb/config.in
672 --- a/gdb/config.in
673 +++ b/gdb/config.in
674 @@ -36,6 +36,9 @@
675  /* Define to BFD's default target vector. */
676  #undef DEFAULT_BFD_VEC
677  
678 +/* librpm version specific library name to dlopen. */
679 +#undef DLOPEN_LIBRPM
680 +
681  /* Define to 1 if translation of program messages to the user's native
682     language is requested. */
683  #undef ENABLE_NLS
684 @@ -245,6 +248,9 @@
685  /* Define if you have the mpfr library. */
686  #undef HAVE_LIBMPFR
687  
688 +/* Define if librpm library is being used. */
689 +#undef HAVE_LIBRPM
690 +
691  /* Define to 1 if you have the <libunwind-ia64.h> header file. */
692  #undef HAVE_LIBUNWIND_IA64_H
693  
694 diff --git a/gdb/configure b/gdb/configure
695 --- a/gdb/configure
696 +++ b/gdb/configure
697 @@ -761,6 +761,11 @@ CODESIGN_CERT
698  HAVE_NATIVE_GCORE_TARGET
699  TARGET_OBS
700  subdirs
701 +RPM_LIBS
702 +RPM_CFLAGS
703 +PKG_CONFIG_LIBDIR
704 +PKG_CONFIG_PATH
705 +PKG_CONFIG
706  GDB_DATADIR
707  DEBUGDIR
708  MAKEINFO_EXTRA_FLAGS
709 @@ -864,6 +869,7 @@ with_gdb_datadir
710  with_relocated_sources
711  with_auto_load_dir
712  with_auto_load_safe_path
713 +with_rpm
714  enable_targets
715  enable_64_bit_bfd
716  enable_gdbmi
717 @@ -926,6 +932,11 @@ CCC
718  CPP
719  MAKEINFO
720  MAKEINFOFLAGS
721 +PKG_CONFIG
722 +PKG_CONFIG_PATH
723 +PKG_CONFIG_LIBDIR
724 +RPM_CFLAGS
725 +RPM_LIBS
726  YACC
727  YFLAGS
728  XMKMF'
729 @@ -1598,6 +1609,8 @@ Optional Packages:
730                            [--with-auto-load-dir]
731    --without-auto-load-safe-path
732                            do not restrict auto-loaded files locations
733 +  --with-rpm              query rpm database for missing debuginfos (yes/no,
734 +                          def. auto=librpm.so)
735    --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
736    --with-curses           use the curses library instead of the termcap
737                            library
738 @@ -1661,6 +1674,13 @@ Some influential environment variables:
739    MAKEINFO    Parent configure detects if it is of sufficient version.
740    MAKEINFOFLAGS
741                Parameters for MAKEINFO.
742 +  PKG_CONFIG  path to pkg-config utility
743 +  PKG_CONFIG_PATH
744 +              directories to add to pkg-config's search path
745 +  PKG_CONFIG_LIBDIR
746 +              path overriding pkg-config's built-in search path
747 +  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
748 +  RPM_LIBS    linker flags for RPM, overriding pkg-config
749    YACC        The `Yet Another Compiler Compiler' implementation to use.
750                Defaults to the first program found out of: `bison -y', `byacc',
751                `yacc'.
752 @@ -6587,6 +6607,494 @@ _ACEOF
753  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
754  $as_echo "$with_auto_load_safe_path" >&6; }
755  
756 +# Integration with rpm library to support missing debuginfo suggestions.
757 +# --without-rpm: Disable any rpm support.
758 +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
759 +#   Even with runtime missing `libname.so' GDB will still other run correctly.
760 +#   Missing `libname.so' during ./configure will abort the configuration.
761 +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
762 +#   minor version first such as `librpm-4.6.so' as minor version differences
763 +#   mean API+ABI incompatibility.  If the specific match versioned library name
764 +#   could not be found still open dynamically at least `librpm.so'.
765 +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
766 +#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
767 +#   be probably linked with the version specific library (as `librpm-4.6.so').
768 +#   Failure to find librpm by pkg-config will abort the configuration.
769 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
770 +#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
771 +
772 +
773 +# Check whether --with-rpm was given.
774 +if test "${with_rpm+set}" = set; then :
775 +  withval=$with_rpm;
776 +else
777 +  with_rpm="auto"
778 +fi
779 +
780 +
781 +
782 +
783 +if test "x$with_rpm" != "xno"; then
784 +  if test "x$with_rpm" = "xyes"; then
785 +    LIBRPM="librpm.so"
786 +    RPM_REQUIRE=true
787 +    DLOPEN_REQUIRE=false
788 +  elif test "x$with_rpm" = "xauto"; then
789 +    LIBRPM="librpm.so"
790 +    RPM_REQUIRE=false
791 +    DLOPEN_REQUIRE=false
792 +  else
793 +    LIBRPM="$with_rpm"
794 +    RPM_REQUIRE=true
795 +    DLOPEN_REQUIRE=true
796 +  fi
797 +  LIBRPM_STRING='"'"$LIBRPM"'"'
798 +
799 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
800 +$as_echo_n "checking specific librpm version... " >&6; }
801 +  HAVE_DLOPEN_LIBRPM=false
802 +  save_LIBS="$LIBS"
803 +  LIBS="$LIBS -ldl"
804 +  if test "$cross_compiling" = yes; then :
805 +  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
806 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
807 +as_fn_error "cannot run test program while cross compiling
808 +See \`config.log' for more details." "$LINENO" 5; }
809 +else
810 +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
811 +/* end confdefs.h.  */
812 +
813 +#include <rpm/rpmlib.h>
814 +#include <dlfcn.h>
815 +#include <errno.h>
816 +
817 +int
818 +main ()
819 +{
820 +
821 +    void *h;
822 +    const char *const *rpmverp;
823 +    FILE *f;
824 +
825 +    f = fopen ("conftest.out", "w");
826 +    if (!f)
827 +      {
828 +       fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
829 +                strerror (errno));
830 +       return 1;
831 +      }
832 +    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
833 +    if (!h)
834 +      {
835 +       fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
836 +       return 1;
837 +      }
838 +    rpmverp = dlsym (h, "RPMVERSION");
839 +    if (!rpmverp)
840 +      {
841 +       fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
842 +       return 1;
843 +      }
844 +    fprintf (stderr, "RPMVERSION is: \"");
845 +    fprintf (stderr, "%s\"\n", *rpmverp);
846 +
847 +    /* Try to find the specific librpm version only for "librpm.so" as we do
848 +       not know how to assemble the version string otherwise.  */
849 +
850 +    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
851 +      {
852 +       fprintf (f, "%s\n", $LIBRPM_STRING);
853 +       return 0;
854 +      }
855 +    else
856 +      {
857 +       char *h2_name;
858 +       void *h2;
859 +       int major, minor;
860 +
861 +       if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
862 +         {
863 +           fprintf (stderr, "Unable to parse RPMVERSION.\n");
864 +           fprintf (f, "%s\n", $LIBRPM_STRING);
865 +           return 0;
866 +         }
867 +       /* Avoid the square brackets by malloc.  */
868 +       h2_name = malloc (64);
869 +       sprintf (h2_name, "librpm-%d.%d.so", major, minor);
870 +       h2 = dlopen (h2_name, RTLD_LAZY);
871 +       if (!h2)
872 +         {
873 +           fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
874 +           fprintf (f, "%s\n", $LIBRPM_STRING);
875 +           return 0;
876 +         }
877 +       if (h2 != h)
878 +         {
879 +           fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
880 +                    $LIBRPM_STRING, h2_name);
881 +           fprintf (f, "%s\n", $LIBRPM_STRING);
882 +           return 0;
883 +         }
884 +       /* Found the valid .so name with a specific version.  */
885 +       fprintf (f, "%s\n", h2_name);
886 +       return 0;
887 +      }
888 +
889 +  ;
890 +  return 0;
891 +}
892 +_ACEOF
893 +if ac_fn_c_try_run "$LINENO"; then :
894 +
895 +    DLOPEN_LIBRPM="`cat conftest.out`"
896 +    if test "x$DLOPEN_LIBRPM" != "x"; then
897 +      HAVE_DLOPEN_LIBRPM=true
898 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
899 +$as_echo "$DLOPEN_LIBRPM" >&6; }
900 +    fi
901 +
902 +fi
903 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
904 +  conftest.$ac_objext conftest.beam conftest.$ac_ext
905 +fi
906 +
907 +  rm -f conftest.out
908 +
909 +
910 +
911 +  if $HAVE_DLOPEN_LIBRPM; then
912 +
913 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
914 +$as_echo_n "checking rpm library API compatibility... " >&6; }
915 +    # The compilation requires -Werror to verify anything.
916 +    save_CFLAGS="$CFLAGS"
917 +    CFLAGS="$CFLAGS -Werror"
918 +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
919 +/* end confdefs.h.  */
920 +
921 +/* Duplicate here the declarations to verify they match "elfread.c".  */
922 +#include <rpm/rpmlib.h>
923 +#include <rpm/rpmts.h>
924 +#include <rpm/rpmdb.h>
925 +#include <rpm/header.h>
926 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
927 +extern int rpmReadConfigFiles(const char * file, const char * target);
928 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
929 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
930 +extern rpmts rpmtsCreate(void);
931 +extern rpmts rpmtsFree(rpmts ts);
932 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
933 +                                           const void * keyp, size_t keylen);
934 +
935 +int
936 +main ()
937 +{
938 +
939 +  ;
940 +  return 0;
941 +}
942 +_ACEOF
943 +if ac_fn_c_try_compile "$LINENO"; then :
944 +
945 +      LIBRPM_COMPAT=true
946 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
947 +$as_echo "yes" >&6; }
948 +
949 +else
950 +
951 +      LIBRPM_COMPAT=false
952 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
953 +$as_echo "no" >&6; }
954 +
955 +fi
956 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
957 +    CFLAGS="$save_CFLAGS"
958 +
959 +    if ! $LIBRPM_COMPAT; then
960 +      HAVE_DLOPEN_LIBRPM=false
961 +    fi
962 +  fi
963 +
964 +  if $HAVE_DLOPEN_LIBRPM; then
965 +    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
966 +
967 +cat >>confdefs.h <<_ACEOF
968 +#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
969 +_ACEOF
970 +
971 +
972 +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
973 +
974 +  else
975 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
976 +$as_echo "no" >&6; }
977 +    LIBS="$save_LIBS"
978 +    if $DLOPEN_REQUIRE; then
979 +      as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
980 +    fi
981 +
982 +
983 +
984 +
985 +
986 +
987 +
988 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
989 +       if test -n "$ac_tool_prefix"; then
990 +  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
991 +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
992 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
993 +$as_echo_n "checking for $ac_word... " >&6; }
994 +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
995 +  $as_echo_n "(cached) " >&6
996 +else
997 +  case $PKG_CONFIG in
998 +  [\\/]* | ?:[\\/]*)
999 +  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
1000 +  ;;
1001 +  *)
1002 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1003 +for as_dir in $PATH
1004 +do
1005 +  IFS=$as_save_IFS
1006 +  test -z "$as_dir" && as_dir=.
1007 +    for ac_exec_ext in '' $ac_executable_extensions; do
1008 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
1009 +    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
1010 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
1011 +    break 2
1012 +  fi
1013 +done
1014 +  done
1015 +IFS=$as_save_IFS
1016 +
1017 +  ;;
1018 +esac
1019 +fi
1020 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
1021 +if test -n "$PKG_CONFIG"; then
1022 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
1023 +$as_echo "$PKG_CONFIG" >&6; }
1024 +else
1025 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1026 +$as_echo "no" >&6; }
1027 +fi
1028 +
1029 +
1030 +fi
1031 +if test -z "$ac_cv_path_PKG_CONFIG"; then
1032 +  ac_pt_PKG_CONFIG=$PKG_CONFIG
1033 +  # Extract the first word of "pkg-config", so it can be a program name with args.
1034 +set dummy pkg-config; ac_word=$2
1035 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
1036 +$as_echo_n "checking for $ac_word... " >&6; }
1037 +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
1038 +  $as_echo_n "(cached) " >&6
1039 +else
1040 +  case $ac_pt_PKG_CONFIG in
1041 +  [\\/]* | ?:[\\/]*)
1042 +  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
1043 +  ;;
1044 +  *)
1045 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1046 +for as_dir in $PATH
1047 +do
1048 +  IFS=$as_save_IFS
1049 +  test -z "$as_dir" && as_dir=.
1050 +    for ac_exec_ext in '' $ac_executable_extensions; do
1051 +  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
1052 +    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
1053 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
1054 +    break 2
1055 +  fi
1056 +done
1057 +  done
1058 +IFS=$as_save_IFS
1059 +
1060 +  ;;
1061 +esac
1062 +fi
1063 +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
1064 +if test -n "$ac_pt_PKG_CONFIG"; then
1065 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
1066 +$as_echo "$ac_pt_PKG_CONFIG" >&6; }
1067 +else
1068 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1069 +$as_echo "no" >&6; }
1070 +fi
1071 +
1072 +  if test "x$ac_pt_PKG_CONFIG" = x; then
1073 +    PKG_CONFIG=""
1074 +  else
1075 +    case $cross_compiling:$ac_tool_warned in
1076 +yes:)
1077 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
1078 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
1079 +ac_tool_warned=yes ;;
1080 +esac
1081 +    PKG_CONFIG=$ac_pt_PKG_CONFIG
1082 +  fi
1083 +else
1084 +  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
1085 +fi
1086 +
1087 +fi
1088 +if test -n "$PKG_CONFIG"; then
1089 +       _pkg_min_version=0.9.0
1090 +       { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
1091 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
1092 +       if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1093 +               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1094 +$as_echo "yes" >&6; }
1095 +       else
1096 +               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1097 +$as_echo "no" >&6; }
1098 +               PKG_CONFIG=""
1099 +       fi
1100 +fi
1101 +
1102 +pkg_failed=no
1103 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
1104 +$as_echo_n "checking for RPM... " >&6; }
1105 +
1106 +if test -n "$RPM_CFLAGS"; then
1107 +    pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
1108 + elif test -n "$PKG_CONFIG"; then
1109 +    if test -n "$PKG_CONFIG" && \
1110 +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
1111 +  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
1112 +  ac_status=$?
1113 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1114 +  test $ac_status = 0; }; then
1115 +  pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
1116 +                     test "x$?" != "x0" && pkg_failed=yes
1117 +else
1118 +  pkg_failed=yes
1119 +fi
1120 + else
1121 +    pkg_failed=untried
1122 +fi
1123 +if test -n "$RPM_LIBS"; then
1124 +    pkg_cv_RPM_LIBS="$RPM_LIBS"
1125 + elif test -n "$PKG_CONFIG"; then
1126 +    if test -n "$PKG_CONFIG" && \
1127 +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
1128 +  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
1129 +  ac_status=$?
1130 +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1131 +  test $ac_status = 0; }; then
1132 +  pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
1133 +                     test "x$?" != "x0" && pkg_failed=yes
1134 +else
1135 +  pkg_failed=yes
1136 +fi
1137 + else
1138 +    pkg_failed=untried
1139 +fi
1140 +
1141 +
1142 +
1143 +if test $pkg_failed = yes; then
1144 +       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1145 +$as_echo "no" >&6; }
1146 +
1147 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1148 +        _pkg_short_errors_supported=yes
1149 +else
1150 +        _pkg_short_errors_supported=no
1151 +fi
1152 +        if test $_pkg_short_errors_supported = yes; then
1153 +               RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1`
1154 +        else
1155 +               RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1`
1156 +        fi
1157 +       # Put the nasty error message in config.log where it belongs
1158 +       echo "$RPM_PKG_ERRORS" >&5
1159 +
1160 +       HAVE_LIBRPM=false
1161 +elif test $pkg_failed = untried; then
1162 +       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1163 +$as_echo "no" >&6; }
1164 +       HAVE_LIBRPM=false
1165 +else
1166 +       RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
1167 +       RPM_LIBS=$pkg_cv_RPM_LIBS
1168 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1169 +$as_echo "yes" >&6; }
1170 +       HAVE_LIBRPM=true
1171 +fi
1172 +
1173 +    if $HAVE_LIBRPM; then
1174 +
1175 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
1176 +$as_echo_n "checking rpm library API compatibility... " >&6; }
1177 +    # The compilation requires -Werror to verify anything.
1178 +    save_CFLAGS="$CFLAGS"
1179 +    CFLAGS="$CFLAGS -Werror"
1180 +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1181 +/* end confdefs.h.  */
1182 +
1183 +/* Duplicate here the declarations to verify they match "elfread.c".  */
1184 +#include <rpm/rpmlib.h>
1185 +#include <rpm/rpmts.h>
1186 +#include <rpm/rpmdb.h>
1187 +#include <rpm/header.h>
1188 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
1189 +extern int rpmReadConfigFiles(const char * file, const char * target);
1190 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
1191 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
1192 +extern rpmts rpmtsCreate(void);
1193 +extern rpmts rpmtsFree(rpmts ts);
1194 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
1195 +                                           const void * keyp, size_t keylen);
1196 +
1197 +int
1198 +main ()
1199 +{
1200 +
1201 +  ;
1202 +  return 0;
1203 +}
1204 +_ACEOF
1205 +if ac_fn_c_try_compile "$LINENO"; then :
1206 +
1207 +      LIBRPM_COMPAT=true
1208 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1209 +$as_echo "yes" >&6; }
1210 +
1211 +else
1212 +
1213 +      LIBRPM_COMPAT=false
1214 +      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1215 +$as_echo "no" >&6; }
1216 +
1217 +fi
1218 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1219 +    CFLAGS="$save_CFLAGS"
1220 +
1221 +      if ! $LIBRPM_COMPAT; then
1222 +       HAVE_LIBRPM=false
1223 +       RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
1224 +      fi
1225 +    fi
1226 +
1227 +    if $HAVE_LIBRPM; then
1228 +
1229 +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
1230 +
1231 +      CFLAGS="$CFLAGS $RPM_CFLAGS"
1232 +      LIBS="$LIBS $RPM_LIBS"
1233 +    else
1234 +      if $RPM_REQUIRE; then
1235 +       as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
1236 +      else
1237 +       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
1238 +$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
1239 +      fi
1240 +    fi
1241 +  fi
1242 +fi
1243 +
1244  
1245  
1246  subdirs="$subdirs testsuite"
1247 diff --git a/gdb/configure.ac b/gdb/configure.ac
1248 --- a/gdb/configure.ac
1249 +++ b/gdb/configure.ac
1250 @@ -144,6 +144,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
1251               [Directories safe to hold auto-loaded files.])
1252  AC_MSG_RESULT([$with_auto_load_safe_path])
1253  
1254 +# Integration with rpm library to support missing debuginfo suggestions.
1255 +# --without-rpm: Disable any rpm support.
1256 +# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
1257 +#   Even with runtime missing `libname.so' GDB will still other run correctly.
1258 +#   Missing `libname.so' during ./configure will abort the configuration.
1259 +# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
1260 +#   minor version first such as `librpm-4.6.so' as minor version differences
1261 +#   mean API+ABI incompatibility.  If the specific match versioned library name
1262 +#   could not be found still open dynamically at least `librpm.so'.
1263 +# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
1264 +#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
1265 +#   be probably linked with the version specific library (as `librpm-4.6.so').
1266 +#   Failure to find librpm by pkg-config will abort the configuration.
1267 +# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
1268 +#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
1269 +
1270 +AC_ARG_WITH([rpm],
1271 +  [AS_HELP_STRING([--with-rpm],
1272 +                  [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
1273 +
1274 +m4_pattern_allow([^AC_MSG_ERROR$])
1275 +m4_pattern_allow([^AC_MSG_WARN$])
1276 +if test "x$with_rpm" != "xno"; then
1277 +  if test "x$with_rpm" = "xyes"; then
1278 +    LIBRPM="librpm.so"
1279 +    RPM_REQUIRE=true
1280 +    DLOPEN_REQUIRE=false
1281 +  elif test "x$with_rpm" = "xauto"; then
1282 +    LIBRPM="librpm.so"
1283 +    RPM_REQUIRE=false
1284 +    DLOPEN_REQUIRE=false
1285 +  else
1286 +    LIBRPM="$with_rpm"
1287 +    RPM_REQUIRE=true
1288 +    DLOPEN_REQUIRE=true
1289 +  fi
1290 +  LIBRPM_STRING='"'"$LIBRPM"'"'
1291 +
1292 +  AC_MSG_CHECKING([specific librpm version])
1293 +  HAVE_DLOPEN_LIBRPM=false
1294 +  save_LIBS="$LIBS"
1295 +  LIBS="$LIBS -ldl"
1296 +  AC_RUN_IFELSE(AC_LANG_PROGRAM([[
1297 +#include <rpm/rpmlib.h>
1298 +#include <dlfcn.h>
1299 +#include <errno.h>
1300 +  ]], [[
1301 +    void *h;
1302 +    const char *const *rpmverp;
1303 +    FILE *f;
1304 +
1305 +    f = fopen ("conftest.out", "w");
1306 +    if (!f)
1307 +      {
1308 +       fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
1309 +                strerror (errno));
1310 +       return 1;
1311 +      }
1312 +    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
1313 +    if (!h)
1314 +      {
1315 +       fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
1316 +       return 1;
1317 +      }
1318 +    rpmverp = dlsym (h, "RPMVERSION");
1319 +    if (!rpmverp)
1320 +      {
1321 +       fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
1322 +       return 1;
1323 +      }
1324 +    fprintf (stderr, "RPMVERSION is: \"");
1325 +    fprintf (stderr, "%s\"\n", *rpmverp);
1326 +
1327 +    /* Try to find the specific librpm version only for "librpm.so" as we do
1328 +       not know how to assemble the version string otherwise.  */
1329 +
1330 +    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
1331 +      {
1332 +       fprintf (f, "%s\n", $LIBRPM_STRING);
1333 +       return 0;
1334 +      }
1335 +    else
1336 +      {
1337 +       char *h2_name;
1338 +       void *h2;
1339 +       int major, minor;
1340 +
1341 +       if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
1342 +         {
1343 +           fprintf (stderr, "Unable to parse RPMVERSION.\n");
1344 +           fprintf (f, "%s\n", $LIBRPM_STRING);
1345 +           return 0;
1346 +         }
1347 +       /* Avoid the square brackets by malloc.  */
1348 +       h2_name = malloc (64);
1349 +       sprintf (h2_name, "librpm-%d.%d.so", major, minor);
1350 +       h2 = dlopen (h2_name, RTLD_LAZY);
1351 +       if (!h2)
1352 +         {
1353 +           fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
1354 +           fprintf (f, "%s\n", $LIBRPM_STRING);
1355 +           return 0;
1356 +         }
1357 +       if (h2 != h)
1358 +         {
1359 +           fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
1360 +                    $LIBRPM_STRING, h2_name);
1361 +           fprintf (f, "%s\n", $LIBRPM_STRING);
1362 +           return 0;
1363 +         }
1364 +       /* Found the valid .so name with a specific version.  */
1365 +       fprintf (f, "%s\n", h2_name);
1366 +       return 0;
1367 +      }
1368 +  ]]), [
1369 +    DLOPEN_LIBRPM="`cat conftest.out`"
1370 +    if test "x$DLOPEN_LIBRPM" != "x"; then
1371 +      HAVE_DLOPEN_LIBRPM=true
1372 +      AC_MSG_RESULT($DLOPEN_LIBRPM)
1373 +    fi
1374 +  ])
1375 +  rm -f conftest.out
1376 +
1377 +  m4_define([CHECK_LIBRPM_COMPAT], [
1378 +    AC_MSG_CHECKING([rpm library API compatibility])
1379 +    # The compilation requires -Werror to verify anything.
1380 +    save_CFLAGS="$CFLAGS"
1381 +    CFLAGS="$CFLAGS -Werror"
1382 +    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
1383 +/* Duplicate here the declarations to verify they match "elfread.c".  */
1384 +#include <rpm/rpmlib.h>
1385 +#include <rpm/rpmts.h>
1386 +#include <rpm/rpmdb.h>
1387 +#include <rpm/header.h>
1388 +extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
1389 +extern int rpmReadConfigFiles(const char * file, const char * target);
1390 +extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
1391 +extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
1392 +extern rpmts rpmtsCreate(void);
1393 +extern rpmts rpmtsFree(rpmts ts);
1394 +extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
1395 +                                           const void * keyp, size_t keylen);
1396 +    ]]), [
1397 +      LIBRPM_COMPAT=true
1398 +      AC_MSG_RESULT(yes)
1399 +    ], [
1400 +      LIBRPM_COMPAT=false
1401 +      AC_MSG_RESULT(no)
1402 +    ])
1403 +    CFLAGS="$save_CFLAGS"
1404 +  ])
1405 +
1406 +  if $HAVE_DLOPEN_LIBRPM; then
1407 +    CHECK_LIBRPM_COMPAT
1408 +    if ! $LIBRPM_COMPAT; then
1409 +      HAVE_DLOPEN_LIBRPM=false
1410 +    fi
1411 +  fi
1412 +
1413 +  if $HAVE_DLOPEN_LIBRPM; then
1414 +    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
1415 +    AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
1416 +    AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
1417 +  else
1418 +    AC_MSG_RESULT(no)
1419 +    LIBS="$save_LIBS"
1420 +    if $DLOPEN_REQUIRE; then
1421 +      AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
1422 +    fi
1423 +    PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
1424 +
1425 +    if $HAVE_LIBRPM; then
1426 +      CHECK_LIBRPM_COMPAT
1427 +      if ! $LIBRPM_COMPAT; then
1428 +       HAVE_LIBRPM=false
1429 +       RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
1430 +      fi
1431 +    fi
1432 +
1433 +    if $HAVE_LIBRPM; then
1434 +      AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
1435 +      CFLAGS="$CFLAGS $RPM_CFLAGS"
1436 +      LIBS="$LIBS $RPM_LIBS"
1437 +    else
1438 +      if $RPM_REQUIRE; then
1439 +       AC_MSG_ERROR($RPM_PKG_ERRORS)
1440 +      else
1441 +       AC_MSG_WARN($RPM_PKG_ERRORS)
1442 +      fi
1443 +    fi
1444 +  fi
1445 +fi
1446
1447  AC_CONFIG_SUBDIRS(testsuite)
1448  
1449  # Check whether to support alternative target configurations
1450 diff --git a/gdb/event-top.c b/gdb/event-top.c
1451 --- a/gdb/event-top.c
1452 +++ b/gdb/event-top.c
1453 @@ -41,6 +41,7 @@
1454  #include "ser-event.h"
1455  #include "gdb_select.h"
1456  #include "gdbsupport/gdb-sigmask.h"
1457 +#include "symfile.h"
1458  
1459  /* readline include files.  */
1460  #include "readline/readline.h"
1461 @@ -363,6 +364,8 @@ display_gdb_prompt (const char *new_prompt)
1462    /* Reset the nesting depth used when trace-commands is set.  */
1463    reset_command_nest_depth ();
1464  
1465 +  debug_flush_missing ();
1466 +
1467    /* Do not call the python hook on an explicit prompt change as
1468       passed to this function, as this forms a secondary/local prompt,
1469       IE, displayed but not set.  */
1470 @@ -772,7 +775,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
1471        command_handler (cmd);
1472  
1473        if (ui->prompt_state != PROMPTED)
1474 -       display_gdb_prompt (0);
1475 +       {
1476 +         debug_flush_missing ();
1477 +         display_gdb_prompt (0);
1478 +       }
1479      }
1480  }
1481  
1482 diff --git a/gdb/symfile.h b/gdb/symfile.h
1483 --- a/gdb/symfile.h
1484 +++ b/gdb/symfile.h
1485 @@ -542,6 +542,8 @@ extern void generic_load (const char *args, int from_tty);
1486  /* build-id support.  */
1487  extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
1488  extern void debug_print_missing (const char *binary, const char *debug);
1489 +extern void debug_flush_missing (void);
1490 +#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
1491  
1492  /* From dwarf2read.c */
1493  
This page took 0.147531 seconds and 3 git commands to generate.