diff options
author | Jerome Guitton <guitton@adacore.com> | 2009-04-27 11:57:46 +0000 |
---|---|---|
committer | Jerome Guitton <guitton@adacore.com> | 2009-04-27 11:57:46 +0000 |
commit | aad80b26837bc6067e7121859e6a5776388764bb (patch) | |
tree | 1ad5f3b5f3a0056f90ec10afedb11fa2483fb045 /gdb/symtab.c | |
parent | df1756f414a26ac33aa2d0dbe6d757e214e45419 (diff) | |
download | gdb-aad80b26837bc6067e7121859e6a5776388764bb.zip gdb-aad80b26837bc6067e7121859e6a5776388764bb.tar.gz gdb-aad80b26837bc6067e7121859e6a5776388764bb.tar.bz2 |
* 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.c | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 622ddd3..b8a6c31 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 |