Code cleanup.
	* dictionary.c
	(struct dict_vector) <iter_match_first, iter_match_next>
	(iter_match_first_hashed, iter_match_next_hashed)
	(iter_match_first_linear, iter_match_next_linear)
	(dict_iter_match_first, dict_iter_match_next, iter_match_first_hashed)
	(iter_match_next_hashed, iter_match_first_linear)
	(iter_match_next_linear): Use symbol_compare_ftype.
	* dictionary.h: Include symfile.h.
	(dict_iter_match_first, dict_iter_match_next): Use
	symbol_compare_ftype.
	* dwarf2read.c (dw2_map_matching_symbols): Likewise.
	* psymtab.c (match_partial_symbol, match_partial_symbol, map_block)
	(map_matching_symbols_psymtab): Likewise.
	* symfile.h (symbol_compare_ftype): New typedef.
	(struct quick_symbol_functions) <map_matching_symbols): Use
	symbol_compare_ftype.
This commit is contained in:
Jan Kratochvil 2010-11-24 19:01:51 +00:00
parent f6df29bc29
commit 2edb89d30e
6 changed files with 55 additions and 50 deletions

View file

@ -1,3 +1,23 @@
2010-11-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* dictionary.c
(struct dict_vector) <iter_match_first, iter_match_next>
(iter_match_first_hashed, iter_match_next_hashed)
(iter_match_first_linear, iter_match_next_linear)
(dict_iter_match_first, dict_iter_match_next, iter_match_first_hashed)
(iter_match_next_hashed, iter_match_first_linear)
(iter_match_next_linear): Use symbol_compare_ftype.
* dictionary.h: Include symfile.h.
(dict_iter_match_first, dict_iter_match_next): Use
symbol_compare_ftype.
* dwarf2read.c (dw2_map_matching_symbols): Likewise.
* psymtab.c (match_partial_symbol, match_partial_symbol, map_block)
(map_matching_symbols_psymtab): Likewise.
* symfile.h (symbol_compare_ftype): New typedef.
(struct quick_symbol_functions) <map_matching_symbols): Use
symbol_compare_ftype.
2010-11-23 Tom Tromey <tromey@redhat.com> 2010-11-23 Tom Tromey <tromey@redhat.com>
* configure: Rebuild. * configure: Rebuild.

View file

@ -118,13 +118,11 @@ struct dict_vector
struct symbol *(*iterator_next) (struct dict_iterator *iterator); struct symbol *(*iterator_next) (struct dict_iterator *iterator);
/* Functions to iterate over symbols with a given name. */ /* Functions to iterate over symbols with a given name. */
struct symbol *(*iter_match_first) (const struct dictionary *dict, struct symbol *(*iter_match_first) (const struct dictionary *dict,
const char *name, const char *name,
int (*equiv) (const char *, symbol_compare_ftype *equiv,
const char *), struct dict_iterator *iterator);
struct dict_iterator *iterator);
struct symbol *(*iter_match_next) (const char *name, struct symbol *(*iter_match_next) (const char *name,
int (*equiv) (const char *, symbol_compare_ftype *equiv,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
/* A size function, for maint print symtabs. */ /* A size function, for maint print symtabs. */
int (*size) (const struct dictionary *dict); int (*size) (const struct dictionary *dict);
@ -243,13 +241,11 @@ static struct symbol *iterator_next_hashed (struct dict_iterator *iterator);
static struct symbol *iter_match_first_hashed (const struct dictionary *dict, static struct symbol *iter_match_first_hashed (const struct dictionary *dict,
const char *name, const char *name,
int (*compare) (const char *, symbol_compare_ftype *compare,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
static struct symbol *iter_match_next_hashed (const char *name, static struct symbol *iter_match_next_hashed (const char *name,
int (*compare) (const char *, symbol_compare_ftype *compare,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
static unsigned int dict_hash (const char *string); static unsigned int dict_hash (const char *string);
@ -277,13 +273,11 @@ static struct symbol *iterator_next_linear (struct dict_iterator *iterator);
static struct symbol *iter_match_first_linear (const struct dictionary *dict, static struct symbol *iter_match_first_linear (const struct dictionary *dict,
const char *name, const char *name,
int (*compare) (const char *, symbol_compare_ftype *compare,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
static struct symbol *iter_match_next_linear (const char *name, static struct symbol *iter_match_next_linear (const char *name,
int (*compare) (const char *, symbol_compare_ftype *compare,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
static int size_linear (const struct dictionary *dict); static int size_linear (const struct dictionary *dict);
@ -542,16 +536,14 @@ dict_iter_name_next (const char *name, struct dict_iterator *iterator)
struct symbol * struct symbol *
dict_iter_match_first (const struct dictionary *dict, dict_iter_match_first (const struct dictionary *dict,
const char *name, const char *name, symbol_compare_ftype *compare,
int (*compare) (const char *, const char *),
struct dict_iterator *iterator) struct dict_iterator *iterator)
{ {
return (DICT_VECTOR (dict))->iter_match_first (dict, name, compare, iterator); return (DICT_VECTOR (dict))->iter_match_first (dict, name, compare, iterator);
} }
struct symbol * struct symbol *
dict_iter_match_next (const char *name, dict_iter_match_next (const char *name, symbol_compare_ftype *compare,
int (*compare) (const char *, const char *),
struct dict_iterator *iterator) struct dict_iterator *iterator)
{ {
return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator))) return (DICT_VECTOR (DICT_ITERATOR_DICT (iterator)))
@ -646,9 +638,8 @@ iterator_hashed_advance (struct dict_iterator *iterator)
} }
static struct symbol * static struct symbol *
iter_match_first_hashed (const struct dictionary *dict, iter_match_first_hashed (const struct dictionary *dict, const char *name,
const char *name, symbol_compare_ftype *compare,
int (*compare) (const char *, const char *),
struct dict_iterator *iterator) struct dict_iterator *iterator)
{ {
unsigned int hash_index = dict_hash (name) % DICT_HASHED_NBUCKETS (dict); unsigned int hash_index = dict_hash (name) % DICT_HASHED_NBUCKETS (dict);
@ -677,8 +668,7 @@ iter_match_first_hashed (const struct dictionary *dict,
} }
static struct symbol * static struct symbol *
iter_match_next_hashed (const char *name, iter_match_next_hashed (const char *name, symbol_compare_ftype *compare,
int (*compare) (const char *, const char *),
struct dict_iterator *iterator) struct dict_iterator *iterator)
{ {
struct symbol *next; struct symbol *next;
@ -868,8 +858,7 @@ iterator_next_linear (struct dict_iterator *iterator)
static struct symbol * static struct symbol *
iter_match_first_linear (const struct dictionary *dict, iter_match_first_linear (const struct dictionary *dict,
const char *name, const char *name, symbol_compare_ftype *compare,
int (*compare) (const char *, const char *),
struct dict_iterator *iterator) struct dict_iterator *iterator)
{ {
DICT_ITERATOR_DICT (iterator) = dict; DICT_ITERATOR_DICT (iterator) = dict;
@ -879,8 +868,7 @@ iter_match_first_linear (const struct dictionary *dict,
} }
static struct symbol * static struct symbol *
iter_match_next_linear (const char *name, iter_match_next_linear (const char *name, symbol_compare_ftype *compare,
int (*compare) (const char *, const char *),
struct dict_iterator *iterator) struct dict_iterator *iterator)
{ {
const struct dictionary *dict = DICT_ITERATOR_DICT (iterator); const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);

View file

@ -23,6 +23,8 @@
#ifndef DICTIONARY_H #ifndef DICTIONARY_H
#define DICTIONARY_H #define DICTIONARY_H
#include "symfile.h"
/* An opaque type for dictionaries; only dictionary.c should know /* An opaque type for dictionaries; only dictionary.c should know
about its innards. */ about its innards. */
@ -142,8 +144,7 @@ extern struct symbol *dict_iter_name_next (const char *name,
extern struct symbol *dict_iter_match_first (const struct dictionary *dict, extern struct symbol *dict_iter_match_first (const struct dictionary *dict,
const char *name, const char *name,
int (*compare) (const char*, symbol_compare_ftype *compare,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
/* Advance ITERATOR to point at the next symbol in DICT whose /* Advance ITERATOR to point at the next symbol in DICT whose
@ -155,8 +156,7 @@ extern struct symbol *dict_iter_match_first (const struct dictionary *dict,
previous call to dict_iter_match_first with the same NAME and COMPARE. */ previous call to dict_iter_match_first with the same NAME and COMPARE. */
extern struct symbol *dict_iter_match_next (const char *name, extern struct symbol *dict_iter_match_next (const char *name,
int (*compare) (const char*, symbol_compare_ftype *compare,
const char *),
struct dict_iterator *iterator); struct dict_iterator *iterator);
/* Return some notion of the size of the dictionary: the number of /* Return some notion of the size of the dictionary: the number of

View file

@ -2383,10 +2383,8 @@ dw2_map_matching_symbols (const char * name, domain_enum namespace,
struct objfile *objfile, int global, struct objfile *objfile, int global,
int (*callback) (struct block *, int (*callback) (struct block *,
struct symbol *, void *), struct symbol *, void *),
void *data, void *data, symbol_compare_ftype *match,
int (*match) (const char *, const char *), symbol_compare_ftype *ordered_compare)
int (*ordered_compare) (const char *,
const char *))
{ {
/* Currently unimplemented; used for Ada. The function can be called if the /* Currently unimplemented; used for Ada. The function can be called if the
current language is Ada for a non-Ada objfile using GNU index. As Ada current language is Ada for a non-Ada objfile using GNU index. As Ada

View file

@ -50,11 +50,8 @@ struct psymbol_bcache
static struct partial_symbol *match_partial_symbol (struct partial_symtab *, static struct partial_symbol *match_partial_symbol (struct partial_symtab *,
int, int,
const char *, domain_enum, const char *, domain_enum,
int (*) (const char *, symbol_compare_ftype *,
const char *), symbol_compare_ftype *);
int (*) (const char *,
const char *));
static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *, static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
const char *, int, const char *, int,
@ -446,8 +443,8 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
static struct partial_symbol * static struct partial_symbol *
match_partial_symbol (struct partial_symtab *pst, int global, match_partial_symbol (struct partial_symtab *pst, int global,
const char *name, domain_enum domain, const char *name, domain_enum domain,
int (*match) (const char *, const char *), symbol_compare_ftype *match,
int (*ordered_compare) (const char *, const char *)) symbol_compare_ftype *ordered_compare)
{ {
struct partial_symbol **start, **psym; struct partial_symbol **start, **psym;
struct partial_symbol **top, **real_top, **bottom, **center; struct partial_symbol **top, **real_top, **bottom, **center;
@ -1064,8 +1061,7 @@ static int
map_block (const char *name, domain_enum namespace, struct objfile *objfile, map_block (const char *name, domain_enum namespace, struct objfile *objfile,
struct block *block, struct block *block,
int (*callback) (struct block *, struct symbol *, void *), int (*callback) (struct block *, struct symbol *, void *),
void *data, void *data, symbol_compare_ftype *match)
int (*match) (const char *, const char *))
{ {
struct dict_iterator iter; struct dict_iterator iter;
struct symbol *sym; struct symbol *sym;
@ -1093,9 +1089,8 @@ map_matching_symbols_psymtab (const char *name, domain_enum namespace,
int (*callback) (struct block *, int (*callback) (struct block *,
struct symbol *, void *), struct symbol *, void *),
void *data, void *data,
int (*match) (const char *, const char *), symbol_compare_ftype *match,
int (*ordered_compare) (const char *, symbol_compare_ftype *ordered_compare)
const char *))
{ {
const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
struct partial_symtab *ps; struct partial_symtab *ps;

View file

@ -32,6 +32,11 @@ struct obj_section;
struct obstack; struct obstack;
struct block; struct block;
/* Comparison function for symbol look ups. */
typedef int (symbol_compare_ftype) (const char *string1,
const char *string2);
/* Partial symbols are stored in the psymbol_cache and pointers to /* Partial symbols are stored in the psymbol_cache and pointers to
them are kept in a dynamically grown array that is obtained from them are kept in a dynamically grown array that is obtained from
malloc and grown as necessary via realloc. Each objfile typically malloc and grown as necessary via realloc. Each objfile typically
@ -234,9 +239,8 @@ struct quick_symbol_functions
int (*callback) (struct block *, int (*callback) (struct block *,
struct symbol *, void *), struct symbol *, void *),
void *data, void *data,
int (*match) (const char *, const char *), symbol_compare_ftype *match,
int (*ordered_compare) (const char *, symbol_compare_ftype *ordered_compare);
const char *));
/* Expand all symbol tables in OBJFILE matching some criteria. /* Expand all symbol tables in OBJFILE matching some criteria.