daily update
[external/binutils.git] / gprof / corefile.c
index fd4644b..e25d19b 100644 (file)
@@ -22,6 +22,7 @@
 \f
 #include "gprof.h"
 #include "libiberty.h"
+#include "filenames.h"
 #include "search_list.h"
 #include "source.h"
 #include "symtab.h"
@@ -157,7 +158,8 @@ read_function_mappings (const char *filename)
   symbol_map_count = count;
 
   for (i = 0; i < symbol_map_count; ++i)
-    if (i == 0 || strcmp (symbol_map[i].file_name, symbol_map[i - 1].file_name))
+    if (i == 0
+        || filename_cmp (symbol_map[i].file_name, symbol_map[i - 1].file_name))
       symbol_map[i].is_first = 1;
 
   qsort (symbol_map, symbol_map_count, sizeof (struct function_map), cmp_symbol_map);
@@ -385,19 +387,27 @@ core_sym_class (asymbol *sym)
       if (*name == '$')
         return 0;
 
-      if (*name == '.')
+      while (*name == '.')
        {
-         /* Allow GCC cloned functions.  */
-         if (strlen (name) > 7 && strncmp (name, ".clone.", 7) == 0)
-           name += 6;
+         /* Allow both nested subprograms (which end with ".NNN", where N is
+            a digit) and GCC cloned functions (which contain ".clone").
+            Allow for multiple iterations of both - apparently GCC can clone
+            clones and subprograms.  */
+         int digit_seen = 0;
+#define CLONE_NAME      ".clone."
+#define CLONE_NAME_LEN  strlen (CLONE_NAME)
+             
+         if (strlen (name) > CLONE_NAME_LEN
+             && strncmp (name, CLONE_NAME, CLONE_NAME_LEN) == 0)
+           name += CLONE_NAME_LEN - 1;
 
-         /* Do not discard nested subprograms (those
-            which end with .NNN, where N are digits).  */
          for (name++; *name; name++)
-           if (! ISDIGIT (*name))
+           if (digit_seen && *name == '.')
+             break;
+           else if (ISDIGIT (*name))
+             digit_seen = 1;
+           else
              return 0;
-
-         break;
        }
     }
 
@@ -766,7 +776,7 @@ core_create_line_syms (void)
          || (prev_line_num == dummy.line_num
              && prev_name != NULL
              && strcmp (prev_name, dummy.name) == 0
-             && strcmp (prev_filename, filename) == 0))
+             && filename_cmp (prev_filename, filename) == 0))
        continue;
 
       ++ltab.len;
@@ -831,7 +841,7 @@ core_create_line_syms (void)
       if (!get_src_info (vma, &filename, &ltab.limit->name, &ltab.limit->line_num)
          || (prev && prev->line_num == ltab.limit->line_num
              && strcmp (prev->name, ltab.limit->name) == 0
-             && strcmp (prev->file->name, filename) == 0))
+             && filename_cmp (prev->file->name, filename) == 0))
        continue;
 
       /* Make name pointer a malloc'ed string.  */