]>
Commit | Line | Data |
---|---|---|
140f8057 | 1 | Index: gdb-7.11.50.20160630/gdb/event-top.c |
3a58abaf | 2 | =================================================================== |
140f8057 JR |
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" | |
f412e1b4 | 9 | +#include "symfile.h" |
6ed6bacf | 10 | |
f412e1b4 PS |
11 | /* readline include files. */ |
12 | #include "readline/readline.h" | |
140f8057 | 13 | @@ -347,6 +348,8 @@ |
3a58abaf AM |
14 | /* Reset the nesting depth used when trace-commands is set. */ |
15 | reset_command_nest_depth (); | |
16 | ||
17 | + debug_flush_missing (); | |
18 | + | |
f727df28 KK |
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 | |
140f8057 JR |
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 | |
3a58abaf | 35 | =================================================================== |
140f8057 JR |
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 @@ | |
321e94d6 | 39 | /* build-id support. */ |
324d13e1 | 40 | extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); |
321e94d6 BS |
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") | |
3a58abaf | 44 | |
321e94d6 | 45 | /* From dwarf2read.c */ |
3a58abaf | 46 | |
140f8057 | 47 | Index: gdb-7.11.50.20160630/gdb/aclocal.m4 |
321e94d6 | 48 | =================================================================== |
140f8057 JR |
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 | |
321e94d6 BS |
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. | |
3a58abaf | 78 | + |
321e94d6 BS |
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]) | |
3a58abaf | 88 | + |
321e94d6 BS |
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 | |
3a58abaf | 103 | + |
321e94d6 BS |
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]) | |
3a58abaf | 122 | + |
321e94d6 BS |
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 | |
3a58abaf | 137 | + |
321e94d6 BS |
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 | |
3a58abaf | 148 | + |
3a58abaf | 149 | + |
321e94d6 BS |
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 | |
3a58abaf | 164 | + |
321e94d6 BS |
165 | +pkg_failed=no |
166 | +AC_MSG_CHECKING([for $1]) | |
3a58abaf | 167 | + |
321e94d6 BS |
168 | +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) |
169 | +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) | |
e5178960 | 170 | + |
321e94d6 BS |
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.]) | |
e5178960 | 174 | + |
321e94d6 BS |
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 | |
3a58abaf | 185 | + |
321e94d6 BS |
186 | + m4_default([$4], [AC_MSG_ERROR( |
187 | +[Package requirements ($2) were not met: | |
3a58abaf | 188 | + |
321e94d6 | 189 | +$$1_PKG_ERRORS |
3a58abaf | 190 | + |
321e94d6 BS |
191 | +Consider adjusting the PKG_CONFIG_PATH environment variable if you |
192 | +installed software in a non-standard prefix. | |
3a58abaf | 193 | + |
321e94d6 BS |
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. | |
3a58abaf | 202 | + |
321e94d6 | 203 | +_PKG_TEXT |
3a58abaf | 204 | + |
321e94d6 BS |
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 | |
3a58abaf | 214 | + |
3a58abaf | 215 | + |
321e94d6 BS |
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 | |
3a58abaf | 263 | + |
321e94d6 BS |
264 | +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) |
265 | +AS_VAR_COPY([$1], [pkg_cv_][$1]) | |
3a58abaf | 266 | + |
321e94d6 BS |
267 | +AS_VAR_IF([$1], [""], [$5], [$4])dnl |
268 | +])# PKG_CHECK_VAR | |
3a58abaf | 269 | + |
321e94d6 BS |
270 | # AM_AUX_DIR_EXPAND -*- Autoconf -*- |
271 | ||
272 | # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. | |
140f8057 | 273 | Index: gdb-7.11.50.20160630/gdb/config.in |
321e94d6 | 274 | =================================================================== |
140f8057 JR |
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 | |
321e94d6 BS |
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 | |
3a58abaf | 283 | + |
321e94d6 BS |
284 | /* Define to 1 if translation of program messages to the user's native |
285 | language is requested. */ | |
286 | #undef ENABLE_NLS | |
140f8057 | 287 | @@ -261,6 +264,9 @@ |
321e94d6 BS |
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 | |
3a58abaf | 293 | + |
321e94d6 BS |
294 | /* Define to 1 if you have the <libunwind-ia64.h> header file. */ |
295 | #undef HAVE_LIBUNWIND_IA64_H | |
296 | ||
140f8057 | 297 | Index: gdb-7.11.50.20160630/gdb/configure |
321e94d6 | 298 | =================================================================== |
140f8057 JR |
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 @@ | |
321e94d6 BS |
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 | |
140f8057 | 313 | @@ -814,6 +819,7 @@ |
321e94d6 BS |
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 | |
140f8057 | 321 | @@ -870,6 +876,11 @@ |
321e94d6 BS |
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' | |
140f8057 | 333 | @@ -1541,6 +1552,8 @@ |
321e94d6 BS |
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 | |
140f8057 | 342 | @@ -1595,6 +1608,13 @@ |
321e94d6 BS |
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. | |
140f8057 | 356 | @@ -5613,6 +5633,494 @@ |
321e94d6 BS |
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'). | |
3a58abaf | 375 | + |
3a58abaf | 376 | + |
321e94d6 BS |
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 | |
3a58abaf | 383 | + |
3a58abaf | 384 | + |
3a58abaf | 385 | + |
3a58abaf | 386 | + |
321e94d6 BS |
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"'"' | |
3a58abaf | 402 | + |
321e94d6 BS |
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. */ | |
3a58abaf | 416 | + |
321e94d6 BS |
417 | +#include <rpm/rpmlib.h> |
418 | +#include <dlfcn.h> | |
419 | +#include <errno.h> | |
3a58abaf | 420 | + |
321e94d6 BS |
421 | +int |
422 | +main () | |
3a58abaf | 423 | +{ |
3a58abaf | 424 | + |
321e94d6 BS |
425 | + void *h; |
426 | + const char *const *rpmverp; | |
427 | + FILE *f; | |
3a58abaf | 428 | + |
321e94d6 BS |
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); | |
3a58abaf | 450 | + |
321e94d6 BS |
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. */ | |
3a58abaf | 453 | + |
321e94d6 BS |
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; | |
3a58abaf | 464 | + |
321e94d6 BS |
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 | + } | |
3a58abaf | 492 | + |
321e94d6 BS |
493 | + ; |
494 | + return 0; | |
495 | +} | |
496 | +_ACEOF | |
497 | +if ac_fn_c_try_run "$LINENO"; then : | |
3a58abaf | 498 | + |
321e94d6 BS |
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 | |
3a58abaf | 505 | + |
321e94d6 BS |
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 | |
3a58abaf | 510 | + |
321e94d6 | 511 | + rm -f conftest.out |
3a58abaf | 512 | + |
3a58abaf | 513 | + |
3a58abaf | 514 | + |
321e94d6 | 515 | + if $HAVE_DLOPEN_LIBRPM; then |
3a58abaf | 516 | + |
321e94d6 BS |
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. */ | |
3a58abaf | 524 | + |
321e94d6 BS |
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 () | |
3a58abaf | 541 | +{ |
321e94d6 BS |
542 | + |
543 | + ; | |
544 | + return 0; | |
3a58abaf | 545 | +} |
321e94d6 BS |
546 | +_ACEOF |
547 | +if ac_fn_c_try_compile "$LINENO"; then : | |
3a58abaf | 548 | + |
321e94d6 BS |
549 | + LIBRPM_COMPAT=true |
550 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
551 | +$as_echo "yes" >&6; } | |
3a58abaf | 552 | + |
321e94d6 | 553 | +else |
3a58abaf | 554 | + |
321e94d6 BS |
555 | + LIBRPM_COMPAT=false |
556 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
557 | +$as_echo "no" >&6; } | |
a7de96f0 | 558 | + |
3a58abaf | 559 | +fi |
321e94d6 BS |
560 | +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext |
561 | + CFLAGS="$save_CFLAGS" | |
3a58abaf | 562 | + |
321e94d6 BS |
563 | + if ! $LIBRPM_COMPAT; then |
564 | + HAVE_DLOPEN_LIBRPM=false | |
565 | + fi | |
566 | + fi | |
3a58abaf | 567 | + |
321e94d6 BS |
568 | + if $HAVE_DLOPEN_LIBRPM; then |
569 | + DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' | |
3a58abaf | 570 | + |
321e94d6 BS |
571 | +cat >>confdefs.h <<_ACEOF |
572 | +#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING | |
573 | +_ACEOF | |
3a58abaf | 574 | + |
3a58abaf | 575 | + |
321e94d6 | 576 | +$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h |
3a58abaf | 577 | + |
321e94d6 BS |
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 | |
3a58abaf | 585 | + |
3a58abaf | 586 | + |
3a58abaf | 587 | + |
3a58abaf | 588 | + |
3a58abaf | 589 | + |
3a58abaf | 590 | + |
28b292e9 | 591 | + |
321e94d6 BS |
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 | |
3a58abaf | 600 | +else |
321e94d6 BS |
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 | |
3a58abaf | 620 | + |
321e94d6 BS |
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 | |
3a58abaf | 632 | + |
3a58abaf | 633 | + |
321e94d6 BS |
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 | |
3a58abaf | 663 | + |
321e94d6 BS |
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 | |
3a58abaf | 675 | + |
321e94d6 BS |
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 | |
3a58abaf | 687 | +else |
321e94d6 | 688 | + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" |
7566401a ER |
689 | +fi |
690 | + | |
321e94d6 BS |
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 | |
3a58abaf | 705 | + |
321e94d6 BS |
706 | +pkg_failed=no |
707 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5 | |
708 | +$as_echo_n "checking for RPM... " >&6; } | |
3a58abaf | 709 | + |
321e94d6 BS |
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` | |
28b292e9 | 720 | + test "x$?" != "x0" && pkg_failed=yes |
321e94d6 BS |
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` | |
28b292e9 | 737 | + test "x$?" != "x0" && pkg_failed=yes |
321e94d6 BS |
738 | +else |
739 | + pkg_failed=yes | |
740 | +fi | |
741 | + else | |
742 | + pkg_failed=untried | |
743 | +fi | |
3a58abaf | 744 | + |
3a58abaf | 745 | + |
321e94d6 BS |
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 | |
3a58abaf | 753 | +else |
321e94d6 BS |
754 | + _pkg_short_errors_supported=no |
755 | +fi | |
756 | + if test $_pkg_short_errors_supported = yes; then | |
28b292e9 | 757 | + RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1` |
321e94d6 | 758 | + else |
28b292e9 | 759 | + RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1` |
321e94d6 BS |
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 | |
3a58abaf AM |
785 | +/* end confdefs.h. */ |
786 | + | |
321e94d6 | 787 | +/* Duplicate here the declarations to verify they match "elfread.c". */ |
3a58abaf | 788 | +#include <rpm/rpmlib.h> |
321e94d6 BS |
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); | |
3a58abaf AM |
800 | + |
801 | +int | |
802 | +main () | |
803 | +{ | |
804 | + | |
321e94d6 BS |
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" | |
140f8057 | 851 | Index: gdb-7.11.50.20160630/gdb/configure.ac |
321e94d6 | 852 | =================================================================== |
140f8057 JR |
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 @@ | |
321e94d6 BS |
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; | |
3a58abaf AM |
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 | + } | |
321e94d6 | 973 | + ]]), [ |
3a58abaf AM |
974 | + DLOPEN_LIBRPM="`cat conftest.out`" |
975 | + if test "x$DLOPEN_LIBRPM" != "x"; then | |
976 | + HAVE_DLOPEN_LIBRPM=true | |
321e94d6 | 977 | + AC_MSG_RESULT($DLOPEN_LIBRPM) |
3a58abaf | 978 | + fi |
321e94d6 | 979 | + ]) |
3a58abaf AM |
980 | + rm -f conftest.out |
981 | + | |
321e94d6 BS |
982 | + m4_define([CHECK_LIBRPM_COMPAT], [ |
983 | + AC_MSG_CHECKING([rpm library API compatibility]) | |
3a58abaf AM |
984 | + # The compilation requires -Werror to verify anything. |
985 | + save_CFLAGS="$CFLAGS" | |
986 | + CFLAGS="$CFLAGS -Werror" | |
321e94d6 | 987 | + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ |
51a5ef0f | 988 | +/* Duplicate here the declarations to verify they match "elfread.c". */ |
3a58abaf AM |
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); | |
321e94d6 | 1001 | + ]]), [ |
3a58abaf | 1002 | + LIBRPM_COMPAT=true |
321e94d6 BS |
1003 | + AC_MSG_RESULT(yes) |
1004 | + ], [ | |
3a58abaf | 1005 | + LIBRPM_COMPAT=false |
321e94d6 BS |
1006 | + AC_MSG_RESULT(no) |
1007 | + ]) | |
3a58abaf | 1008 | + CFLAGS="$save_CFLAGS" |
321e94d6 | 1009 | + ]) |
3a58abaf | 1010 | + |
321e94d6 BS |
1011 | + if $HAVE_DLOPEN_LIBRPM; then |
1012 | + CHECK_LIBRPM_COMPAT | |
3a58abaf AM |
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"'"' | |
321e94d6 BS |
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.]) | |
3a58abaf | 1022 | + else |
321e94d6 | 1023 | + AC_MSG_RESULT(no) |
3a58abaf AM |
1024 | + LIBS="$save_LIBS" |
1025 | + if $DLOPEN_REQUIRE; then | |
321e94d6 | 1026 | + AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.]) |
3a58abaf | 1027 | + fi |
321e94d6 | 1028 | + PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false]) |
3a58abaf | 1029 | + |
321e94d6 BS |
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 | |
3a58abaf | 1037 | + |
321e94d6 BS |
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 | |
140f8057 | 1055 | Index: gdb-7.11.50.20160630/gdb/corelow.c |
321e94d6 | 1056 | =================================================================== |
140f8057 JR |
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 @@ | |
321e94d6 BS |
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 | ||
140f8057 | 1068 | Index: gdb-7.11.50.20160630/gdb/build-id.c |
321e94d6 | 1069 | =================================================================== |
140f8057 JR |
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 | |
324d13e1 JR |
1072 | @@ -35,6 +35,7 @@ |
1073 | #include "elf/common.h" | |
1074 | #include "elf-bfd.h" | |
321e94d6 BS |
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 | |
140f8057 | 1080 | @@ -665,8 +666,366 @@ |
321e94d6 BS |
1081 | return result; |
1082 | } | |
1083 | ||
1084 | +#ifdef HAVE_LIBRPM | |
a7de96f0 | 1085 | + |
321e94d6 BS |
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 | |
a7de96f0 | 1093 | + |
321e94d6 BS |
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. */ | |
a7de96f0 | 1096 | + |
321e94d6 | 1097 | +static struct htab *missing_rpm_hash; |
a7de96f0 | 1098 | + |
321e94d6 BS |
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 | + */ | |
3a58abaf | 1103 | + |
321e94d6 BS |
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; | |
7566401a | 1111 | + |
321e94d6 | 1112 | +/* Returns the count of newly added rpms. */ |
3a58abaf | 1113 | + |
321e94d6 BS |
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; | |
3a58abaf | 1121 | + |
321e94d6 BS |
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 */ | |
3a58abaf | 1152 | + |
321e94d6 | 1153 | + gdb_assert (filename != NULL); |
3a58abaf | 1154 | + |
321e94d6 BS |
1155 | + if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0) |
1156 | + return 0; | |
3a58abaf | 1157 | + |
28b292e9 AM |
1158 | + if (is_target_filename (filename)) |
1159 | + return 0; | |
1160 | + | |
321e94d6 BS |
1161 | + if (filename[0] != '/') |
1162 | + { | |
1163 | + warning (_("Ignoring non-absolute filename: <%s>"), filename); | |
1164 | + return 0; | |
1165 | + } | |
3a58abaf | 1166 | + |
321e94d6 BS |
1167 | + if (!rpm_init_done) |
1168 | + { | |
1169 | + static int init_tried; | |
3a58abaf | 1170 | + |
321e94d6 BS |
1171 | + /* Already failed the initialization before? */ |
1172 | + if (init_tried) | |
1173 | + return 0; | |
1174 | + init_tried = 1; | |
3a58abaf | 1175 | + |
321e94d6 BS |
1176 | +#ifdef DLOPEN_LIBRPM |
1177 | + { | |
1178 | + void *h; | |
3a58abaf | 1179 | + |
321e94d6 BS |
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 | + } | |
3a58abaf | 1188 | + |
140f8057 JR |
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")))) | |
321e94d6 BS |
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 */ | |
3a58abaf | 1207 | + |
321e94d6 BS |
1208 | + if (rpmReadConfigFiles_p (NULL, NULL) != 0) |
1209 | + { | |
1210 | + warning (_("Error reading the rpm configuration files")); | |
1211 | + return 0; | |
1212 | + } | |
3a58abaf | 1213 | + |
321e94d6 BS |
1214 | + rpm_init_done = 1; |
1215 | + } | |
3a58abaf | 1216 | + |
321e94d6 | 1217 | + ts = rpmtsCreate_p (); |
3a58abaf | 1218 | + |
321e94d6 BS |
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; | |
3a58abaf | 1230 | + |
321e94d6 BS |
1231 | + h = rpmdbNextIterator_p (mi); |
1232 | + if (h == NULL) | |
1233 | + break; | |
3a58abaf | 1234 | + |
321e94d6 | 1235 | + /* Verify the debuginfo file is not already installed. */ |
3a58abaf | 1236 | + |
321e94d6 BS |
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}' */ | |
140f8057 | 1251 | + s2 = (char *) memrchr (debuginfo, '-', s - debuginfo); |
321e94d6 BS |
1252 | + } |
1253 | + if (s2) | |
1254 | + { | |
1255 | + /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */ | |
140f8057 | 1256 | + s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo); |
321e94d6 BS |
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}' */ | |
3a58abaf | 1276 | + |
321e94d6 BS |
1277 | + /* RPMDBI_PACKAGES requires keylen == sizeof (int). */ |
1278 | + /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */ | |
140f8057 | 1279 | + mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0); |
321e94d6 BS |
1280 | + xfree (debuginfo); |
1281 | + if (mi_debuginfo) | |
1282 | + { | |
1283 | + rpmdbFreeIterator_p (mi_debuginfo); | |
1284 | + count = 0; | |
1285 | + break; | |
1286 | + } | |
3a58abaf | 1287 | + |
321e94d6 BS |
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 | + } | |
3a58abaf | 1298 | + |
321e94d6 BS |
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. */ | |
3a58abaf | 1311 | + |
321e94d6 BS |
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. */ | |
3a58abaf | 1316 | + |
321e94d6 BS |
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; | |
3a58abaf | 1327 | + |
321e94d6 | 1328 | + *slot = debuginfo; |
6ed6bacf | 1329 | + |
140f8057 | 1330 | + missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo)); |
321e94d6 BS |
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 | + } | |
3a58abaf | 1340 | + |
321e94d6 BS |
1341 | + rpmdbFreeIterator_p (mi); |
1342 | + } | |
3a58abaf | 1343 | + |
321e94d6 | 1344 | + rpmtsFree_p (ts); |
3a58abaf | 1345 | + |
321e94d6 BS |
1346 | + return count; |
1347 | +} | |
3a58abaf | 1348 | + |
321e94d6 BS |
1349 | +static int |
1350 | +missing_rpm_list_compar (const char *const *ap, const char *const *bp) | |
1351 | +{ | |
1352 | + return strcoll (*ap, *bp); | |
1353 | +} | |
3a58abaf | 1354 | + |
321e94d6 BS |
1355 | +/* It returns a NULL-terminated array of strings needing to be FREEd. It may |
1356 | + also return only NULL. */ | |
3a58abaf | 1357 | + |
321e94d6 BS |
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; | |
3a58abaf | 1364 | + |
321e94d6 BS |
1365 | + if (missing_rpm_list_entries == 0) |
1366 | + return; | |
3a58abaf | 1367 | + |
140f8057 | 1368 | + array = (char **) xmalloc (sizeof (*array) * missing_rpm_list_entries); |
321e94d6 | 1369 | + cleanups = make_cleanup (xfree, array); |
3a58abaf | 1370 | + |
321e94d6 BS |
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); | |
3a58abaf | 1378 | + |
321e94d6 BS |
1379 | + qsort (array, missing_rpm_list_entries, sizeof (*array), |
1380 | + (int (*) (const void *, const void *)) missing_rpm_list_compar); | |
3a58abaf | 1381 | + |
321e94d6 | 1382 | + printf_unfiltered (_("Missing separate debuginfos, use: %s"), |
324d13e1 JR |
1383 | +#ifdef DNF_DEBUGINFO_INSTALL |
1384 | + "dnf " | |
1385 | +#endif | |
321e94d6 BS |
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'); | |
3a58abaf | 1394 | + |
321e94d6 BS |
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. */ | |
3a58abaf | 1446 | |
321e94d6 | 1447 | struct missing_filepair |
140f8057 | 1448 | @@ -720,11 +1079,17 @@ |
321e94d6 BS |
1449 | /* All their memory came just from missing_filepair_OBSTACK. */ |
1450 | missing_filepair_hash = NULL; | |
e5178960 | 1451 | } |
321e94d6 BS |
1452 | +#ifdef HAVE_LIBRPM |
1453 | + missing_exec = MISSING_EXEC_NOT_TRIED; | |
1454 | +#endif | |
1455 | } | |
e5178960 | 1456 | |
321e94d6 BS |
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 | ||
140f8057 | 1466 | @@ -791,14 +1156,39 @@ |
321e94d6 BS |
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"), | |
324d13e1 JR |
1503 | +#ifdef DNF_DEBUGINFO_INSTALL |
1504 | + "dnf" | |
1505 | +#else | |
1506 | + "yum" | |
1507 | +#endif | |
1508 | + " --enablerepo='*debug*' install", debug); | |
321e94d6 BS |
1509 | + } |
1510 | } | |
e5178960 | 1511 | |
321e94d6 | 1512 | /* See build-id.h. */ |