Blame SOURCES/gdb-6.6-buildid-locate-rpm.patch

2c2fa1
Index: gdb-7.6/gdb/event-top.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/event-top.c	2013-01-31 19:37:37.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/event-top.c	2013-07-17 19:51:02.679357656 +0200
2c2fa1
@@ -36,6 +36,7 @@
2c2fa1
 #include "continuations.h"
2c2fa1
 #include "gdbcmd.h"		/* for dont_repeat() */
2c2fa1
 #include "annotate.h"
2c2fa1
+#include "symfile.h"
2c2fa1
 
2c2fa1
 /* readline include files.  */
2c2fa1
 #include "readline/readline.h"
2c2fa1
@@ -170,6 +171,8 @@ rl_callback_read_char_wrapper (gdb_clien
2c2fa1
 void
2c2fa1
 cli_command_loop (void)
2c2fa1
 {
2c2fa1
+  debug_flush_missing ();
2c2fa1
+
2c2fa1
   display_gdb_prompt (0);
2c2fa1
 
2c2fa1
   /* Now it's time to start the event loop.  */
2c2fa1
@@ -237,6 +240,8 @@ display_gdb_prompt (char *new_prompt)
2c2fa1
   /* Reset the nesting depth used when trace-commands is set.  */
2c2fa1
   reset_command_nest_depth ();
2c2fa1
 
2c2fa1
+  debug_flush_missing ();
2c2fa1
+
2c2fa1
   /* Each interpreter has its own rules on displaying the command
2c2fa1
      prompt.  */
2c2fa1
   if (!current_interp_display_prompt_p ())
2c2fa1
Index: gdb-7.6/gdb/elfread.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/elfread.c	2013-07-17 19:51:02.639357629 +0200
2c2fa1
+++ gdb-7.6/gdb/elfread.c	2013-07-17 19:51:50.738390068 +0200
2c2fa1
@@ -49,6 +49,7 @@
2c2fa1
 #include "gdbcore.h"
2c2fa1
 #include "gdbcmd.h"
2c2fa1
 #include "observer.h"
2c2fa1
+#include "elf/external.h"
2c2fa1
 #include <sys/stat.h>
2c2fa1
 
2c2fa1
 extern void _initialize_elfread (void);
2c2fa1
@@ -1682,8 +1683,360 @@ build_id_to_filename (const struct elf_b
2c2fa1
   return retval;
2c2fa1
 }
2c2fa1
 
2c2fa1
+#ifdef HAVE_LIBRPM
2c2fa1
+
2c2fa1
+#include <rpm/rpmlib.h>
2c2fa1
+#include <rpm/rpmts.h>
2c2fa1
+#include <rpm/rpmdb.h>
2c2fa1
+#include <rpm/header.h>
2c2fa1
+#ifdef DLOPEN_LIBRPM
2c2fa1
+#include <dlfcn.h>
2c2fa1
+#endif
2c2fa1
+
2c2fa1
+/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
2c2fa1
+   and avoid their duplicities during a single inferior run.  */
2c2fa1
+
2c2fa1
+static struct htab *missing_rpm_hash;
2c2fa1
+
2c2fa1
+/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
2c2fa1
+   all the rpms right before the nearest GDB prompt.  It gets cleared after
2c2fa1
+   each such print (it is questionable if we should clear it after the print).
2c2fa1
+   */
2c2fa1
+
2c2fa1
+struct missing_rpm
2c2fa1
+  {
2c2fa1
+    struct missing_rpm *next;
2c2fa1
+    char rpm[1];
2c2fa1
+  };
2c2fa1
+static struct missing_rpm *missing_rpm_list;
2c2fa1
+static int missing_rpm_list_entries;
2c2fa1
+
2c2fa1
+/* Returns the count of newly added rpms.  */
2c2fa1
+
2c2fa1
+static int
2c2fa1
+missing_rpm_enlist (const char *filename)
2c2fa1
+{
2c2fa1
+  static int rpm_init_done = 0;
2c2fa1
+  rpmts ts;
2c2fa1
+  rpmdbMatchIterator mi;
2c2fa1
+  int count = 0;
2c2fa1
+
2c2fa1
+#ifdef DLOPEN_LIBRPM
2c2fa1
+  /* Duplicate here the declarations to verify they match.  The same sanity
2c2fa1
+     check is present also in `configure.ac'.  */
2c2fa1
+  extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
2c2fa1
+  static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
2c2fa1
+  extern int rpmReadConfigFiles(const char * file, const char * target);
2c2fa1
+  static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
2c2fa1
+  extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
2c2fa1
+  static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
2c2fa1
+  extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
2c2fa1
+  static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
2c2fa1
+  extern rpmts rpmtsCreate(void);
2c2fa1
+  static rpmts (*rpmtsCreate_p) (void);
2c2fa1
+  extern rpmts rpmtsFree(rpmts ts);
2c2fa1
+  static rpmts (*rpmtsFree_p) (rpmts ts);
2c2fa1
+  extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
2c2fa1
+                                              const void * keyp, size_t keylen);
2c2fa1
+  static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
2c2fa1
+						    rpmTag rpmtag,
2c2fa1
+						    const void *keyp,
2c2fa1
+						    size_t keylen);
2c2fa1
+#else	/* !DLOPEN_LIBRPM */
2c2fa1
+# define headerFormat_p headerFormat
2c2fa1
+# define rpmReadConfigFiles_p rpmReadConfigFiles
2c2fa1
+# define rpmdbFreeIterator_p rpmdbFreeIterator
2c2fa1
+# define rpmdbNextIterator_p rpmdbNextIterator
2c2fa1
+# define rpmtsCreate_p rpmtsCreate
2c2fa1
+# define rpmtsFree_p rpmtsFree
2c2fa1
+# define rpmtsInitIterator_p rpmtsInitIterator
2c2fa1
+#endif	/* !DLOPEN_LIBRPM */
2c2fa1
+
2c2fa1
+  gdb_assert (filename != NULL);
2c2fa1
+
2c2fa1
+  if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  if (filename[0] != '/')
2c2fa1
+    {
2c2fa1
+      warning (_("Ignoring non-absolute filename: <%s>"), filename);
2c2fa1
+      return 0;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  if (!rpm_init_done)
2c2fa1
+    {
2c2fa1
+      static int init_tried;
2c2fa1
+
2c2fa1
+      /* Already failed the initialization before?  */
2c2fa1
+      if (init_tried)
2c2fa1
+      	return 0;
2c2fa1
+      init_tried = 1;
2c2fa1
+
2c2fa1
+#ifdef DLOPEN_LIBRPM
2c2fa1
+      {
2c2fa1
+	void *h;
2c2fa1
+
2c2fa1
+	h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
2c2fa1
+	if (!h)
2c2fa1
+	  {
2c2fa1
+	    warning (_("Unable to open \"%s\" (%s), "
2c2fa1
+		      "missing debuginfos notifications will not be displayed"),
2c2fa1
+		     DLOPEN_LIBRPM, dlerror ());
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+
2c2fa1
+	if (!((headerFormat_p = dlsym (h, "headerFormat"))
2c2fa1
+	      && (rpmReadConfigFiles_p = dlsym (h, "rpmReadConfigFiles"))
2c2fa1
+	      && (rpmdbFreeIterator_p = dlsym (h, "rpmdbFreeIterator"))
2c2fa1
+	      && (rpmdbNextIterator_p = dlsym (h, "rpmdbNextIterator"))
2c2fa1
+	      && (rpmtsCreate_p = dlsym (h, "rpmtsCreate"))
2c2fa1
+	      && (rpmtsFree_p = dlsym (h, "rpmtsFree"))
2c2fa1
+	      && (rpmtsInitIterator_p = dlsym (h, "rpmtsInitIterator"))))
2c2fa1
+	  {
2c2fa1
+	    warning (_("Opened library \"%s\" is incompatible (%s), "
2c2fa1
+		      "missing debuginfos notifications will not be displayed"),
2c2fa1
+		     DLOPEN_LIBRPM, dlerror ());
2c2fa1
+	    if (dlclose (h))
2c2fa1
+	      warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
2c2fa1
+		       dlerror ());
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+      }
2c2fa1
+#endif	/* DLOPEN_LIBRPM */
2c2fa1
+
2c2fa1
+      if (rpmReadConfigFiles_p (NULL, NULL) != 0)
2c2fa1
+	{
2c2fa1
+	  warning (_("Error reading the rpm configuration files"));
2c2fa1
+	  return 0;
2c2fa1
+	}
2c2fa1
+
2c2fa1
+      rpm_init_done = 1;
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  ts = rpmtsCreate_p ();
2c2fa1
+
2c2fa1
+  mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
2c2fa1
+  if (mi != NULL)
2c2fa1
+    {
2c2fa1
+      for (;;)
2c2fa1
+	{
2c2fa1
+	  Header h;
2c2fa1
+	  char *debuginfo, **slot, *s, *s2;
2c2fa1
+	  errmsg_t err;
2c2fa1
+	  size_t srcrpmlen = sizeof (".src.rpm") - 1;
2c2fa1
+	  size_t debuginfolen = sizeof ("-debuginfo") - 1;
2c2fa1
+	  rpmdbMatchIterator mi_debuginfo;
2c2fa1
+
2c2fa1
+	  h = rpmdbNextIterator_p (mi);
2c2fa1
+	  if (h == NULL)
2c2fa1
+	    break;
2c2fa1
+
2c2fa1
+	  /* Verify the debuginfo file is not already installed.  */
2c2fa1
+
2c2fa1
+	  debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
2c2fa1
+				      &err;;
2c2fa1
+	  if (!debuginfo)
2c2fa1
+	    {
2c2fa1
+	      warning (_("Error querying the rpm file `%s': %s"), filename,
2c2fa1
+	               err);
2c2fa1
+	      continue;
2c2fa1
+	    }
2c2fa1
+	  /* s = `.src.rpm-debuginfo.%{arch}' */
2c2fa1
+	  s = strrchr (debuginfo, '-') - srcrpmlen;
2c2fa1
+	  s2 = NULL;
2c2fa1
+	  if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
2c2fa1
+	    {
2c2fa1
+	      /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
2c2fa1
+	      s2 = memrchr (debuginfo, '-', s - debuginfo);
2c2fa1
+	    }
2c2fa1
+	  if (s2)
2c2fa1
+	    {
2c2fa1
+	      /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
2c2fa1
+	      s2 = memrchr (debuginfo, '-', s2 - debuginfo);
2c2fa1
+	    }
2c2fa1
+	  if (!s2)
2c2fa1
+	    {
2c2fa1
+	      warning (_("Error querying the rpm file `%s': %s"), filename,
2c2fa1
+	               debuginfo);
2c2fa1
+	      xfree (debuginfo);
2c2fa1
+	      continue;
2c2fa1
+	    }
2c2fa1
+	  /* s = `.src.rpm-debuginfo.%{arch}' */
2c2fa1
+	  /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
2c2fa1
+	  memmove (s2 + debuginfolen, s2, s - s2);
2c2fa1
+	  memcpy (s2, "-debuginfo", debuginfolen);
2c2fa1
+	  /* s = `XXXX.%{arch}' */
2c2fa1
+	  /* strlen ("XXXX") == srcrpmlen + debuginfolen */
2c2fa1
+	  /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
2c2fa1
+	  /* strlen ("XX") == srcrpmlen */
2c2fa1
+	  memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
2c2fa1
+		   strlen (s + srcrpmlen + debuginfolen) + 1);
2c2fa1
+	  /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
2c2fa1
+
2c2fa1
+	  /* RPMDBI_PACKAGES requires keylen == sizeof (int).  */
2c2fa1
+	  /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel().  */
2c2fa1
+	  mi_debuginfo = rpmtsInitIterator_p (ts, RPMDBI_LABEL, debuginfo, 0);
2c2fa1
+	  xfree (debuginfo);
2c2fa1
+	  if (mi_debuginfo)
2c2fa1
+	    {
2c2fa1
+	      rpmdbFreeIterator_p (mi_debuginfo);
2c2fa1
+	      count = 0;
2c2fa1
+	      break;
2c2fa1
+	    }
2c2fa1
+
2c2fa1
+	  /* The allocated memory gets utilized below for MISSING_RPM_HASH.  */
2c2fa1
+	  debuginfo = headerFormat_p (h,
2c2fa1
+				      "%{name}-%{version}-%{release}.%{arch}",
2c2fa1
+				      &err;;
2c2fa1
+	  if (!debuginfo)
2c2fa1
+	    {
2c2fa1
+	      warning (_("Error querying the rpm file `%s': %s"), filename,
2c2fa1
+	               err);
2c2fa1
+	      continue;
2c2fa1
+	    }
2c2fa1
+
2c2fa1
+	  /* Base package name for `debuginfo-install'.  We do not use the
2c2fa1
+	     `yum' command directly as the line
2c2fa1
+		 yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
2c2fa1
+	     would be more complicated than just:
2c2fa1
+		 debuginfo-install NAME-VERSION-RELEASE.ARCH
2c2fa1
+	     Do not supply the rpm base name (derived from .src.rpm name) as
2c2fa1
+	     debuginfo-install is unable to install the debuginfo package if
2c2fa1
+	     the base name PKG binary rpm is not installed while for example
2c2fa1
+	     PKG-libs would be installed (RH Bug 467901).
2c2fa1
+	     FUTURE: After multiple debuginfo versions simultaneously installed
2c2fa1
+	     get supported the support for the VERSION-RELEASE tags handling
2c2fa1
+	     may need an update.  */
2c2fa1
+
2c2fa1
+	  if (missing_rpm_hash == NULL)
2c2fa1
+	    {
2c2fa1
+	      /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
2c2fa1
+		 should not deallocate the entries.  */
2c2fa1
+
2c2fa1
+	      missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
2c2fa1
+			       (int (*) (const void *, const void *)) streq,
2c2fa1
+						    NULL, xcalloc, xfree);
2c2fa1
+	    }
2c2fa1
+	  slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
2c2fa1
+	  /* XCALLOC never returns NULL.  */
2c2fa1
+	  gdb_assert (slot != NULL);
2c2fa1
+	  if (*slot == NULL)
2c2fa1
+	    {
2c2fa1
+	      struct missing_rpm *missing_rpm;
2c2fa1
+
2c2fa1
+	      *slot = debuginfo;
2c2fa1
+
2c2fa1
+	      missing_rpm = xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
2c2fa1
+	      strcpy (missing_rpm->rpm, debuginfo);
2c2fa1
+	      missing_rpm->next = missing_rpm_list;
2c2fa1
+	      missing_rpm_list = missing_rpm;
2c2fa1
+	      missing_rpm_list_entries++;
2c2fa1
+	    }
2c2fa1
+	  else
2c2fa1
+	    xfree (debuginfo);
2c2fa1
+	  count++;
2c2fa1
+	}
2c2fa1
+
2c2fa1
+      rpmdbFreeIterator_p (mi);
2c2fa1
+    }
2c2fa1
+
2c2fa1
+  rpmtsFree_p (ts);
2c2fa1
+
2c2fa1
+  return count;
2c2fa1
+}
2c2fa1
+
2c2fa1
+static int
2c2fa1
+missing_rpm_list_compar (const char *const *ap, const char *const *bp)
2c2fa1
+{
2c2fa1
+  return strcoll (*ap, *bp);
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* It returns a NULL-terminated array of strings needing to be FREEd.  It may
2c2fa1
+   also return only NULL.  */
2c2fa1
+
2c2fa1
+static void
2c2fa1
+missing_rpm_list_print (void)
2c2fa1
+{
2c2fa1
+  char **array, **array_iter;
2c2fa1
+  struct missing_rpm *list_iter;
2c2fa1
+  struct cleanup *cleanups;
2c2fa1
+
2c2fa1
+  if (missing_rpm_list_entries == 0)
2c2fa1
+    return;
2c2fa1
+
2c2fa1
+  array = xmalloc (sizeof (*array) * missing_rpm_list_entries);
2c2fa1
+  cleanups = make_cleanup (xfree, array);
2c2fa1
+
2c2fa1
+  array_iter = array;
2c2fa1
+  for (list_iter = missing_rpm_list; list_iter != NULL;
2c2fa1
+       list_iter = list_iter->next)
2c2fa1
+    {
2c2fa1
+      *array_iter++ = list_iter->rpm;
2c2fa1
+    }
2c2fa1
+  gdb_assert (array_iter == array + missing_rpm_list_entries);
2c2fa1
+
2c2fa1
+  qsort (array, missing_rpm_list_entries, sizeof (*array),
2c2fa1
+	 (int (*) (const void *, const void *)) missing_rpm_list_compar);
2c2fa1
+
2c2fa1
+  printf_unfiltered (_("Missing separate debuginfos, use: %s"),
2c2fa1
+		     "debuginfo-install");
2c2fa1
+  for (array_iter = array; array_iter < array + missing_rpm_list_entries;
2c2fa1
+       array_iter++)
2c2fa1
+    {
2c2fa1
+      putchar_unfiltered (' ');
2c2fa1
+      puts_unfiltered (*array_iter);
2c2fa1
+    }
2c2fa1
+  putchar_unfiltered ('\n');
2c2fa1
+
2c2fa1
+  while (missing_rpm_list != NULL)
2c2fa1
+    {
2c2fa1
+      list_iter = missing_rpm_list;
2c2fa1
+      missing_rpm_list = list_iter->next;
2c2fa1
+      xfree (list_iter);
2c2fa1
+    }
2c2fa1
+  missing_rpm_list_entries = 0;
2c2fa1
+
2c2fa1
+  do_cleanups (cleanups);
2c2fa1
+}
2c2fa1
+
2c2fa1
+static void
2c2fa1
+missing_rpm_change (void)
2c2fa1
+{
2c2fa1
+  debug_flush_missing ();
2c2fa1
+
2c2fa1
+  gdb_assert (missing_rpm_list == NULL);
2c2fa1
+  if (missing_rpm_hash != NULL)
2c2fa1
+    {
2c2fa1
+      htab_delete (missing_rpm_hash);
2c2fa1
+      missing_rpm_hash = NULL;
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+
2c2fa1
+enum missing_exec
2c2fa1
+  {
2c2fa1
+    /* Init state.  EXEC_BFD also still could be NULL.  */
2c2fa1
+    MISSING_EXEC_NOT_TRIED,
2c2fa1
+    /* We saw a non-NULL EXEC_BFD but RPM has no info about it.  */
2c2fa1
+    MISSING_EXEC_NOT_FOUND,
2c2fa1
+    /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
2c2fa1
+       or separate) or the main executable's RPM is now contained in
2c2fa1
+       MISSING_RPM_HASH.  */
2c2fa1
+    MISSING_EXEC_ENLISTED
2c2fa1
+  };
2c2fa1
+static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
2c2fa1
+
2c2fa1
+#endif	/* HAVE_LIBRPM */
2c2fa1
+
2c2fa1
+void
2c2fa1
+debug_flush_missing (void)
2c2fa1
+{
2c2fa1
+#ifdef HAVE_LIBRPM
2c2fa1
+  missing_rpm_list_print ();
2c2fa1
+#endif
2c2fa1
+}
2c2fa1
+
2c2fa1
 /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
2c2fa1
-     Try to install the hash file ...
2c2fa1
+     yum --enablerepo='*debug*' install ...
2c2fa1
    avoidance.  */
2c2fa1
 
2c2fa1
 struct missing_filepair
2c2fa1
@@ -1737,11 +2090,17 @@ missing_filepair_change (void)
2c2fa1
       /* All their memory came just from missing_filepair_OBSTACK.  */
2c2fa1
       missing_filepair_hash = NULL;
2c2fa1
     }
2c2fa1
+#ifdef HAVE_LIBRPM
2c2fa1
+  missing_exec = MISSING_EXEC_NOT_TRIED;
2c2fa1
+#endif
2c2fa1
 }
2c2fa1
 
2c2fa1
 static void
2c2fa1
 debug_print_executable_changed (void)
2c2fa1
 {
2c2fa1
+#ifdef HAVE_LIBRPM
2c2fa1
+  missing_rpm_change ();
2c2fa1
+#endif
2c2fa1
   missing_filepair_change ();
2c2fa1
 }
2c2fa1
 
2c2fa1
@@ -1808,14 +2167,34 @@ debug_print_missing (const char *binary,
2c2fa1
 
2c2fa1
   *slot = missing_filepair;
2c2fa1
 
2c2fa1
-  /* We do not collect and flush these messages as each such message
2c2fa1
-     already requires its own separate lines.  */
2c2fa1
+#ifdef HAVE_LIBRPM
2c2fa1
+  if (missing_exec == MISSING_EXEC_NOT_TRIED)
2c2fa1
+    {
2c2fa1
+      char *execfilename;
2c2fa1
 
2c2fa1
-  fprintf_unfiltered (gdb_stdlog,
2c2fa1
-		      _("Missing separate debuginfo for %s\n"), binary);
2c2fa1
-  if (debug != NULL)
2c2fa1
-    fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
2c2fa1
-			debug);
2c2fa1
+      execfilename = get_exec_file (0);
2c2fa1
+      if (execfilename != NULL)
2c2fa1
+	{
2c2fa1
+	  if (missing_rpm_enlist (execfilename) == 0)
2c2fa1
+	    missing_exec = MISSING_EXEC_NOT_FOUND;
2c2fa1
+	  else
2c2fa1
+	    missing_exec = MISSING_EXEC_ENLISTED;
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+  if (missing_exec != MISSING_EXEC_ENLISTED)
2c2fa1
+    if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
2c2fa1
+	&& (debug == NULL || missing_rpm_enlist (debug) == 0))
2c2fa1
+#endif	/* HAVE_LIBRPM */
2c2fa1
+      {
2c2fa1
+	/* We do not collect and flush these messages as each such message
2c2fa1
+	   already requires its own separate lines.  */
2c2fa1
+
2c2fa1
+	fprintf_unfiltered (gdb_stdlog,
2c2fa1
+			    _("Missing separate debuginfo for %s\n"), binary);
2c2fa1
+        if (debug != NULL)
2c2fa1
+	  fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
2c2fa1
+			      "yum --enablerepo='*debug*' install", debug);
2c2fa1
+      }
2c2fa1
 }
2c2fa1
 
2c2fa1
 static char *
2c2fa1
Index: gdb-7.6/gdb/symfile.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/symfile.h	2013-07-17 19:51:02.639357629 +0200
2c2fa1
+++ gdb-7.6/gdb/symfile.h	2013-07-17 19:51:02.687357661 +0200
2c2fa1
@@ -598,6 +598,8 @@ extern struct elf_build_id *build_id_add
2c2fa1
 extern char *build_id_to_filename (const struct elf_build_id *build_id,
2c2fa1
 				   char **link_return, int add_debug_suffix);
2c2fa1
 extern void debug_print_missing (const char *binary, const char *debug);
2c2fa1
+extern void debug_flush_missing (void);
2c2fa1
+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
2c2fa1
 
2c2fa1
 /* From dwarf2read.c */
2c2fa1
 
2c2fa1
Index: gdb-7.6/gdb/testsuite/lib/gdb.exp
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/testsuite/lib/gdb.exp	2013-07-17 19:51:02.640357629 +0200
2c2fa1
+++ gdb-7.6/gdb/testsuite/lib/gdb.exp	2013-07-17 19:51:02.688357662 +0200
2c2fa1
@@ -1482,7 +1482,7 @@ proc default_gdb_start { } {
2c2fa1
 	    warning "Couldn't set the width to 0."
2c2fa1
 	}
2c2fa1
     }
2c2fa1
-    # Turn off the missing warnings as the testsuite does not expect it.
2c2fa1
+    # Turn off the missing RPMs warnings as the testsuite does not expect it.
2c2fa1
     send_gdb "set build-id-verbose 0\n"
2c2fa1
     gdb_expect 10 {
2c2fa1
 	-re "$gdb_prompt $" {
2c2fa1
Index: gdb-7.6/gdb/testsuite/lib/mi-support.exp
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/testsuite/lib/mi-support.exp	2013-07-17 19:51:02.656357640 +0200
2c2fa1
+++ gdb-7.6/gdb/testsuite/lib/mi-support.exp	2013-07-17 19:51:02.689357663 +0200
2c2fa1
@@ -212,7 +212,7 @@ proc default_mi_gdb_start { args } {
2c2fa1
 	    warning "Couldn't set the width to 0."
2c2fa1
 	}
2c2fa1
     }
2c2fa1
-    # Turn off the missing warnings as the testsuite does not expect it.
2c2fa1
+    # Turn off the missing RPMs warnings as the testsuite does not expect it.
2c2fa1
     send_gdb "190-gdb-set build-id-verbose 0\n"
2c2fa1
     gdb_expect 10 {
2c2fa1
 	-re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
2c2fa1
Index: gdb-7.6/gdb/tui/tui-interp.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/tui/tui-interp.c	2013-01-01 07:41:30.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/tui/tui-interp.c	2013-07-17 19:51:02.689357663 +0200
2c2fa1
@@ -30,6 +30,7 @@
2c2fa1
 #include "tui/tui.h"
2c2fa1
 #include "tui/tui-io.h"
2c2fa1
 #include "exceptions.h"
2c2fa1
+#include "symfile.h"
2c2fa1
 
2c2fa1
 /* Set to 1 when the TUI mode must be activated when we first start
2c2fa1
    gdb.  */
2c2fa1
Index: gdb-7.6/gdb/aclocal.m4
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/aclocal.m4	2013-01-17 12:06:26.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/aclocal.m4	2013-07-17 19:51:02.689357663 +0200
2c2fa1
@@ -11,6 +11,164 @@
2c2fa1
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
2c2fa1
 # PARTICULAR PURPOSE.
2c2fa1
 
2c2fa1
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
2c2fa1
+# serial 1 (pkg-config-0.24)
2c2fa1
+# 
2c2fa1
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
2c2fa1
+#
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 2 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful, but
2c2fa1
+# WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2c2fa1
+# General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program; if not, write to the Free Software
2c2fa1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2c2fa1
+#
2c2fa1
+# As a special exception to the GNU General Public License, if you
2c2fa1
+# distribute this file as part of a program that contains a
2c2fa1
+# configuration script generated by Autoconf, you may include it under
2c2fa1
+# the same distribution terms that you use for the rest of that program.
2c2fa1
+
2c2fa1
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
2c2fa1
+# ----------------------------------
2c2fa1
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
2c2fa1
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
2c2fa1
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
2c2fa1
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
2c2fa1
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
2c2fa1
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
2c2fa1
+
2c2fa1
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2c2fa1
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2c2fa1
+fi
2c2fa1
+if test -n "$PKG_CONFIG"; then
2c2fa1
+	_pkg_min_version=m4_default([$1], [0.9.0])
2c2fa1
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
2c2fa1
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2c2fa1
+		AC_MSG_RESULT([yes])
2c2fa1
+	else
2c2fa1
+		AC_MSG_RESULT([no])
2c2fa1
+		PKG_CONFIG=""
2c2fa1
+	fi
2c2fa1
+fi[]dnl
2c2fa1
+])# PKG_PROG_PKG_CONFIG
2c2fa1
+
2c2fa1
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2c2fa1
+#
2c2fa1
+# Check to see whether a particular set of modules exists.  Similar
2c2fa1
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
2c2fa1
+#
2c2fa1
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
2c2fa1
+# only at the first occurence in configure.ac, so if the first place
2c2fa1
+# it's called might be skipped (such as if it is within an "if", you
2c2fa1
+# have to call PKG_CHECK_EXISTS manually
2c2fa1
+# --------------------------------------------------------------
2c2fa1
+AC_DEFUN([PKG_CHECK_EXISTS],
2c2fa1
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
2c2fa1
+if test -n "$PKG_CONFIG" && \
2c2fa1
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
2c2fa1
+  m4_default([$2], [:])
2c2fa1
+m4_ifvaln([$3], [else
2c2fa1
+  $3])dnl
2c2fa1
+fi])
2c2fa1
+
2c2fa1
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
2c2fa1
+# ---------------------------------------------
2c2fa1
+m4_define([_PKG_CONFIG],
2c2fa1
+[if test -n "$$1"; then
2c2fa1
+    pkg_cv_[]$1="$$1"
2c2fa1
+ elif test -n "$PKG_CONFIG"; then
2c2fa1
+    PKG_CHECK_EXISTS([$3],
2c2fa1
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
2c2fa1
+		     [pkg_failed=yes])
2c2fa1
+ else
2c2fa1
+    pkg_failed=untried
2c2fa1
+fi[]dnl
2c2fa1
+])# _PKG_CONFIG
2c2fa1
+
2c2fa1
+# _PKG_SHORT_ERRORS_SUPPORTED
2c2fa1
+# -----------------------------
2c2fa1
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
2c2fa1
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
2c2fa1
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2c2fa1
+        _pkg_short_errors_supported=yes
2c2fa1
+else
2c2fa1
+        _pkg_short_errors_supported=no
2c2fa1
+fi[]dnl
2c2fa1
+])# _PKG_SHORT_ERRORS_SUPPORTED
2c2fa1
+
2c2fa1
+
2c2fa1
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
2c2fa1
+# [ACTION-IF-NOT-FOUND])
2c2fa1
+#
2c2fa1
+#
2c2fa1
+# Note that if there is a possibility the first call to
2c2fa1
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
2c2fa1
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
2c2fa1
+#
2c2fa1
+#
2c2fa1
+# --------------------------------------------------------------
2c2fa1
+AC_DEFUN([PKG_CHECK_MODULES],
2c2fa1
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
2c2fa1
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
2c2fa1
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
2c2fa1
+
2c2fa1
+pkg_failed=no
2c2fa1
+AC_MSG_CHECKING([for $1])
2c2fa1
+
2c2fa1
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
2c2fa1
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
2c2fa1
+
2c2fa1
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
2c2fa1
+and $1[]_LIBS to avoid the need to call pkg-config.
2c2fa1
+See the pkg-config man page for more details.])
2c2fa1
+
2c2fa1
+if test $pkg_failed = yes; then
2c2fa1
+   	AC_MSG_RESULT([no])
2c2fa1
+        _PKG_SHORT_ERRORS_SUPPORTED
2c2fa1
+        if test $_pkg_short_errors_supported = yes; then
2c2fa1
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
2c2fa1
+        else 
2c2fa1
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
2c2fa1
+        fi
2c2fa1
+	# Put the nasty error message in config.log where it belongs
2c2fa1
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
2c2fa1
+
2c2fa1
+	m4_default([$4], [AC_MSG_ERROR(
2c2fa1
+[Package requirements ($2) were not met:
2c2fa1
+
2c2fa1
+$$1_PKG_ERRORS
2c2fa1
+
2c2fa1
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
2c2fa1
+installed software in a non-standard prefix.
2c2fa1
+
2c2fa1
+_PKG_TEXT])
2c2fa1
+        ])
2c2fa1
+elif test $pkg_failed = untried; then
2c2fa1
+     	AC_MSG_RESULT([no])
2c2fa1
+	m4_default([$4], [AC_MSG_FAILURE(
2c2fa1
+[The pkg-config script could not be found or is too old.  Make sure it
2c2fa1
+is in your PATH or set the PKG_CONFIG environment variable to the full
2c2fa1
+path to pkg-config.
2c2fa1
+
2c2fa1
+_PKG_TEXT
2c2fa1
+
2c2fa1
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])
2c2fa1
+        ])
2c2fa1
+else
2c2fa1
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
2c2fa1
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
2c2fa1
+        AC_MSG_RESULT([yes])
2c2fa1
+	$3
2c2fa1
+fi[]dnl
2c2fa1
+])# PKG_CHECK_MODULES
2c2fa1
+
2c2fa1
 # AM_CONDITIONAL                                            -*- Autoconf -*-
2c2fa1
 
2c2fa1
 # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
2c2fa1
Index: gdb-7.6/gdb/config.in
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/config.in	2012-12-09 19:39:58.000000000 +0100
2c2fa1
+++ gdb-7.6/gdb/config.in	2013-07-17 19:51:02.689357663 +0200
2c2fa1
@@ -33,6 +33,9 @@
2c2fa1
 /* Define to BFD's default target vector. */
2c2fa1
 #undef DEFAULT_BFD_VEC
2c2fa1
 
2c2fa1
+/* librpm version specific library name to dlopen. */
2c2fa1
+#undef DLOPEN_LIBRPM
2c2fa1
+
2c2fa1
 /* Define to 1 if translation of program messages to the user's native
2c2fa1
    language is requested. */
2c2fa1
 #undef ENABLE_NLS
2c2fa1
@@ -210,6 +213,9 @@
2c2fa1
 /* Define if Python 2.7 is being used. */
2c2fa1
 #undef HAVE_LIBPYTHON2_7
2c2fa1
 
2c2fa1
+/* Define if librpm library is being used. */
2c2fa1
+#undef HAVE_LIBRPM
2c2fa1
+
2c2fa1
 /* Define to 1 if you have the <libunwind-ia64.h> header file. */
2c2fa1
 #undef HAVE_LIBUNWIND_IA64_H
2c2fa1
 
2c2fa1
Index: gdb-7.6/gdb/configure
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/configure	2013-07-17 19:51:01.665356963 +0200
2c2fa1
+++ gdb-7.6/gdb/configure	2013-07-17 19:51:02.691357664 +0200
2c2fa1
@@ -686,6 +686,11 @@ PKGVERSION
2c2fa1
 HAVE_NATIVE_GCORE_TARGET
2c2fa1
 TARGET_OBS
2c2fa1
 subdirs
2c2fa1
+RPM_LIBS
2c2fa1
+RPM_CFLAGS
2c2fa1
+PKG_CONFIG_LIBDIR
2c2fa1
+PKG_CONFIG_PATH
2c2fa1
+PKG_CONFIG
2c2fa1
 GDB_DATADIR
2c2fa1
 DEBUGDIR
2c2fa1
 MAKEINFO_EXTRA_FLAGS
2c2fa1
@@ -786,6 +791,7 @@ with_gdb_datadir
2c2fa1
 with_relocated_sources
2c2fa1
 with_auto_load_dir
2c2fa1
 with_auto_load_safe_path
2c2fa1
+with_rpm
2c2fa1
 enable_targets
2c2fa1
 enable_64_bit_bfd
2c2fa1
 enable_gdbcli
2c2fa1
@@ -834,6 +840,11 @@ CPPFLAGS
2c2fa1
 CPP
2c2fa1
 MAKEINFO
2c2fa1
 MAKEINFOFLAGS
2c2fa1
+PKG_CONFIG
2c2fa1
+PKG_CONFIG_PATH
2c2fa1
+PKG_CONFIG_LIBDIR
2c2fa1
+RPM_CFLAGS
2c2fa1
+RPM_LIBS
2c2fa1
 YACC
2c2fa1
 YFLAGS
2c2fa1
 XMKMF'
2c2fa1
@@ -1504,6 +1515,8 @@ Optional Packages:
2c2fa1
                           [--with-auto-load-dir]
2c2fa1
   --without-auto-load-safe-path
2c2fa1
                           do not restrict auto-loaded files locations
2c2fa1
+  --with-rpm              query rpm database for missing debuginfos (yes/no,
2c2fa1
+                          def. auto=librpm.so)
2c2fa1
   --with-libunwind-ia64   use libunwind frame unwinding for ia64 targets
2c2fa1
   --with-curses           use the curses library instead of the termcap
2c2fa1
                           library
2c2fa1
@@ -1548,6 +1561,13 @@ Some influential environment variables:
2c2fa1
   MAKEINFO    Parent configure detects if it is of sufficient version.
2c2fa1
   MAKEINFOFLAGS
2c2fa1
               Parameters for MAKEINFO.
2c2fa1
+  PKG_CONFIG  path to pkg-config utility
2c2fa1
+  PKG_CONFIG_PATH
2c2fa1
+              directories to add to pkg-config's search path
2c2fa1
+  PKG_CONFIG_LIBDIR
2c2fa1
+              path overriding pkg-config's built-in search path
2c2fa1
+  RPM_CFLAGS  C compiler flags for RPM, overriding pkg-config
2c2fa1
+  RPM_LIBS    linker flags for RPM, overriding pkg-config
2c2fa1
   YACC        The `Yet Another C Compiler' implementation to use. Defaults to
2c2fa1
               the first program found out of: `bison -y', `byacc', `yacc'.
2c2fa1
   YFLAGS      The list of arguments that will be passed by default to $YACC.
2c2fa1
@@ -5033,6 +5053,491 @@ _ACEOF
2c2fa1
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
2c2fa1
 $as_echo "$with_auto_load_safe_path" >&6; }
2c2fa1
 
2c2fa1
+# Integration with rpm library to support missing debuginfo suggestions.
2c2fa1
+# --without-rpm: Disable any rpm support.
2c2fa1
+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
2c2fa1
+#   Even with runtime missing `libname.so' GDB will still other run correctly.
2c2fa1
+#   Missing `libname.so' during ./configure will abort the configuration.
2c2fa1
+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
2c2fa1
+#   minor version first such as `librpm-4.6.so' as minor version differences
2c2fa1
+#   mean API+ABI incompatibility.  If the specific match versioned library name
2c2fa1
+#   could not be found still open dynamically at least `librpm.so'.
2c2fa1
+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
2c2fa1
+#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
2c2fa1
+#   be probably linked with the version specific library (as `librpm-4.6.so').
2c2fa1
+#   Failure to find librpm by pkg-config will abort the configuration.
2c2fa1
+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
2c2fa1
+#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
2c2fa1
+
2c2fa1
+
2c2fa1
+# Check whether --with-rpm was given.
2c2fa1
+if test "${with_rpm+set}" = set; then :
2c2fa1
+  withval=$with_rpm;
2c2fa1
+else
2c2fa1
+  with_rpm="auto"
2c2fa1
+fi
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+if test "x$with_rpm" != "xno"; then
2c2fa1
+  if test "x$with_rpm" = "xyes"; then
2c2fa1
+    LIBRPM="librpm.so"
2c2fa1
+    RPM_REQUIRE=true
2c2fa1
+    DLOPEN_REQUIRE=false
2c2fa1
+  elif test "x$with_rpm" = "xauto"; then
2c2fa1
+    LIBRPM="librpm.so"
2c2fa1
+    RPM_REQUIRE=false
2c2fa1
+    DLOPEN_REQUIRE=false
2c2fa1
+  else
2c2fa1
+    LIBRPM="$with_rpm"
2c2fa1
+    RPM_REQUIRE=true
2c2fa1
+    DLOPEN_REQUIRE=true
2c2fa1
+  fi
2c2fa1
+  LIBRPM_STRING='"'"$LIBRPM"'"'
2c2fa1
+
2c2fa1
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
2c2fa1
+$as_echo_n "checking specific librpm version... " >&6; }
2c2fa1
+  HAVE_DLOPEN_LIBRPM=false
2c2fa1
+  save_LIBS="$LIBS"
2c2fa1
+  LIBS="$LIBS -ldl"
2c2fa1
+  if test "$cross_compiling" = yes; then :
2c2fa1
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2c2fa1
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2c2fa1
+as_fn_error "cannot run test program while cross compiling
2c2fa1
+See \`config.log' for more details." "$LINENO" 5; }
2c2fa1
+else
2c2fa1
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2c2fa1
+/* end confdefs.h.  */
2c2fa1
+
2c2fa1
+#include <rpm/rpmlib.h>
2c2fa1
+#include <dlfcn.h>
2c2fa1
+#include <errno.h>
2c2fa1
+
2c2fa1
+int
2c2fa1
+main ()
2c2fa1
+{
2c2fa1
+
2c2fa1
+    void *h;
2c2fa1
+    const char *const *rpmverp;
2c2fa1
+    FILE *f;
2c2fa1
+
2c2fa1
+    f = fopen ("conftest.out", "w");
2c2fa1
+    if (!f)
2c2fa1
+      {
2c2fa1
+	fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
2c2fa1
+		 strerror (errno));
2c2fa1
+	return 1;
2c2fa1
+      }
2c2fa1
+    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
2c2fa1
+    if (!h)
2c2fa1
+      {
2c2fa1
+	fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
2c2fa1
+	return 1;
2c2fa1
+      }
2c2fa1
+    rpmverp = dlsym (h, "RPMVERSION");
2c2fa1
+    if (!rpmverp)
2c2fa1
+      {
2c2fa1
+	fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
2c2fa1
+	return 1;
2c2fa1
+      }
2c2fa1
+    fprintf (stderr, "RPMVERSION is: \"");
2c2fa1
+    fprintf (stderr, "%s\"\n", *rpmverp);
2c2fa1
+
2c2fa1
+    /* Try to find the specific librpm version only for "librpm.so" as we do
2c2fa1
+       not know how to assemble the version string otherwise.  */
2c2fa1
+
2c2fa1
+    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
2c2fa1
+      {
2c2fa1
+	fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	return 0;
2c2fa1
+      }
2c2fa1
+    else
2c2fa1
+      {
2c2fa1
+	char *h2_name;
2c2fa1
+	void *h2;
2c2fa1
+	int major, minor;
2c2fa1
+
2c2fa1
+	if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
2c2fa1
+	  {
2c2fa1
+	    fprintf (stderr, "Unable to parse RPMVERSION.\n");
2c2fa1
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+	/* Avoid the square brackets by malloc.  */
2c2fa1
+	h2_name = malloc (64);
2c2fa1
+	sprintf (h2_name, "librpm-%d.%d.so", major, minor);
2c2fa1
+	h2 = dlopen (h2_name, RTLD_LAZY);
2c2fa1
+	if (!h2)
2c2fa1
+	  {
2c2fa1
+	    fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
2c2fa1
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+	if (h2 != h)
2c2fa1
+	  {
2c2fa1
+	    fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
2c2fa1
+		     $LIBRPM_STRING, h2_name);
2c2fa1
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+	/* Found the valid .so name with a specific version.  */
2c2fa1
+	fprintf (f, "%s\n", h2_name);
2c2fa1
+	return 0;
2c2fa1
+      }
2c2fa1
+
2c2fa1
+  ;
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+_ACEOF
2c2fa1
+if ac_fn_c_try_run "$LINENO"; then :
2c2fa1
+
2c2fa1
+    DLOPEN_LIBRPM="`cat conftest.out`"
2c2fa1
+    if test "x$DLOPEN_LIBRPM" != "x"; then
2c2fa1
+      HAVE_DLOPEN_LIBRPM=true
2c2fa1
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
2c2fa1
+$as_echo "$DLOPEN_LIBRPM" >&6; }
2c2fa1
+    fi
2c2fa1
+
2c2fa1
+fi
2c2fa1
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
2c2fa1
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
2c2fa1
+fi
2c2fa1
+
2c2fa1
+  rm -f conftest.out
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+  if $HAVE_DLOPEN_LIBRPM; then
2c2fa1
+
2c2fa1
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
2c2fa1
+$as_echo_n "checking rpm library API compatibility... " >&6; }
2c2fa1
+    # The compilation requires -Werror to verify anything.
2c2fa1
+    save_CFLAGS="$CFLAGS"
2c2fa1
+    CFLAGS="$CFLAGS -Werror"
2c2fa1
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2c2fa1
+/* end confdefs.h.  */
2c2fa1
+
2c2fa1
+/* Duplicate here the declarations to verify they match "elfread.c".  */
2c2fa1
+#include <rpm/rpmlib.h>
2c2fa1
+#include <rpm/rpmts.h>
2c2fa1
+#include <rpm/rpmdb.h>
2c2fa1
+#include <rpm/header.h>
2c2fa1
+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
2c2fa1
+extern int rpmReadConfigFiles(const char * file, const char * target);
2c2fa1
+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
2c2fa1
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
2c2fa1
+extern rpmts rpmtsCreate(void);
2c2fa1
+extern rpmts rpmtsFree(rpmts ts);
2c2fa1
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
2c2fa1
+					    const void * keyp, size_t keylen);
2c2fa1
+
2c2fa1
+int
2c2fa1
+main ()
2c2fa1
+{
2c2fa1
+
2c2fa1
+  ;
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+_ACEOF
2c2fa1
+if ac_fn_c_try_compile "$LINENO"; then :
2c2fa1
+
2c2fa1
+      LIBRPM_COMPAT=true
2c2fa1
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2c2fa1
+$as_echo "yes" >&6; }
2c2fa1
+
2c2fa1
+else
2c2fa1
+
2c2fa1
+      LIBRPM_COMPAT=false
2c2fa1
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+
2c2fa1
+fi
2c2fa1
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2c2fa1
+    CFLAGS="$save_CFLAGS"
2c2fa1
+
2c2fa1
+    if ! $LIBRPM_COMPAT; then
2c2fa1
+      HAVE_DLOPEN_LIBRPM=false
2c2fa1
+    fi
2c2fa1
+  fi
2c2fa1
+
2c2fa1
+  if $HAVE_DLOPEN_LIBRPM; then
2c2fa1
+    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
2c2fa1
+
2c2fa1
+cat >>confdefs.h <<_ACEOF
2c2fa1
+#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
2c2fa1
+_ACEOF
2c2fa1
+
2c2fa1
+
2c2fa1
+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
2c2fa1
+
2c2fa1
+  else
2c2fa1
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+    LIBS="$save_LIBS"
2c2fa1
+    if $DLOPEN_REQUIRE; then
2c2fa1
+      as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
2c2fa1
+    fi
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2c2fa1
+	if test -n "$ac_tool_prefix"; then
2c2fa1
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
2c2fa1
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
2c2fa1
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2c2fa1
+$as_echo_n "checking for $ac_word... " >&6; }
2c2fa1
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
2c2fa1
+  $as_echo_n "(cached) " >&6
2c2fa1
+else
2c2fa1
+  case $PKG_CONFIG in
2c2fa1
+  [\\/]* | ?:[\\/]*)
2c2fa1
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
2c2fa1
+  ;;
2c2fa1
+  *)
2c2fa1
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2c2fa1
+for as_dir in $PATH
2c2fa1
+do
2c2fa1
+  IFS=$as_save_IFS
2c2fa1
+  test -z "$as_dir" && as_dir=.
2c2fa1
+    for ac_exec_ext in '' $ac_executable_extensions; do
2c2fa1
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2c2fa1
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
2c2fa1
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2c2fa1
+    break 2
2c2fa1
+  fi
2c2fa1
+done
2c2fa1
+  done
2c2fa1
+IFS=$as_save_IFS
2c2fa1
+
2c2fa1
+  ;;
2c2fa1
+esac
2c2fa1
+fi
2c2fa1
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
2c2fa1
+if test -n "$PKG_CONFIG"; then
2c2fa1
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
2c2fa1
+$as_echo "$PKG_CONFIG" >&6; }
2c2fa1
+else
2c2fa1
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+fi
2c2fa1
+
2c2fa1
+
2c2fa1
+fi
2c2fa1
+if test -z "$ac_cv_path_PKG_CONFIG"; then
2c2fa1
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
2c2fa1
+  # Extract the first word of "pkg-config", so it can be a program name with args.
2c2fa1
+set dummy pkg-config; ac_word=$2
2c2fa1
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2c2fa1
+$as_echo_n "checking for $ac_word... " >&6; }
2c2fa1
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
2c2fa1
+  $as_echo_n "(cached) " >&6
2c2fa1
+else
2c2fa1
+  case $ac_pt_PKG_CONFIG in
2c2fa1
+  [\\/]* | ?:[\\/]*)
2c2fa1
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
2c2fa1
+  ;;
2c2fa1
+  *)
2c2fa1
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2c2fa1
+for as_dir in $PATH
2c2fa1
+do
2c2fa1
+  IFS=$as_save_IFS
2c2fa1
+  test -z "$as_dir" && as_dir=.
2c2fa1
+    for ac_exec_ext in '' $ac_executable_extensions; do
2c2fa1
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2c2fa1
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
2c2fa1
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2c2fa1
+    break 2
2c2fa1
+  fi
2c2fa1
+done
2c2fa1
+  done
2c2fa1
+IFS=$as_save_IFS
2c2fa1
+
2c2fa1
+  ;;
2c2fa1
+esac
2c2fa1
+fi
2c2fa1
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
2c2fa1
+if test -n "$ac_pt_PKG_CONFIG"; then
2c2fa1
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
2c2fa1
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
2c2fa1
+else
2c2fa1
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+fi
2c2fa1
+
2c2fa1
+  if test "x$ac_pt_PKG_CONFIG" = x; then
2c2fa1
+    PKG_CONFIG=""
2c2fa1
+  else
2c2fa1
+    case $cross_compiling:$ac_tool_warned in
2c2fa1
+yes:)
2c2fa1
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2c2fa1
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2c2fa1
+ac_tool_warned=yes ;;
2c2fa1
+esac
2c2fa1
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
2c2fa1
+  fi
2c2fa1
+else
2c2fa1
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
2c2fa1
+fi
2c2fa1
+
2c2fa1
+fi
2c2fa1
+if test -n "$PKG_CONFIG"; then
2c2fa1
+	_pkg_min_version=0.9.0
2c2fa1
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
2c2fa1
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
2c2fa1
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2c2fa1
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2c2fa1
+$as_echo "yes" >&6; }
2c2fa1
+	else
2c2fa1
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+		PKG_CONFIG=""
2c2fa1
+	fi
2c2fa1
+fi
2c2fa1
+
2c2fa1
+pkg_failed=no
2c2fa1
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
2c2fa1
+$as_echo_n "checking for RPM... " >&6; }
2c2fa1
+
2c2fa1
+if test -n "$RPM_CFLAGS"; then
2c2fa1
+    pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
2c2fa1
+ elif test -n "$PKG_CONFIG"; then
2c2fa1
+    if test -n "$PKG_CONFIG" && \
2c2fa1
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
2c2fa1
+  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
2c2fa1
+  ac_status=$?
2c2fa1
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2c2fa1
+  test $ac_status = 0; }; then
2c2fa1
+  pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
2c2fa1
+else
2c2fa1
+  pkg_failed=yes
2c2fa1
+fi
2c2fa1
+ else
2c2fa1
+    pkg_failed=untried
2c2fa1
+fi
2c2fa1
+if test -n "$RPM_LIBS"; then
2c2fa1
+    pkg_cv_RPM_LIBS="$RPM_LIBS"
2c2fa1
+ elif test -n "$PKG_CONFIG"; then
2c2fa1
+    if test -n "$PKG_CONFIG" && \
2c2fa1
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
2c2fa1
+  ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
2c2fa1
+  ac_status=$?
2c2fa1
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2c2fa1
+  test $ac_status = 0; }; then
2c2fa1
+  pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
2c2fa1
+else
2c2fa1
+  pkg_failed=yes
2c2fa1
+fi
2c2fa1
+ else
2c2fa1
+    pkg_failed=untried
2c2fa1
+fi
2c2fa1
+
2c2fa1
+
2c2fa1
+
2c2fa1
+if test $pkg_failed = yes; then
2c2fa1
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+
2c2fa1
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2c2fa1
+        _pkg_short_errors_supported=yes
2c2fa1
+else
2c2fa1
+        _pkg_short_errors_supported=no
2c2fa1
+fi
2c2fa1
+        if test $_pkg_short_errors_supported = yes; then
2c2fa1
+	        RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "rpm" 2>&1`
2c2fa1
+        else
2c2fa1
+	        RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors "rpm" 2>&1`
2c2fa1
+        fi
2c2fa1
+	# Put the nasty error message in config.log where it belongs
2c2fa1
+	echo "$RPM_PKG_ERRORS" >&5
2c2fa1
+
2c2fa1
+	HAVE_LIBRPM=false
2c2fa1
+elif test $pkg_failed = untried; then
2c2fa1
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+	HAVE_LIBRPM=false
2c2fa1
+else
2c2fa1
+	RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
2c2fa1
+	RPM_LIBS=$pkg_cv_RPM_LIBS
2c2fa1
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2c2fa1
+$as_echo "yes" >&6; }
2c2fa1
+	HAVE_LIBRPM=true
2c2fa1
+fi
2c2fa1
+
2c2fa1
+    if $HAVE_LIBRPM; then
2c2fa1
+
2c2fa1
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
2c2fa1
+$as_echo_n "checking rpm library API compatibility... " >&6; }
2c2fa1
+    # The compilation requires -Werror to verify anything.
2c2fa1
+    save_CFLAGS="$CFLAGS"
2c2fa1
+    CFLAGS="$CFLAGS -Werror"
2c2fa1
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2c2fa1
+/* end confdefs.h.  */
2c2fa1
+
2c2fa1
+/* Duplicate here the declarations to verify they match "elfread.c".  */
2c2fa1
+#include <rpm/rpmlib.h>
2c2fa1
+#include <rpm/rpmts.h>
2c2fa1
+#include <rpm/rpmdb.h>
2c2fa1
+#include <rpm/header.h>
2c2fa1
+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
2c2fa1
+extern int rpmReadConfigFiles(const char * file, const char * target);
2c2fa1
+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
2c2fa1
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
2c2fa1
+extern rpmts rpmtsCreate(void);
2c2fa1
+extern rpmts rpmtsFree(rpmts ts);
2c2fa1
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
2c2fa1
+					    const void * keyp, size_t keylen);
2c2fa1
+
2c2fa1
+int
2c2fa1
+main ()
2c2fa1
+{
2c2fa1
+
2c2fa1
+  ;
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+_ACEOF
2c2fa1
+if ac_fn_c_try_compile "$LINENO"; then :
2c2fa1
+
2c2fa1
+      LIBRPM_COMPAT=true
2c2fa1
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2c2fa1
+$as_echo "yes" >&6; }
2c2fa1
+
2c2fa1
+else
2c2fa1
+
2c2fa1
+      LIBRPM_COMPAT=false
2c2fa1
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2c2fa1
+$as_echo "no" >&6; }
2c2fa1
+
2c2fa1
+fi
2c2fa1
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2c2fa1
+    CFLAGS="$save_CFLAGS"
2c2fa1
+
2c2fa1
+      if ! $LIBRPM_COMPAT; then
2c2fa1
+	HAVE_LIBRPM=false
2c2fa1
+	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
2c2fa1
+      fi
2c2fa1
+    fi
2c2fa1
+
2c2fa1
+    if $HAVE_LIBRPM; then
2c2fa1
+
2c2fa1
+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
2c2fa1
+
2c2fa1
+      CFLAGS="$CFLAGS $RPM_CFLAGS"
2c2fa1
+      LIBS="$LIBS $RPM_LIBS"
2c2fa1
+    else
2c2fa1
+      if $RPM_REQUIRE; then
2c2fa1
+	as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
2c2fa1
+      else
2c2fa1
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
2c2fa1
+$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
2c2fa1
+      fi
2c2fa1
+    fi
2c2fa1
+  fi
2c2fa1
+fi
2c2fa1
+
2c2fa1
 
2c2fa1
 
2c2fa1
 subdirs="$subdirs testsuite"
2c2fa1
Index: gdb-7.6/gdb/configure.ac
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/configure.ac	2013-07-17 19:51:01.666356964 +0200
2c2fa1
+++ gdb-7.6/gdb/configure.ac	2013-07-17 19:51:02.692357665 +0200
2c2fa1
@@ -166,6 +166,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap
2c2fa1
 	      [Directories safe to hold auto-loaded files.])
2c2fa1
 AC_MSG_RESULT([$with_auto_load_safe_path])
2c2fa1
 
2c2fa1
+# Integration with rpm library to support missing debuginfo suggestions.
2c2fa1
+# --without-rpm: Disable any rpm support.
2c2fa1
+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
2c2fa1
+#   Even with runtime missing `libname.so' GDB will still other run correctly.
2c2fa1
+#   Missing `libname.so' during ./configure will abort the configuration.
2c2fa1
+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
2c2fa1
+#   minor version first such as `librpm-4.6.so' as minor version differences
2c2fa1
+#   mean API+ABI incompatibility.  If the specific match versioned library name
2c2fa1
+#   could not be found still open dynamically at least `librpm.so'.
2c2fa1
+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
2c2fa1
+#   to find librpm for compilation-time linking by pkg-config.  GDB binary will
2c2fa1
+#   be probably linked with the version specific library (as `librpm-4.6.so').
2c2fa1
+#   Failure to find librpm by pkg-config will abort the configuration.
2c2fa1
+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
2c2fa1
+#   cannot find librpm use to the rpmless compilation (like `--without-rpm').
2c2fa1
+
2c2fa1
+AC_ARG_WITH([rpm],
2c2fa1
+  [AS_HELP_STRING([--with-rpm],
2c2fa1
+                  [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
2c2fa1
+
2c2fa1
+m4_pattern_allow([^AC_MSG_ERROR$])
2c2fa1
+m4_pattern_allow([^AC_MSG_WARN$])
2c2fa1
+if test "x$with_rpm" != "xno"; then
2c2fa1
+  if test "x$with_rpm" = "xyes"; then
2c2fa1
+    LIBRPM="librpm.so"
2c2fa1
+    RPM_REQUIRE=true
2c2fa1
+    DLOPEN_REQUIRE=false
2c2fa1
+  elif test "x$with_rpm" = "xauto"; then
2c2fa1
+    LIBRPM="librpm.so"
2c2fa1
+    RPM_REQUIRE=false
2c2fa1
+    DLOPEN_REQUIRE=false
2c2fa1
+  else
2c2fa1
+    LIBRPM="$with_rpm"
2c2fa1
+    RPM_REQUIRE=true
2c2fa1
+    DLOPEN_REQUIRE=true
2c2fa1
+  fi
2c2fa1
+  LIBRPM_STRING='"'"$LIBRPM"'"'
2c2fa1
+
2c2fa1
+  AC_MSG_CHECKING([specific librpm version])
2c2fa1
+  HAVE_DLOPEN_LIBRPM=false
2c2fa1
+  save_LIBS="$LIBS"
2c2fa1
+  LIBS="$LIBS -ldl"
2c2fa1
+  AC_RUN_IFELSE(AC_LANG_PROGRAM([[
2c2fa1
+#include <rpm/rpmlib.h>
2c2fa1
+#include <dlfcn.h>
2c2fa1
+#include <errno.h>
2c2fa1
+  ]], [[
2c2fa1
+    void *h;
2c2fa1
+    const char *const *rpmverp;
2c2fa1
+    FILE *f;
2c2fa1
+
2c2fa1
+    f = fopen ("conftest.out", "w");
2c2fa1
+    if (!f)
2c2fa1
+      {
2c2fa1
+	fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
2c2fa1
+		 strerror (errno));
2c2fa1
+	return 1;
2c2fa1
+      }
2c2fa1
+    h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
2c2fa1
+    if (!h)
2c2fa1
+      {
2c2fa1
+	fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
2c2fa1
+	return 1;
2c2fa1
+      }
2c2fa1
+    rpmverp = dlsym (h, "RPMVERSION");
2c2fa1
+    if (!rpmverp)
2c2fa1
+      {
2c2fa1
+	fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
2c2fa1
+	return 1;
2c2fa1
+      }
2c2fa1
+    fprintf (stderr, "RPMVERSION is: \"");
2c2fa1
+    fprintf (stderr, "%s\"\n", *rpmverp);
2c2fa1
+
2c2fa1
+    /* Try to find the specific librpm version only for "librpm.so" as we do
2c2fa1
+       not know how to assemble the version string otherwise.  */
2c2fa1
+
2c2fa1
+    if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
2c2fa1
+      {
2c2fa1
+	fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	return 0;
2c2fa1
+      }
2c2fa1
+    else
2c2fa1
+      {
2c2fa1
+	char *h2_name;
2c2fa1
+	void *h2;
2c2fa1
+	int major, minor;
2c2fa1
+
2c2fa1
+	if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
2c2fa1
+	  {
2c2fa1
+	    fprintf (stderr, "Unable to parse RPMVERSION.\n");
2c2fa1
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+	/* Avoid the square brackets by malloc.  */
2c2fa1
+	h2_name = malloc (64);
2c2fa1
+	sprintf (h2_name, "librpm-%d.%d.so", major, minor);
2c2fa1
+	h2 = dlopen (h2_name, RTLD_LAZY);
2c2fa1
+	if (!h2)
2c2fa1
+	  {
2c2fa1
+	    fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
2c2fa1
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+	if (h2 != h)
2c2fa1
+	  {
2c2fa1
+	    fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
2c2fa1
+		     $LIBRPM_STRING, h2_name);
2c2fa1
+	    fprintf (f, "%s\n", $LIBRPM_STRING);
2c2fa1
+	    return 0;
2c2fa1
+	  }
2c2fa1
+	/* Found the valid .so name with a specific version.  */
2c2fa1
+	fprintf (f, "%s\n", h2_name);
2c2fa1
+	return 0;
2c2fa1
+      }
2c2fa1
+  ]]), [
2c2fa1
+    DLOPEN_LIBRPM="`cat conftest.out`"
2c2fa1
+    if test "x$DLOPEN_LIBRPM" != "x"; then
2c2fa1
+      HAVE_DLOPEN_LIBRPM=true
2c2fa1
+      AC_MSG_RESULT($DLOPEN_LIBRPM)
2c2fa1
+    fi
2c2fa1
+  ])
2c2fa1
+  rm -f conftest.out
2c2fa1
+
2c2fa1
+  m4_define([CHECK_LIBRPM_COMPAT], [
2c2fa1
+    AC_MSG_CHECKING([rpm library API compatibility])
2c2fa1
+    # The compilation requires -Werror to verify anything.
2c2fa1
+    save_CFLAGS="$CFLAGS"
2c2fa1
+    CFLAGS="$CFLAGS -Werror"
2c2fa1
+    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
2c2fa1
+/* Duplicate here the declarations to verify they match "elfread.c".  */
2c2fa1
+#include <rpm/rpmlib.h>
2c2fa1
+#include <rpm/rpmts.h>
2c2fa1
+#include <rpm/rpmdb.h>
2c2fa1
+#include <rpm/header.h>
2c2fa1
+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
2c2fa1
+extern int rpmReadConfigFiles(const char * file, const char * target);
2c2fa1
+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
2c2fa1
+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
2c2fa1
+extern rpmts rpmtsCreate(void);
2c2fa1
+extern rpmts rpmtsFree(rpmts ts);
2c2fa1
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
2c2fa1
+					    const void * keyp, size_t keylen);
2c2fa1
+    ]]), [
2c2fa1
+      LIBRPM_COMPAT=true
2c2fa1
+      AC_MSG_RESULT(yes)
2c2fa1
+    ], [
2c2fa1
+      LIBRPM_COMPAT=false
2c2fa1
+      AC_MSG_RESULT(no)
2c2fa1
+    ])
2c2fa1
+    CFLAGS="$save_CFLAGS"
2c2fa1
+  ])
2c2fa1
+
2c2fa1
+  if $HAVE_DLOPEN_LIBRPM; then
2c2fa1
+    CHECK_LIBRPM_COMPAT
2c2fa1
+    if ! $LIBRPM_COMPAT; then
2c2fa1
+      HAVE_DLOPEN_LIBRPM=false
2c2fa1
+    fi
2c2fa1
+  fi
2c2fa1
+
2c2fa1
+  if $HAVE_DLOPEN_LIBRPM; then
2c2fa1
+    DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
2c2fa1
+    AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
2c2fa1
+    AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
2c2fa1
+  else
2c2fa1
+    AC_MSG_RESULT(no)
2c2fa1
+    LIBS="$save_LIBS"
2c2fa1
+    if $DLOPEN_REQUIRE; then
2c2fa1
+      AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
2c2fa1
+    fi
2c2fa1
+    PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
2c2fa1
+
2c2fa1
+    if $HAVE_LIBRPM; then
2c2fa1
+      CHECK_LIBRPM_COMPAT
2c2fa1
+      if ! $LIBRPM_COMPAT; then
2c2fa1
+	HAVE_LIBRPM=false
2c2fa1
+	RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
2c2fa1
+      fi
2c2fa1
+    fi
2c2fa1
+
2c2fa1
+    if $HAVE_LIBRPM; then
2c2fa1
+      AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
2c2fa1
+      CFLAGS="$CFLAGS $RPM_CFLAGS"
2c2fa1
+      LIBS="$LIBS $RPM_LIBS"
2c2fa1
+    else
2c2fa1
+      if $RPM_REQUIRE; then
2c2fa1
+	AC_MSG_ERROR($RPM_PKG_ERRORS)
2c2fa1
+      else
2c2fa1
+	AC_MSG_WARN($RPM_PKG_ERRORS)
2c2fa1
+      fi
2c2fa1
+    fi
2c2fa1
+  fi
2c2fa1
+fi
2c2fa1
+ 
2c2fa1
 AC_CONFIG_SUBDIRS(testsuite)
2c2fa1
 
2c2fa1
 # Check whether to support alternative target configurations
2c2fa1
Index: gdb-7.6/gdb/corelow.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.orig/gdb/corelow.c	2013-07-17 19:51:02.608357607 +0200
2c2fa1
+++ gdb-7.6/gdb/corelow.c	2013-07-17 19:51:02.692357665 +0200
2c2fa1
@@ -314,7 +314,7 @@ build_id_locate_exec (int from_tty)
2c2fa1
         symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
2c2fa1
     }
2c2fa1
   else
2c2fa1
-    debug_print_missing (_("the main executable file"), build_id_filename);
2c2fa1
+    debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
2c2fa1
 
2c2fa1
   do_cleanups (back_to);
2c2fa1