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