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