Remove struct symbol_search member symtab.

Message ID m3r3w4hyus.fsf@seba.sebabeach.org
State New, archived
Headers

Commit Message

Doug Evans Dec. 13, 2014, 6:01 a.m. UTC
  Hi.

Since symbols have a backlink to their containing symtab,
there's no real need to store symtab in struct symbol_search.
[Is there?]

Regression tested on amd64-linux.

2014-12-10  Doug Evans  <xdje42@gmail.com>

	* symtab.c (struct symbol_search) <symtab>: Delete.  All uses updated.
	* symtab.c (compare_search_syms): Use SYMBOL_SYMTAB accessor.
	(print_symbol_info): Delete arg symtab.  All callers updated.
	(symtab_symbol_info): Use SYMBOL_SYMTAB accessor.
  

Comments

Doug Evans Dec. 17, 2014, 6:06 a.m. UTC | #1
On Fri, Dec 12, 2014 at 10:01 PM, Doug Evans <xdje42@gmail.com> wrote:
> Hi.
>
> Since symbols have a backlink to their containing symtab,
> there's no real need to store symtab in struct symbol_search.
> [Is there?]
>
> Regression tested on amd64-linux.
>
> 2014-12-10  Doug Evans  <xdje42@gmail.com>
>
>         * symtab.h (struct symbol_search) <symtab>: Delete.  All uses updated.
>         * symtab.c (compare_search_syms): Use SYMBOL_SYMTAB accessor.
>         (print_symbol_info): Delete arg symtab.  All callers updated.
>         (symtab_symbol_info): Use SYMBOL_SYMTAB accessor.

Committed.
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index fb70758..311ecbc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3417,7 +3417,8 @@  compare_search_syms (const void *sa, const void *sb)
   struct symbol_search *sym_b = *(struct symbol_search **) sb;
   int c;
 
-  c = FILENAME_CMP (sym_a->symtab->filename, sym_b->symtab->filename);
+  c = FILENAME_CMP (SYMBOL_SYMTAB (sym_a->symbol)->filename,
+		    SYMBOL_SYMTAB (sym_b->symbol)->filename);
   if (c != 0)
     return c;
 
@@ -3733,7 +3734,6 @@  search_symbols (const char *regexp, enum search_domain kind,
 		struct symbol_search *psr = (struct symbol_search *)
 		  xmalloc (sizeof (struct symbol_search));
 		psr->block = i;
-		psr->symtab = real_symtab;
 		psr->symbol = sym;
 		memset (&psr->msymbol, 0, sizeof (psr->msymbol));
 		psr->next = NULL;
@@ -3791,7 +3791,6 @@  search_symbols (const char *regexp, enum search_domain kind,
 			psr->block = i;
 			psr->msymbol.minsym = msymbol;
 			psr->msymbol.objfile = objfile;
-			psr->symtab = NULL;
 			psr->symbol = NULL;
 			psr->next = NULL;
 			if (tail == NULL)
@@ -3817,9 +3816,10 @@  search_symbols (const char *regexp, enum search_domain kind,
 
 static void
 print_symbol_info (enum search_domain kind,
-		   struct symtab *s, struct symbol *sym,
+		   struct symbol *sym,
 		   int block, const char *last)
 {
+  struct symtab *s = SYMBOL_SYMTAB (sym);
   const char *s_filename = symtab_to_filename_for_display (s);
 
   if (last == NULL || filename_cmp (last, s_filename) != 0)
@@ -3914,11 +3914,11 @@  symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty)
       else
 	{
 	  print_symbol_info (kind,
-			     p->symtab,
 			     p->symbol,
 			     p->block,
 			     last_filename);
-	  last_filename = symtab_to_filename_for_display (p->symtab);
+	  last_filename
+	    = symtab_to_filename_for_display (SYMBOL_SYMTAB (p->symbol));
 	}
     }
 
@@ -4004,7 +4004,8 @@  rbreak_command (char *regexp, int from_tty)
     {
       if (p->msymbol.minsym == NULL)
 	{
-	  const char *fullname = symtab_to_fullname (p->symtab);
+	  struct symtab *symtab = SYMBOL_SYMTAB (p->symbol);
+	  const char *fullname = symtab_to_fullname (symtab);
 
 	  int newlen = (strlen (fullname)
 			+ strlen (SYMBOL_LINKAGE_NAME (p->symbol))
@@ -4021,10 +4022,9 @@  rbreak_command (char *regexp, int from_tty)
 	  strcat (string, "'");
 	  break_command (string, from_tty);
 	  print_symbol_info (FUNCTIONS_DOMAIN,
-			     p->symtab,
 			     p->symbol,
 			     p->block,
-			     symtab_to_filename_for_display (p->symtab));
+			     symtab_to_filename_for_display (symtab));
 	}
       else
 	{
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3051530..2ffb483 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1442,9 +1442,7 @@  struct symbol_search
 
   /* Information describing what was found.
 
-     If symtab and symbol are NOT NULL, then information was found
-     for this match.  */
-  struct symtab *symtab;
+     If symbol is NOT NULL, then information was found for this match.  */
   struct symbol *symbol;
 
   /* If msymbol is non-null, then a match was made on something for