This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH] Symplify macro in symtab.h


This patch "removes" the large macro SYMBOL_INIT_LANGUAGE_SPECIFIC.
It doesn't really get rid of it, because the first parameter can be a
partial symbol, a minimal symbol, or a full symbol, and we need to
still let the macro pass into the function the common ginfo field of
the p/m/symbol structure.

Similar approach had been taken earlier for the
SYMBOL_INIT_DEMANGLED_NAME macro.

Elena

2002-10-23  Elena Zannoni  <ezannoni@redhat.com>

	* symtab.c (symbol_init_language_specific): New function.
	* symtab.h (SYMBOL_INIT_LANGUAGE_SPECIFIC): Simplify macro, by
	turning most of it into a function.
	(symbol_init_language_specific): Export.
Index: symtab.h
===================================================================
RCS file: /cvs/uberbaum/gdb/symtab.h,v
retrieving revision 1.46
diff -u -p -r1.46 symtab.h
--- symtab.h	21 Oct 2002 19:11:50 -0000	1.46
+++ symtab.h	23 Oct 2002 18:07:16 -0000
@@ -139,32 +139,12 @@ extern CORE_ADDR symbol_overlayed_addres
 #define SYMBOL_CPLUS_DEMANGLED_NAME(symbol)	\
   (symbol)->ginfo.language_specific.cplus_specific.demangled_name
 
-/* Macro that initializes the language dependent portion of a symbol
+/* Initializes the language dependent portion of a symbol
    depending upon the language for the symbol. */
-
-#define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language)			\
-  do {									\
-    SYMBOL_LANGUAGE (symbol) = language;				\
-    if (SYMBOL_LANGUAGE (symbol) == language_cplus			\
-	|| SYMBOL_LANGUAGE (symbol) == language_java			\
-	)								\
-      {									
\
-	SYMBOL_CPLUS_DEMANGLED_NAME (symbol) = NULL;			\
-      }									
\
-    else if (SYMBOL_LANGUAGE (symbol) == language_objc)			
\
-      {									
\
-	SYMBOL_OBJC_DEMANGLED_NAME (symbol) = NULL;			\
-      }									
\
-    /* OBSOLETE else if (SYMBOL_LANGUAGE (symbol) == language_chill) */ \
-    /* OBSOLETE   { */						 	\
-    /* OBSOLETE     SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL; */	\
-    /* OBSOLETE   } */							\
-    else								\
-      {									
\
-	memset (&(symbol)->ginfo.language_specific, 0,			\
-		sizeof ((symbol)->ginfo.language_specific));		\
-      }									
\
-  } while (0)
+#define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language) \
+  (symbol_init_language_specific (&(symbol)->ginfo, (language)))
+extern void symbol_init_language_specific (struct general_symbol_info *symbol,
+					   enum language language);
 
 #define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack) \
   (symbol_init_demangled_name (&symbol->ginfo, (obstack)))

Index: symtab.c
===================================================================
RCS file: /cvs/uberbaum/gdb/symtab.c,v
retrieving revision 1.70
diff -u -p -r1.70 symtab.c
--- symtab.c	20 Sep 2002 14:58:58 -0000	1.70
+++ symtab.c	23 Oct 2002 18:15:12 -0000
@@ -385,6 +385,33 @@ gdb_mangle_name (struct type *type, int 
 }
 
 
+/* Initialize the language dependent portion of a symbol
+   depending upon the language for the symbol. */
+void
+symbol_init_language_specific (struct general_symbol_info *gsymbol,
+			       enum language language)
+{
+  gsymbol->language = language;
+  if (gsymbol->language == language_cplus
+      || gsymbol->language == language_java)
+    {
+      gsymbol->language_specific.cplus_specific.demangled_name = NULL;
+    }
+  else if (gsymbol->language == language_objc)
+    {
+      gsymbol->language_specific.objc_specific.demangled_name = NULL;
+    }
+  /* OBSOLETE else if (SYMBOL_LANGUAGE (symbol) == language_chill) */
+  /* OBSOLETE   { */
+  /* OBSOLETE     SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL; */
+  /* OBSOLETE   } */
+  else
+    {
+      memset (&gsymbol->language_specific, 0,
+	      sizeof (gsymbol->language_specific));
+    }
+}
+
 /* Initialize a symbol's mangled name.  */
 
 /* Try to initialize the demangled name for a symbol, based on the


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