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