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
5ced33e
--- ../gdb-6.3/./gdb/symfile.c	2005-04-02 16:02:22.000000000 -0500
5ced33e
+++ ./gdb/symfile.c	2005-04-02 13:05:10.000000000 -0500
5ced33e
@@ -1043,7 +1043,8 @@
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;
5ced33e
@@ -1052,6 +1053,12 @@
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)
5ced33e
@@ -1059,7 +1066,16 @@
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
 
5ced33e
 static char *debug_file_directory = NULL;
5ced33e
@@ -1083,6 +1099,8 @@
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);
5ced33e
@@ -1110,7 +1128,7 @@
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);
5ced33e
@@ -1123,7 +1141,7 @@
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);
5ced33e
@@ -1136,7 +1154,7 @@
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);