public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <xdje42@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Remove struct symbol_search member symtab.
Date: Sat, 13 Dec 2014 06:02:00 -0000	[thread overview]
Message-ID: <m3r3w4hyus.fsf@seba.sebabeach.org> (raw)

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.

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

             reply	other threads:[~2014-12-13  6:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-13  6:02 Doug Evans [this message]
2014-12-17  6:06 ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3r3w4hyus.fsf@seba.sebabeach.org \
    --to=xdje42@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).