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