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