5ced33e
2005-04-02  Andrew Cagney  <cagney@gnu.org>
5ced33e
5ced33e
	* symfile.c (separate_debug_file_exists): When the CRCs mismatch
5ced33e
	print a warning.
5ced33e
	(find_separate_debug_file): Pass in the objfile's name.
5ced33e
8b1b3fd
Index: gdb-6.8/gdb/symfile.c
8b1b3fd
===================================================================
8b1b3fd
--- gdb-6.8.orig/gdb/symfile.c	2008-01-29 23:47:20.000000000 +0100
8b1b3fd
+++ gdb-6.8/gdb/symfile.c	2008-07-14 10:26:30.000000000 +0200
8b1b3fd
@@ -1348,7 +1348,8 @@ get_debug_link_info (struct objfile *obj
5ced33e
 }
5ced33e
 
5ced33e
 static int
5ced33e
-separate_debug_file_exists (const char *name, unsigned long crc)
5ced33e
+separate_debug_file_exists (const char *name, unsigned long crc,
5ced33e
+			    const char *parent_name)
5ced33e
 {
5ced33e
   unsigned long file_crc = 0;
5ced33e
   int fd;
8b1b3fd
@@ -1357,6 +1358,12 @@ separate_debug_file_exists (const char *
5ced33e
 
5ced33e
   fd = open (name, O_RDONLY | O_BINARY);
5ced33e
   if (fd < 0)
5ced33e
+    /* Fail silently, this preserves existing behavior.  The
5ced33e
+       assumption here is that the file wasn't found because there's
5ced33e
+       no file to find (we shouldn't be printing warnings about
5ced33e
+       missing debug info files when the user hasn't installed them).
5ced33e
+       The alternative is to complain here - that better belongs in a
5ced33e
+       warning.  */
5ced33e
     return 0;
5ced33e
 
5ced33e
   while ((count = read (fd, buffer, sizeof (buffer))) > 0)
8b1b3fd
@@ -1364,7 +1371,16 @@ separate_debug_file_exists (const char *
5ced33e
 
5ced33e
   close (fd);
5ced33e
 
5ced33e
-  return crc == file_crc;
5ced33e
+  if (crc != file_crc)
5ced33e
+    {
5ced33e
+      warning (_("the debug information found in \"%s\""
5ced33e
+		 " does not match \"%s\" (CRC mismatch).\n"),
5ced33e
+	       name, parent_name);
5ced33e
+      return 0;
5ced33e
+    }
5ced33e
+
5ced33e
+  /* No worries!  */
5ced33e
+  return 1;
5ced33e
 }
5ced33e
 
8b1b3fd
 char *debug_file_directory = NULL;
8b1b3fd
@@ -1416,6 +1432,8 @@ find_separate_debug_file (struct objfile
5ced33e
   basename = get_debug_link_info (objfile, &crc32);
5ced33e
 
5ced33e
   if (basename == NULL)
5ced33e
+    /* There's no separate debug info, hence there's no way we could
5ced33e
+       load it => no warning.  */
5ced33e
     return NULL;
5ced33e
 
5ced33e
   dir = xstrdup (objfile->name);
8b1b3fd
@@ -1443,7 +1461,7 @@ find_separate_debug_file (struct objfile
5ced33e
   strcpy (debugfile, dir);
5ced33e
   strcat (debugfile, basename);
5ced33e
 
5ced33e
-  if (separate_debug_file_exists (debugfile, crc32))
5ced33e
+  if (separate_debug_file_exists (debugfile, crc32, objfile->name))
5ced33e
     {
5ced33e
       xfree (basename);
5ced33e
       xfree (dir);
8b1b3fd
@@ -1456,7 +1474,7 @@ find_separate_debug_file (struct objfile
5ced33e
   strcat (debugfile, "/");
5ced33e
   strcat (debugfile, basename);
5ced33e
 
5ced33e
-  if (separate_debug_file_exists (debugfile, crc32))
5ced33e
+  if (separate_debug_file_exists (debugfile, crc32, objfile->name))
5ced33e
     {
5ced33e
       xfree (basename);
5ced33e
       xfree (dir);
8b1b3fd
@@ -1469,7 +1487,7 @@ find_separate_debug_file (struct objfile
5ced33e
   strcat (debugfile, dir);
5ced33e
   strcat (debugfile, basename);
5ced33e
 
5ced33e
-  if (separate_debug_file_exists (debugfile, crc32))
5ced33e
+  if (separate_debug_file_exists (debugfile, crc32, objfile->name))
5ced33e
     {
5ced33e
       xfree (basename);
5ced33e
       xfree (dir);
8b1b3fd
@@ -1488,7 +1506,7 @@ find_separate_debug_file (struct objfile
eb9d945
       strcat (debugfile, "/");
eb9d945
       strcat (debugfile, basename);
eb9d945
 
eb9d945
-      if (separate_debug_file_exists (debugfile, crc32))
eb9d945
+      if (separate_debug_file_exists (debugfile, crc32, objfile->name))
eb9d945
 	{
eb9d945
 	  xfree (canon_name);
8b1b3fd
 	  xfree (basename);