diff options
author | Joel Brobecker <brobecker@gnat.com> | 2012-06-05 13:50:50 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2012-06-05 13:50:50 +0000 |
commit | 19630284f570790ebf6d50bfb43caa1f125ee88a (patch) | |
tree | 1ae3d6f4c3a0fb1e045313bcead7b3f6c562a3fb /gdb/findvar.c | |
parent | 67ff19f7de8c61147c5401c7f56ad30fda0f5491 (diff) | |
download | gdb-19630284f570790ebf6d50bfb43caa1f125ee88a.zip gdb-19630284f570790ebf6d50bfb43caa1f125ee88a.tar.gz gdb-19630284f570790ebf6d50bfb43caa1f125ee88a.tar.bz2 |
New "iterate_over_objfiles_in_search_order" gdbarch method.
This patch introduces the "iterate_over_objfiles_in_search_order"
gdbarch method, as well as its default implementation, and converts
the areas where it will matter to using this gdbarch method.
The default method implementation is the only one installed, and
the changes should have no functional impact in terms of behavior.
This only paves the way for the architectures that will need their
own version.
gdb/ChangeLog:
* gdbarch.sh: Add generation of
"iterate_over_objfiles_in_search_order_cb_ftype" typedef in
gdbarch.h. Add include of "objfiles.h" in gdbarch.c.
(iterate_over_objfiles_in_search_order): New gdbarch method.
* gdbarch.h, gdbarch.c: Regenerate.
* objfiles.h (default_iterate_over_objfiles_in_search_order):
Add declaration.
* objfiles.c (default_iterate_over_objfiles_in_search_order):
New function.
* symtab.c (lookup_symbol_aux_objfile): New function, extracted
out of lookup_symbol_aux_symtabs.
(lookup_symbol_aux_symtabs): Replace extracted-out code by
call to lookup_symbol_aux_objfile.
(struct global_sym_lookup_data): New type.
(lookup_symbol_global_iterator_cb): New function.
(lookup_symbol_global): Search for symbol using
gdbarch_iterate_over_objfiles_in_search_order and
lookup_symbol_global_iterator_cb.
* findvar.c (struct minsym_lookup_data): New type.
(minsym_lookup_iterator_cb): New function.
(default_read_var_value) [case LOC_UNRESOLVED]: Resolve the
symbol's address via gdbarch_iterate_over_objfiles_in_search_order
and minsym_lookup_iterator_cb.
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r-- | gdb/findvar.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c index 9009e6f..66bcebe 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -406,6 +406,37 @@ symbol_read_needs_frame (struct symbol *sym) return 1; } +/* Private data to be used with minsym_lookup_iterator_cb. */ + +struct minsym_lookup_data +{ + /* The name of the minimal symbol we are searching for. */ + const char *name; + + /* The field where the callback should store the minimal symbol + if found. It should be initialized to NULL before the search + is started. */ + struct minimal_symbol *result; +}; + +/* A callback function for gdbarch_iterate_over_objfiles_in_search_order. + It searches by name for a minimal symbol within the given OBJFILE. + The arguments are passed via CB_DATA, which in reality is a pointer + to struct minsym_lookup_data. */ + +static int +minsym_lookup_iterator_cb (struct objfile *objfile, void *cb_data) +{ + struct minsym_lookup_data *data = (struct minsym_lookup_data *) cb_data; + + gdb_assert (data->result == NULL); + + data->result = lookup_minimal_symbol (data->name, NULL, objfile); + + /* The iterator should stop iff a match was found. */ + return (data->result != NULL); +} + /* A default implementation for the "la_read_var_value" hook in the language vector which should work in most situations. */ @@ -559,10 +590,19 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) case LOC_UNRESOLVED: { + struct minsym_lookup_data lookup_data; struct minimal_symbol *msym; struct obj_section *obj_section; - msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); + memset (&lookup_data, 0, sizeof (lookup_data)); + lookup_data.name = SYMBOL_LINKAGE_NAME (var); + + gdbarch_iterate_over_objfiles_in_search_order + (get_objfile_arch (SYMBOL_SYMTAB (var)->objfile), + minsym_lookup_iterator_cb, &lookup_data, + SYMBOL_SYMTAB (var)->objfile); + msym = lookup_data.result; + if (msym == NULL) error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var)); if (overlay_debugging) |