diff options
author | Paul N. Hilfinger <hilfinger@adacore.com> | 2010-10-07 07:13:51 +0000 |
---|---|---|
committer | Paul N. Hilfinger <hilfinger@adacore.com> | 2010-10-07 07:13:51 +0000 |
commit | 40658b9446ce0507f120bdc69c51c3dfbfd35381 (patch) | |
tree | bf7dc4987b4885a535d3481cf952858337588741 /gdb/symfile.h | |
parent | c4d840bdd6f9e19843bd35835cc08e992fe5e1db (diff) | |
download | gdb-40658b9446ce0507f120bdc69c51c3dfbfd35381.zip gdb-40658b9446ce0507f120bdc69c51c3dfbfd35381.tar.gz gdb-40658b9446ce0507f120bdc69c51c3dfbfd35381.tar.bz2 |
Rework symbol searches to move Ada-specific stuff to ada-lang.c.
This is a clean-up of some of our symbol-lookup machinery to pull some
kludgy Ada-specific definitions out of psymtab.c. In place of
map_ada_symtabs and ada_lookup_partial_symbol, we have a method
map_matching_symbols, which searches through all symbol tables and
partial symbol tables looking for a symbol that matches according to
a matching function that is passed as a parameter. This requires some
care, because partial symbol tables speed up searches by binary search,
while full symbol tables use hashing. To call map_matching_symbols, therefore,
you may need to supply both a matching function that is compatible with the
dictionary hash function and an ordering relation that is compatible with
strcmp_iw, which is used to order partial symbol tables.
Having added this general routine to psymtab.c, we use it in ada-lang.c
to rework add_non_local_symbols (now renamed add_nonlocal_symbols).
Changelog:
gdb/
* ada-lang.c (full_match): Declare.
(ada_match_name): Rename to match_name (we should avoid prefixing static
symbols with "ada_").
(match_name): New name for ada_match_name.
(struct ada_psym_data): Remove and replace with...
(struct match_data): User data for map_matching_symbols.
(ada_add_psyms): Remove.
(aux_add_nonlocal_symbols): New function, used as callback for
map_matching_symbols.
(compare_names): Ordering function adopted from strcmp_iw for Ada-encoded
symbols.
(ada_add_non_local_symbols): Rename to add_nonlocal_symbols.
(add_nonlocal_symbols): Renamed from ada_add_non_local_symbols.
Rework to use map_matching_symbols instead of map_ada_symtabs.
(ada_lookup_symbol_list): Use add_nonlocal_symbols.
* psymtab.c: Include dependency on dictionary.h.
(match_partial_symbol): New function.
(ada_lookup_partial_symbol): Remove.
(map_block): New function, auxiliary to map_matching_symbols_psymtab.
(map_matching_symbols_psymtab): New function.
(psym_functions): Replace map_ada_symtabs with map_matching_symbols_psymtab.
* symfile.h: Replace map_ada_symtabs definition with map_matching_symbols.
Diffstat (limited to 'gdb/symfile.h')
-rw-r--r-- | gdb/symfile.h | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/gdb/symfile.h b/gdb/symfile.h index f9b4e01..c9f4e65 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -212,21 +212,31 @@ struct quick_symbol_functions named NAME. If no such symbol exists in OBJFILE, return NULL. */ const char *(*find_symbol_file) (struct objfile *objfile, const char *name); - /* This method is specific to Ada. It walks the partial symbol - tables of OBJFILE looking for a name match. WILD_MATCH and - IS_NAME_SUFFIX are predicate functions that the implementation - may call to check for a match. - - This function is completely ad hoc and new implementations should - refer to the psymtab implementation to see what to do. */ - void (*map_ada_symtabs) (struct objfile *objfile, - int (*wild_match) (const char *, const char *), - int (*is_name_suffix) (const char *), - void (*callback) (struct objfile *, - struct symtab *, void *), - const char *name, int global, - domain_enum namespace, int wild, - void *data); + /* Find global or static symbols in all tables that are in NAMESPACE + and for which MATCH (symbol name, NAME) == 0, passing each to + CALLBACK, reading in partial symbol symbol tables as needed. Look + through global symbols if GLOBAL and otherwise static symbols. + Passes NAME, NAMESPACE, and DATA to CALLBACK with each symbol + found. After each block is processed, passes NULL to CALLBACK. + MATCH must be weaker than strcmp_iw in the sense that + strcmp_iw(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE, if + non-null, must be an ordering relation compatible with strcmp_iw + in the sense that + strcmp(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0 + and + strcmp(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0 + (allowing strcmp(x,y) < 0 while ORDERED_COMPARE(x, y) == 0). + CALLBACK returns 0 to indicate that the scan should continue, or + non-zero to indicate that the scan should be terminated. */ + + void (*map_matching_symbols) (const char *name, domain_enum namespace, + struct objfile *, int global, + int (*callback) (struct block *, + struct symbol *, void *), + void *data, + int (*match) (const char *, const char *), + int (*ordered_compare) (const char *, + const char *)); /* Expand all symbol tables in OBJFILE matching some criteria. |