This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Remove pre_expand_symtabs_matching quick_symbol_functions API
Joel Brobecker writes:
> > Jan> Sorry, I no longer have anything against, GNU Coding Standards says:
> > Jan> (assignments inside while-conditions are ok)
> > Jan> and I only remembered the first part:
> > Jan> Try to avoid assignments inside if-conditions
> >
> > I don't remember that being there :)
> > Super.
>
> Jan beat me to the GCS quote, but I also verified that the ARI only
> checks for assignments inside if-s.
Righto.
Here is the revised patch, it addresses the comments to date.
I will check this in in a few days if there are no further comments.
Thanks.
2013-01-07 Doug Evans <dje@google.com>
* symfile.h (quick_symbol_functions): Delete member
pre_expand_symtabs_matching. All uses removed.
* dwarf2read.c (dw2_lookup_symbol): Implement.
(dw2_do_expand_symtabs_matching): Delete.
(dw2_pre_expand_symtabs_matching): Delete.
(struct dw2_symtab_iterator): New type.
(dw2_symtab_iter_init, dw2_symtab_iter_next): New functions.
(dw2_expand_symtabs_for_function): Rewrite.
(dwarf2_gdb_index_functions): Update.
* psymtab.c (pre_expand_symtabs_matching_psymtabs): Delete.
(psym_functions): Update.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.726
diff -c -p -r1.726 dwarf2read.c
*** dwarf2read.c 1 Jan 2013 06:32:41 -0000 1.726
--- dwarf2read.c 8 Jan 2013 00:11:56 -0000
*************** dw2_map_symtabs_matching_filename (struc
*** 3149,3247 ****
return 0;
}
! static struct symtab *
! dw2_lookup_symbol (struct objfile *objfile, int block_index,
! const char *name, domain_enum domain)
{
! /* We do all the work in the pre_expand_symtabs_matching hook
! instead. */
! return NULL;
! }
! /* A helper function that expands all symtabs that hold an object
! named NAME. If WANT_SPECIFIC_BLOCK is non-zero, only look for
! symbols in block BLOCK_KIND. */
static void
! dw2_do_expand_symtabs_matching (struct objfile *objfile,
! int want_specific_block,
! enum block_enum block_kind,
! const char *name, domain_enum domain)
{
struct mapped_index *index;
dw2_setup (objfile);
index = dwarf2_per_objfile->index_table;
! /* index_table is NULL if OBJF_READNOW. */
if (index)
{
! offset_type *vec;
! if (find_slot_in_mapped_hash (index, name, &vec))
{
! offset_type i, len = MAYBE_SWAP (*vec);
! for (i = 0; i < len; ++i)
{
! offset_type cu_index_and_attrs = MAYBE_SWAP (vec[i + 1]);
! offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
! struct dwarf2_per_cu_data *per_cu = dw2_get_cu (cu_index);
! int want_static = block_kind != GLOBAL_BLOCK;
! /* This value is only valid for index versions >= 7. */
! int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
! gdb_index_symbol_kind symbol_kind =
! GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
! /* Only check the symbol attributes if they're present.
! Indices prior to version 7 don't record them,
! and indices >= 7 may elide them for certain symbols
! (gold does this). */
! int attrs_valid =
! (index->version >= 7
! && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
!
! if (attrs_valid
! && want_specific_block
! && want_static != is_static)
! continue;
! /* Only check the symbol's kind if it has one. */
! if (attrs_valid)
! {
! switch (domain)
! {
! case VAR_DOMAIN:
! if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE
! && symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION
! /* Some types are also in VAR_DOMAIN. */
! && symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
! continue;
! break;
! case STRUCT_DOMAIN:
! if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
! continue;
! break;
! case LABEL_DOMAIN:
! if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER)
! continue;
! break;
! default:
! break;
! }
! }
! dw2_instantiate_symtab (per_cu);
}
}
}
- }
! static void
! dw2_pre_expand_symtabs_matching (struct objfile *objfile,
! enum block_enum block_kind, const char *name,
! domain_enum domain)
! {
! dw2_do_expand_symtabs_matching (objfile, 1, block_kind, name, domain);
}
static void
--- 3149,3316 ----
return 0;
}
! /* Struct used to manage iterating over all CUs looking for a symbol. */
!
! struct dw2_symtab_iterator
{
! /* The internalized form of .gdb_index. */
! struct mapped_index *index;
! /* If non-zero, only look for symbols that match BLOCK_INDEX. */
! int want_specific_block;
! /* One of GLOBAL_BLOCK or STATIC_BLOCK.
! Unused if !WANT_SPECIFIC_BLOCK. */
! int block_index;
! /* The kind of symbol we're looking for. */
! domain_enum domain;
! /* The list of CUs from the index entry of the symbol,
! or NULL if not found. */
! offset_type *vec;
! /* The next element in VEC to look at. */
! int next;
! /* The number of elements in VEC, or zero if there is no match. */
! int length;
! };
! /* Initialize the index symtab iterator ITER.
! If WANT_SPECIFIC_BLOCK is non-zero, only look for symbols
! in block BLOCK_INDEX. Otherwise BLOCK_INDEX is ignored. */
static void
! dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
! struct mapped_index *index,
! int want_specific_block,
! int block_index,
! domain_enum domain,
! const char *name)
! {
! iter->index = index;
! iter->want_specific_block = want_specific_block;
! iter->block_index = block_index;
! iter->domain = domain;
! iter->next = 0;
!
! if (find_slot_in_mapped_hash (index, name, &iter->vec))
! iter->length = MAYBE_SWAP (*iter->vec);
! else
! {
! iter->vec = NULL;
! iter->length = 0;
! }
! }
!
! /* Return the next matching CU or NULL if there are no more. */
!
! static struct dwarf2_per_cu_data *
! dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
! {
! for ( ; iter->next < iter->length; ++iter->next)
! {
! offset_type cu_index_and_attrs =
! MAYBE_SWAP (iter->vec[iter->next + 1]);
! offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
! struct dwarf2_per_cu_data *per_cu = dw2_get_cu (cu_index);
! int want_static = iter->block_index != GLOBAL_BLOCK;
! /* This value is only valid for index versions >= 7. */
! int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
! gdb_index_symbol_kind symbol_kind =
! GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
! /* Only check the symbol attributes if they're present.
! Indices prior to version 7 don't record them,
! and indices >= 7 may elide them for certain symbols
! (gold does this). */
! int attrs_valid =
! (iter->index->version >= 7
! && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
!
! /* Skip if already read in. */
! if (per_cu->v.quick->symtab)
! continue;
!
! if (attrs_valid
! && iter->want_specific_block
! && want_static != is_static)
! continue;
!
! /* Only check the symbol's kind if it has one. */
! if (attrs_valid)
! {
! switch (iter->domain)
! {
! case VAR_DOMAIN:
! if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE
! && symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION
! /* Some types are also in VAR_DOMAIN. */
! && symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
! continue;
! break;
! case STRUCT_DOMAIN:
! if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
! continue;
! break;
! case LABEL_DOMAIN:
! if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER)
! continue;
! break;
! default:
! break;
! }
! }
!
! ++iter->next;
! return per_cu;
! }
!
! return NULL;
! }
!
! static struct symtab *
! dw2_lookup_symbol (struct objfile *objfile, int block_index,
! const char *name, domain_enum domain)
{
+ struct symtab *stab_best = NULL;
struct mapped_index *index;
dw2_setup (objfile);
index = dwarf2_per_objfile->index_table;
! /* index is NULL if OBJF_READNOW. */
if (index)
{
! struct dw2_symtab_iterator iter;
! struct dwarf2_per_cu_data *per_cu;
!
! dw2_symtab_iter_init (&iter, index, 1, block_index, domain, name);
! while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
{
! struct symbol *sym = NULL;
! struct symtab *stab = dw2_instantiate_symtab (per_cu);
!
! /* Some caution must be observed with overloaded functions
! and methods, since the index will not contain any overload
! information (but NAME might contain it). */
! if (stab->primary)
{
! struct blockvector *bv = BLOCKVECTOR (stab);
! struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
! sym = lookup_block_symbol (block, name, domain);
! }
! if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
! {
! if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
! return stab;
!
! stab_best = stab;
}
+
+ /* Keep looking through other CUs. */
}
}
! return stab_best;
}
static void
*************** static void
*** 3279,3287 ****
dw2_expand_symtabs_for_function (struct objfile *objfile,
const char *func_name)
{
! /* Note: It doesn't matter what we pass for block_kind here. */
! dw2_do_expand_symtabs_matching (objfile, 0, GLOBAL_BLOCK, func_name,
! VAR_DOMAIN);
}
static void
--- 3348,3372 ----
dw2_expand_symtabs_for_function (struct objfile *objfile,
const char *func_name)
{
! struct mapped_index *index;
!
! dw2_setup (objfile);
!
! index = dwarf2_per_objfile->index_table;
!
! /* index is NULL if OBJF_READNOW. */
! if (index)
! {
! struct dw2_symtab_iterator iter;
! struct dwarf2_per_cu_data *per_cu;
!
! /* Note: It doesn't matter what we pass for block_index here. */
! dw2_symtab_iter_init (&iter, index, 0, GLOBAL_BLOCK, VAR_DOMAIN,
! func_name);
!
! while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
! dw2_instantiate_symtab (per_cu);
! }
}
static void
*************** const struct quick_symbol_functions dwar
*** 3697,3703 ****
dw2_forget_cached_source_info,
dw2_map_symtabs_matching_filename,
dw2_lookup_symbol,
- dw2_pre_expand_symtabs_matching,
dw2_print_stats,
dw2_dump,
dw2_relocate,
--- 3782,3787 ----
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.57
diff -c -p -r1.57 psymtab.c
*** psymtab.c 3 Jan 2013 07:17:52 -0000 1.57
--- psymtab.c 8 Jan 2013 00:11:56 -0000
*************** match_partial_symbol (struct objfile *ob
*** 628,642 ****
return NULL;
}
- static void
- pre_expand_symtabs_matching_psymtabs (struct objfile *objfile,
- enum block_enum block_kind,
- const char *name,
- domain_enum domain)
- {
- /* Nothing. */
- }
-
/* Returns the name used to search psymtabs. Unlike symtabs, psymtabs do
not contain any method/function instance information (since this would
force reading type information while reading psymtabs). Therefore,
--- 628,633 ----
*************** const struct quick_symbol_functions psym
*** 1428,1434 ****
forget_cached_source_info_partial,
partial_map_symtabs_matching_filename,
lookup_symbol_aux_psymtabs,
- pre_expand_symtabs_matching_psymtabs,
print_psymtab_stats_for_objfile,
dump_psymtabs_for_objfile,
relocate_psymtabs,
--- 1419,1424 ----
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.117
diff -c -p -r1.117 symfile.h
*** symfile.h 2 Jan 2013 18:52:07 -0000 1.117
--- symfile.h 8 Jan 2013 00:11:56 -0000
*************** struct quick_symbol_functions
*** 189,204 ****
int kind, const char *name,
domain_enum domain);
- /* This is called to expand symbol tables before looking up a
- symbol. A backend can choose to implement this and then have its
- `lookup_symbol' hook always return NULL, or the reverse. (It
- doesn't make sense to implement both.) The arguments are as for
- `lookup_symbol'. */
- void (*pre_expand_symtabs_matching) (struct objfile *objfile,
- enum block_enum block_kind,
- const char *name,
- domain_enum domain);
-
/* Print statistics about any indices loaded for OBJFILE. The
statistics should be printed to gdb_stdout. This is used for
"maint print statistics". */
--- 189,194 ----
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.335
diff -c -p -r1.335 symtab.c
*** symtab.c 1 Jan 2013 06:32:52 -0000 1.335
--- symtab.c 8 Jan 2013 00:11:56 -0000
*************** lookup_symbol_aux_objfile (struct objfil
*** 1551,1560 ****
const struct block *block;
struct symtab *s;
- if (objfile->sf)
- objfile->sf->qf->pre_expand_symtabs_matching (objfile, block_index,
- name, domain);
-
ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
{
bv = BLOCKVECTOR (s);
--- 1551,1556 ----
*************** basic_lookup_transparent_type (const cha
*** 1912,1922 ****
ALL_OBJFILES (objfile)
{
- if (objfile->sf)
- objfile->sf->qf->pre_expand_symtabs_matching (objfile,
- GLOBAL_BLOCK,
- name, STRUCT_DOMAIN);
-
ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
{
bv = BLOCKVECTOR (s);
--- 1908,1913 ----
*************** basic_lookup_transparent_type (const cha
*** 1945,1954 ****
ALL_OBJFILES (objfile)
{
- if (objfile->sf)
- objfile->sf->qf->pre_expand_symtabs_matching (objfile, STATIC_BLOCK,
- name, STRUCT_DOMAIN);
-
ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
{
bv = BLOCKVECTOR (s);
--- 1936,1941 ----