This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] ALL_OBJFILE_PRIMARY_SYMTABS: New macro
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Thu, 24 May 2012 23:27:45 -0700 (PDT)
- Subject: [patch] ALL_OBJFILE_PRIMARY_SYMTABS: New macro
Hi.
Just a little code cleanup.
I will commit this in a few days if there are no objections.
2012-05-24 Doug Evans <dje@google.com>
* objfiles.h (ALL_OBJFILE_PRIMARY_SYMTABS): New macro.
(ALL_PRIMARY_SYMTABS): Use it.
(ALL_PSPACE_PRIMARY_SYMTABS): Ditto.
* dwarf2read.c (dw2_find_symbol_file): Ditto.
* linespec.c (iterate_over_all_matching_symtabs): Ditto.
* symtab.c (lookup_symbol_aux_objfile): Ditto.
(basic_lookup_transparent_type): Ditto.
Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.90
diff -u -p -r1.90 objfiles.h
--- objfiles.h 21 Feb 2012 06:55:36 -0000 1.90
+++ objfiles.h 25 May 2012 06:12:14 -0000
@@ -556,6 +556,12 @@ extern int gdb_bfd_close_or_warn (struct
#define ALL_OBJFILE_SYMTABS(objfile, s) \
for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next)
+/* Traverse all primary symtabs in one objfile. */
+
+#define ALL_OBJFILE_PRIMARY_SYMTABS(objfile, s) \
+ ALL_OBJFILE_SYMTABS ((objfile), (s)) \
+ if ((s)->primary)
+
/* Traverse all minimal symbols in one objfile. */
#define ALL_OBJFILE_MSYMBOLS(objfile, m) \
@@ -578,13 +584,11 @@ extern int gdb_bfd_close_or_warn (struct
#define ALL_PRIMARY_SYMTABS(objfile, s) \
ALL_OBJFILES (objfile) \
- ALL_OBJFILE_SYMTABS (objfile, s) \
- if ((s)->primary)
+ ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
#define ALL_PSPACE_PRIMARY_SYMTABS(pspace, objfile, s) \
ALL_PSPACE_OBJFILES (ss, objfile) \
- ALL_OBJFILE_SYMTABS (objfile, s) \
- if ((s)->primary)
+ ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
/* Traverse all minimal symbols in all objfiles in the current symbol
space. */
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.656
diff -u -p -r1.656 dwarf2read.c
--- dwarf2read.c 24 May 2012 22:09:20 -0000 1.656
+++ dwarf2read.c 25 May 2012 06:12:14 -0000
@@ -2842,16 +2842,15 @@ dw2_find_symbol_file (struct objfile *ob
{
struct symtab *s;
- ALL_OBJFILE_SYMTABS (objfile, s)
- if (s->primary)
- {
- struct blockvector *bv = BLOCKVECTOR (s);
- const struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- struct symbol *sym = lookup_block_symbol (block, name, VAR_DOMAIN);
+ ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ {
+ struct blockvector *bv = BLOCKVECTOR (s);
+ const struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ struct symbol *sym = lookup_block_symbol (block, name, VAR_DOMAIN);
- if (sym)
- return sym->symtab->filename;
- }
+ if (sym)
+ return sym->symtab->filename;
+ }
return NULL;
}
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.156
diff -u -p -r1.156 linespec.c
--- linespec.c 18 May 2012 21:02:48 -0000 1.156
+++ linespec.c 25 May 2012 06:12:14 -0000
@@ -987,27 +987,24 @@ iterate_over_all_matching_symtabs (struc
ALL_DOMAIN,
&matcher_data);
- ALL_OBJFILE_SYMTABS (objfile, symtab)
+ ALL_OBJFILE_PRIMARY_SYMTABS (objfile, symtab)
{
- if (symtab->primary)
- {
- struct block *block;
+ struct block *block;
- block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
- LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
+ block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
+ LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
- if (include_inline)
- {
- struct symbol_and_data_callback cad = { callback, data };
- int i;
+ if (include_inline)
+ {
+ struct symbol_and_data_callback cad = { callback, data };
+ int i;
- for (i = FIRST_LOCAL_BLOCK;
- i < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (symtab)); i++)
- {
- block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), i);
- LA_ITERATE_OVER_SYMBOLS (block, name, domain,
- iterate_inline_only, &cad);
- }
+ for (i = FIRST_LOCAL_BLOCK;
+ i < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (symtab)); i++)
+ {
+ block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), i);
+ LA_ITERATE_OVER_SYMBOLS (block, name, domain,
+ iterate_inline_only, &cad);
}
}
}
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.306
diff -u -p -r1.306 symtab.c
--- symtab.c 24 May 2012 02:51:48 -0000 1.306
+++ symtab.c 25 May 2012 06:12:14 -0000
@@ -1517,18 +1517,17 @@ lookup_symbol_aux_objfile (struct objfil
objfile->sf->qf->pre_expand_symtabs_matching (objfile, block_index,
name, domain);
- ALL_OBJFILE_SYMTABS (objfile, s)
- if (s->primary)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = lookup_block_symbol (block, name, domain);
- if (sym)
- {
- block_found = block;
- return fixup_symbol_section (sym, objfile);
- }
- }
+ ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, block_index);
+ sym = lookup_block_symbol (block, name, domain);
+ if (sym)
+ {
+ block_found = block;
+ return fixup_symbol_section (sym, objfile);
+ }
+ }
return NULL;
}
@@ -1829,17 +1828,16 @@ basic_lookup_transparent_type (const cha
GLOBAL_BLOCK,
name, STRUCT_DOMAIN);
- ALL_OBJFILE_SYMTABS (objfile, s)
- if (s->primary)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
- {
- return SYMBOL_TYPE (sym);
- }
- }
+ ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+ if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ {
+ return SYMBOL_TYPE (sym);
+ }
+ }
}
ALL_OBJFILES (objfile)