summaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorJerome Guitton <guitton@adacore.com>2009-04-27 11:57:46 +0000
committerJerome Guitton <guitton@adacore.com>2009-04-27 11:57:46 +0000
commitaaea5a06cc659c0642131b604f1f0fc18cb7a3d3 (patch)
tree2d23c27438abf496dcf2127f0b87f2fb832ae29e /gdb/symtab.c
parentc9f10fca16d924d653e9b65a8b0637e678dac17e (diff)
downloadgdb-aaea5a06cc659c0642131b604f1f0fc18cb7a3d3.tar.gz
* 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.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c93
1 files changed, 58 insertions, 35 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 622ddd35955..b8a6c31b1b0 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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