Don't compute CRC32s that we know will fail.
authorSøren Sandmann Pedersen <sandmann@daimi.au.dk>
Tue, 9 Nov 2010 06:40:16 +0000 (01:40 -0500)
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>
Thu, 27 Jan 2011 22:00:02 +0000 (17:00 -0500)
If two files both have build-ids and those build-ids don't match,
there is no point computing the CRCs.

binfile.c

index 95613db..8a2cfed 100644 (file)
--- a/binfile.c
+++ b/binfile.c
@@ -158,11 +158,14 @@ get_debuglink_file (ElfParser   *elf,
     guint32 crc32;
     GList *tries = NULL, *list;
     ElfParser *result = NULL;
+    const char *build_id;
     
     if (!elf)
        return NULL;
     
     basename = elf_parser_get_debug_link (elf, &crc32);
+
+    build_id = elf_parser_get_build_id (elf);
     
 #if 0
     g_print ("   debug link for %s is %s\n", filename, basename);
@@ -183,9 +186,18 @@ get_debuglink_file (ElfParser   *elf,
        const char *name = list->data;
        ElfParser *parser = elf_parser_new (name, NULL);
        guint32 file_crc;
+       const char *file_build_id;
        
        if (parser)
        {
+           /* If both files have build ids, and they don't match,
+            * there is no point computing a CRC32 that we know
+            * will fail
+            */
+           file_build_id = elf_parser_get_build_id (parser);
+           if (build_id && file_build_id && strcmp (build_id, file_build_id) != 0)
+               goto skip;
+
            file_crc = elf_parser_get_crc32 (parser);
            
            if (file_crc == crc32)
@@ -197,9 +209,13 @@ get_debuglink_file (ElfParser   *elf,
            else
            {
                if (!already_warned (name))
-                   g_print ("warning: %s has wrong crc \n", name);
+               {
+                   g_print ("warning: %s has wrong crc %x, %s has crc %x)\n",
+                            name, file_crc, filename, crc32);
+               }
            }
-           
+
+       skip:
            elf_parser_free (parser);
        }
     }
@@ -430,7 +446,7 @@ bin_file_lookup_symbol (bin_file_t    *bin_file,
 
 gboolean
 bin_file_check_inode (bin_file_t *bin_file,
-                     ino_t    inode)
+                     ino_t       inode)
 {
     if (bin_file->inode == inode)
        return TRUE;