This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: consistently use symbol accessors


While experimenting with rearranging the various symbol structures, I
ran across a few cases where symbol accessor macros were either not
used, or incorrectly used.

This patch fixes this.  In most cases this is just the obvious change.
There is some code in solib-som.c that incorrectly uses SYMBOL_TYPE
when MSYMBOL_TYPE is correct.

Built and regtested on x86-64 (compile farm).

Please review.

Tom

:ADDPATCH symbols:

2008-09-16  Tom Tromey  <tromey@redhat.com>

	* symtab.c (find_pc_sect_psymtab): Use MSYMBOL_TYPE.
	(find_pc_sect_symtab): Likewise.
	* symmisc.c (dump_msymbols): Use MSYMBOL_TYPE.
	* solib-som.c (som_solib_desire_dynamic_linker_symbols): Use
	MSYMBOL_TYPE, not SYMBOL_TYPE.
	* parse.c (write_exp_msymbol): Use MSYMBOL_TYPE.
	* objc-lang.c (find_methods): Use MSYMBOL_TYPE.
	* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Use
	MSYMBOL_TYPE.
	* m2-exp.y (yylex): Use SYMBOL_CLASS.

diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 951f778..460d657 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -1035,7 +1035,7 @@ yylex ()
 
     if(sym)
     {
-       switch(sym->aclass)
+      switch(SYMBOL_CLASS (sym))
        {
        case LOC_STATIC:
        case LOC_REGISTER:
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 4069e6f..c0e0aff 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -531,7 +531,7 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc,
 		     triggered by a special mst_abs_or_lib or some
 		     such.  */
 
-		  if (msymbol[hi].type == mst_abs)
+		  if (MSYMBOL_TYPE (&msymbol[hi]) == mst_abs)
 		    {
 		      hi--;
 		      continue;
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 56871e3..f26f693 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1145,7 +1145,8 @@ find_methods (struct symtab *symtab, char type,
     {
       QUIT;
 
-      if ((msymbol->type != mst_text) && (msymbol->type != mst_file_text))
+      if ((MSYMBOL_TYPE (msymbol) != mst_text)
+	  && (MSYMBOL_TYPE (msymbol) != mst_file_text))
 	/* Not a function or method.  */
 	continue;
 
diff --git a/gdb/parse.c b/gdb/parse.c
index ccd3957..f4b80e3 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -416,7 +416,7 @@ write_exp_msymbol (struct minimal_symbol *msymbol,
 
   CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol);
   struct obj_section *section = SYMBOL_OBJ_SECTION (msymbol);
-  enum minimal_symbol_type type = msymbol->type;
+  enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol);
   CORE_ADDR pc;
 
   /* The minimal symbol might point to a function descriptor;
diff --git a/gdb/solib-som.c b/gdb/solib-som.c
index 4d876ff..529bd75 100644
--- a/gdb/solib-som.c
+++ b/gdb/solib-som.c
@@ -391,7 +391,7 @@ som_solib_desire_dynamic_linker_symbols (void)
 							  objfile);
     if (dld_msymbol != NULL)
       {
-	if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
+	if (MSYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
 	  {
 	    u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
 	    if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
@@ -430,7 +430,7 @@ som_solib_desire_dynamic_linker_symbols (void)
 							  objfile);
     if (dld_msymbol != NULL)
       {
-	if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
+	if (MSYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
 	  {
 	    u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
 	    if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index af65497..048d9e0 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -276,7 +276,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
     {
       struct obj_section *section = SYMBOL_OBJ_SECTION (msymbol);
 
-      switch (msymbol->type)
+      switch (MSYMBOL_TYPE (msymbol))
 	{
 	case mst_unknown:
 	  ms_type = 'u';
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1a0dcba..690d501 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -857,11 +857,11 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section)
      not include the data ranges.  */
   msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
   if (msymbol
-      && (msymbol->type == mst_data
-	  || msymbol->type == mst_bss
-	  || msymbol->type == mst_abs
-	  || msymbol->type == mst_file_data
-	  || msymbol->type == mst_file_bss))
+      && (MSYMBOL_TYPE (msymbol) == mst_data
+	  || MSYMBOL_TYPE (msymbol) == mst_bss
+	  || MSYMBOL_TYPE (msymbol) == mst_abs
+	  || MSYMBOL_TYPE (msymbol) == mst_file_data
+	  || MSYMBOL_TYPE (msymbol) == mst_file_bss))
     return NULL;
 
   /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
@@ -1991,11 +1991,11 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
      on the partial_symtab's texthigh and textlow.  */
   msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
   if (msymbol
-      && (msymbol->type == mst_data
-	  || msymbol->type == mst_bss
-	  || msymbol->type == mst_abs
-	  || msymbol->type == mst_file_data
-	  || msymbol->type == mst_file_bss))
+      && (MSYMBOL_TYPE (msymbol) == mst_data
+	  || MSYMBOL_TYPE (msymbol) == mst_bss
+	  || MSYMBOL_TYPE (msymbol) == mst_abs
+	  || MSYMBOL_TYPE (msymbol) == mst_file_data
+	  || MSYMBOL_TYPE (msymbol) == mst_file_bss))
     return NULL;
 
   /* Search all symtabs for the one whose file contains our address, and which


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]