* symtab.c (append_exact_match_to_sals): New function, extracted
authorJerome Guitton <guitton@adacore.com>
Mon, 27 Apr 2009 11:57:46 +0000 (11:57 +0000)
committerJerome Guitton <guitton@adacore.com>
Mon, 27 Apr 2009 11:57:46 +0000 (11:57 +0000)
from expand_line_sal.
(expand_line_sal): Use append_exact_match_to_sals to append exact
matches. If none found, append all best items.

gdb/ChangeLog
gdb/symtab.c

index 8025d706695281e155a30d626d2a43b359fbcc6a..1d932f85a95bc54c7b65222dff7c43dd5dd036f3 100644 (file)
@@ -1,3 +1,10 @@
+2009-04-27  Jerome Guitton  <guitton@adacore.com>
+
+       * symtab.c (append_exact_match_to_sals): New function, extracted
+       from expand_line_sal.
+       (expand_line_sal): Use append_exact_match_to_sals to append exact
+       matches. If none found, append all best items.
+
 2009-04-27  Jerome Guitton  <guitton@adacore.com>
 
        * main.c (captured_main): Move gdbinit lookups after gdb_init.
index 622ddd35955c50ada5402e5fac43562722daeace..b8a6c31b1b04c5253ee062e973ebdb2b45882c01 100644 (file)
@@ -4460,6 +4460,57 @@ append_expanded_sal (struct symtabs_and_lines *sal,
   ++sal->nelts;
 }
 
+/* Helper to expand_line_sal below.  Search in the symtabs for any
+   linetable entry that exactly matches FILENAME and LINENO and append
+   them to RET. If there is at least one match, return 1; otherwise,
+   return 0, and return the best choice in BEST_ITEM and BEST_SYMTAB.  */
+
+static int
+append_exact_match_to_sals (char *filename, int lineno,
+                           struct symtabs_and_lines *ret,
+                           struct linetable_entry **best_item,
+                           struct symtab **best_symtab)
+{
+  struct objfile *objfile;
+  struct symtab *symtab;
+  int exact = 0;
+  int j;
+  *best_item = 0;
+  *best_symtab = 0;
+  
+  ALL_SYMTABS (objfile, symtab)
+    {
+      if (strcmp (filename, symtab->filename) == 0)
+       {
+         struct linetable *l;
+         int len;
+         l = LINETABLE (symtab);
+         if (!l)
+           continue;
+         len = l->nitems;
+
+         for (j = 0; j < len; j++)
+           {
+             struct linetable_entry *item = &(l->item[j]);
+
+             if (item->line == lineno)
+               {
+                 exact = 1;
+                 append_expanded_sal (ret, symtab, lineno, item->pc);
+               }
+             else if (!exact && item->line > lineno
+                      && (*best_item == NULL
+                          || item->line < (*best_item)->line))
+               {
+                 *best_item = item;
+                 *best_symtab = symtab;
+               }
+           }
+       }
+    }
+  return exact;
+}
+
 /* Compute a set of all sals in
    the entire program that correspond to same file
    and line as SAL and return those.  If there
@@ -4515,42 +4566,14 @@ expand_line_sal (struct symtab_and_line sal)
            PSYMTAB_TO_SYMTAB (psymtab);
        }
 
-      /* For each symtab, we add all pcs to ret.sals.  I'm actually
-        not sure what to do if we have exact match in one symtab,
-        and non-exact match on another symtab.  */
-
-      ALL_SYMTABS (objfile, symtab)
-       {
-         if (strcmp (sal.symtab->filename,
-                     symtab->filename) == 0)
-           {
-             struct linetable *l;
-             int len;
-             l = LINETABLE (symtab);
-             if (!l)
-               continue;
-             len = l->nitems;
-
-             for (j = 0; j < len; j++)
-               {
-                 struct linetable_entry *item = &(l->item[j]);
-
-                 if (item->line == lineno)
-                   {
-                     exact = 1;
-                     append_expanded_sal (&ret, symtab, lineno, item->pc);
-                   }
-                 else if (!exact && item->line > lineno
-                          && (best_item == NULL || item->line < best_item->line))
-                   {
-                     best_item = item;
-                     best_symtab = symtab;
-                   }
-               }
-           }
-       }
+      /* Now search the symtab for exact matches and append them.  If
+        none is found, append the best_item and all its exact
+        matches.  */
+      exact = append_exact_match_to_sals (sal.symtab->filename, lineno,
+                                         &ret, &best_item, &best_symtab);
       if (!exact && best_item)
-       append_expanded_sal (&ret, best_symtab, lineno, best_item->pc);
+       append_exact_match_to_sals (best_symtab->filename, best_item->line,
+                                   &ret, &best_item, &best_symtab);
     }
 
   /* For optimized code, compiler can scatter one source line accross
This page took 0.0614400000000001 seconds and 4 git commands to generate.