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: shrink struct minimal_symbol


This patch shrinks struct minimal_symbol.

It turns out that the 'info' field is only used to hold flag bits by a
few back ends.  This patch replaces this field with two one-bit flag
fields, backed into the hole after the 'type' field.  This saves one
pointer per minimal symbol.

The savings here aren't huge -- 1% in my test case (3M in absolute
terms).  Still, unless there are plans for using 'info', this seems
like an easy win.

I kept the name prim_record_minimal_symbol_and_info, even though
'info' is gone, because prim_record_minimal_symbol is already taken.
If you'd prefer a new name, let me know and I can rename it.

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

Please review.

Tom

:ADDPATCH symbols:

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

	* xcoffread.c (RECORD_MINIMAL_SYMBOL): Update.
	(scan_xcoff_symtab): Update.
	* mdebugread.c (record_minimal_symbol): Update.
	(parse_partial_symbols): Update.
	* elfread.c (record_minimal_symbol): Update.
	* dbxread.c (record_minimal_symbol): Update.
	* coffread.c (record_minimal_symbol): Update.
	* sh64-tdep.c (MSYMBOL_IS_SPECIAL): Redefine.
	(sh64_elf_make_msymbol_special): Update.
	* mips-tdep.c (mips_elf_make_msymbol_special): Use
	MSYMBOL_TARGET_FLAG_1.
	(mips_elf_make_msymbol_special): Likewise.
	(msymbol_is_special): Likewise.
	* minsyms.c (prim_record_minimal_symbol_and_info): Update.
	(install_minimal_symbols): Likewise.
	(prim_record_minimal_symbol): Update.
	(prim_record_minimal_symbol_and_info): Remove 'info' argument.
	* m68hc11-tdep.c (MSYMBOL_SET_RTC): Redefine.
	(MSYMBOL_SET_RTI): Redefine.
	(MSYMBOL_IS_RTC): Redefine.
	(MSYMBOL_IS_RTI): Redefine.
	* arm-tdep.c (MSYMBOL_SET_SPECIAL): Redefine.
	(MSYMBOL_IS_SPECIAL): Redefine.
	* symtab.h (struct minimal_symbol) <info>: Remove.
	<target_flag_1, target_flag_2>: New fields.
	(MSYMBOL_INFO): Remove.
	(MSYMBOL_TARGET_FLAG_1): New macro.
	(MSYMBOL_TARGET_FLAG_2): Likewise.
	(prim_record_minimal_symbol_and_info): Update.

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index cb0eb12..102f16b 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -63,11 +63,10 @@ static int arm_debug;
    MSYMBOL_IS_SPECIAL   Tests the "special" bit in a minimal symbol.  */
 
 #define MSYMBOL_SET_SPECIAL(msym)					\
-	MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym))	\
-					| 0x80000000)
+	MSYMBOL_TARGET_FLAG_1 (msym) = 1
 
 #define MSYMBOL_IS_SPECIAL(msym)				\
-	(((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
+	MSYMBOL_TARGET_FLAG_1 (msym)
 
 /* Macros for swapping shorts and ints. In the unlikely case that anybody else needs these,
    move to a general header. (A better solution might be to define memory read routines that
diff --git a/gdb/coffread.c b/gdb/coffread.c
index de81d47..4d8ef8a 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -421,7 +421,7 @@ record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
 
   bfd_section = cs_to_bfd_section (cs, objfile);
   return prim_record_minimal_symbol_and_info (cs->c_name, address, type,
-    NULL, section, bfd_section, objfile);
+					      section, bfd_section, objfile);
 }
 
 /* coff_symfile_init ()
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 25ec313..dde922a 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -514,7 +514,7 @@ record_minimal_symbol (char *name, CORE_ADDR address, int type,
     lowest_text_address = address;
 
   prim_record_minimal_symbol_and_info
-    (name, address, ms_type, NULL, section, bfd_section, objfile);
+    (name, address, ms_type, section, bfd_section, objfile);
 }
 
 /* Scan and build partial symbols for a symbol file.
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 17f86ba..22f4e5d 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -172,7 +172,7 @@ record_minimal_symbol (char *name, CORE_ADDR address,
     address = gdbarch_smash_text_address (gdbarch, address);
 
   return prim_record_minimal_symbol_and_info
-    (name, address, ms_type, NULL, bfd_section->index, bfd_section, objfile);
+    (name, address, ms_type, bfd_section->index, bfd_section, objfile);
 }
 
 /*
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 7bd6e69..1913333 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -59,18 +59,16 @@
    MSYMBOL_IS_RTI       Tests the "RTC" bit in a minimal symbol.  */
 
 #define MSYMBOL_SET_RTC(msym)                                           \
-        MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym))	\
-					| 0x80000000)
+        MSYMBOL_TARGET_FLAG_1 (msym) = 1
 
 #define MSYMBOL_SET_RTI(msym)                                           \
-        MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym))	\
-					| 0x40000000)
+        MSYMBOL_TARGET_FLAG_2 (msym) = 1
 
 #define MSYMBOL_IS_RTC(msym)				\
-	(((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
+	MSYMBOL_TARGET_FLAG_1 (msym)
 
 #define MSYMBOL_IS_RTI(msym)				\
-	(((long) MSYMBOL_INFO (msym) & 0x40000000) != 0)
+	MSYMBOL_TARGET_FLAG_2 (msym)
 
 enum insn_return_kind {
   RETURN_RTS,
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ede6fce..2807008 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2211,7 +2211,7 @@ record_minimal_symbol (const char *name, const CORE_ADDR address,
         bfd_section = NULL;
     }
 
-  prim_record_minimal_symbol_and_info (name, address, ms_type, NULL,
+  prim_record_minimal_symbol_and_info (name, address, ms_type,
                                        section, bfd_section, objfile);
 }
 
@@ -3340,7 +3340,7 @@ parse_partial_symbols (struct objfile *objfile)
 
 		case stStaticProc:
 		  prim_record_minimal_symbol_and_info (name, sh.value,
-						       mst_file_text, NULL,
+						       mst_file_text,
 						       SECT_OFF_TEXT (objfile), NULL,
 						       objfile);
 
@@ -3426,13 +3426,13 @@ parse_partial_symbols (struct objfile *objfile)
 		case stStatic:	/* Variable */
 		  if (SC_IS_DATA (sh.sc))
 		    prim_record_minimal_symbol_and_info (name, sh.value,
-							 mst_file_data, NULL,
+							 mst_file_data,
 							 SECT_OFF_DATA (objfile),
 							 NULL,
 							 objfile);
 		  else
 		    prim_record_minimal_symbol_and_info (name, sh.value,
-							 mst_file_bss, NULL,
+							 mst_file_bss,
 							 SECT_OFF_BSS (objfile),
 							 NULL,
 							 objfile);
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 4069e6f..71d56cb 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -725,7 +725,7 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
     }
 
   prim_record_minimal_symbol_and_info (name, address, ms_type,
-				       NULL, section, NULL, objfile);
+				       section, NULL, objfile);
 }
 
 /* Record a minimal symbol in the msym bunches.  Returns the symbol
@@ -734,7 +734,7 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
 struct minimal_symbol *
 prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
 				     enum minimal_symbol_type ms_type,
-				     char *info, int section,
+				     int section,
 				     asection *bfd_section,
 				     struct objfile *objfile)
 {
@@ -788,8 +788,8 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
       }
 
   MSYMBOL_TYPE (msymbol) = ms_type;
-  /* FIXME:  This info, if it remains, needs its own field.  */
-  MSYMBOL_INFO (msymbol) = info;	/* FIXME! */
+  MSYMBOL_TARGET_FLAG_1 (msymbol) = 0;
+  MSYMBOL_TARGET_FLAG_2 (msymbol) = 0;
   MSYMBOL_SIZE (msymbol) = 0;
 
   /* The hash pointers must be cleared! If they're not,
@@ -1061,7 +1061,8 @@ install_minimal_symbols (struct objfile *objfile)
 
       SYMBOL_LINKAGE_NAME (&msymbols[mcount]) = NULL;
       SYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0;
-      MSYMBOL_INFO (&msymbols[mcount]) = NULL;
+      MSYMBOL_TARGET_FLAG_1 (&msymbols[mcount]) = 0;
+      MSYMBOL_TARGET_FLAG_2 (&msymbols[mcount]) = 0;
       MSYMBOL_SIZE (&msymbols[mcount]) = 0;
       MSYMBOL_TYPE (&msymbols[mcount]) = mst_unknown;
       SYMBOL_INIT_LANGUAGE_SPECIFIC (&msymbols[mcount], language_unknown);
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 615938b..2e1f012 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -253,8 +253,7 @@ mips_elf_make_msymbol_special (asymbol * sym, struct minimal_symbol *msym)
 {
   if (((elf_symbol_type *) (sym))->internal_elf_sym.st_other == STO_MIPS16)
     {
-      MSYMBOL_INFO (msym) = (char *)
-	(((long) MSYMBOL_INFO (msym)) | 0x80000000);
+      MSYMBOL_TARGET_FLAG_1 (msym) = 1;
       SYMBOL_VALUE_ADDRESS (msym) |= 1;
     }
 }
@@ -262,7 +261,7 @@ mips_elf_make_msymbol_special (asymbol * sym, struct minimal_symbol *msym)
 static int
 msymbol_is_special (struct minimal_symbol *msym)
 {
-  return (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0);
+  return MSYMBOL_TARGET_FLAG_1 (msym);
 }
 
 /* XFER a value from the big/little/left end of the register.
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index d8ab939..aa03b66 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -211,7 +211,7 @@ sh64_register_name (struct gdbarch *gdbarch, int reg_nr)
    MSYMBOL_IS_SPECIAL   tests the "special" bit in a minimal symbol  */
 
 #define MSYMBOL_IS_SPECIAL(msym) \
-  (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
+  MSYMBOL_TARGET_FLAG_1 (msym)
 
 static void
 sh64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
@@ -221,7 +221,7 @@ sh64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
 
   if (((elf_symbol_type *)(sym))->internal_elf_sym.st_other == STO_SH5_ISA32)
     {
-      MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) | 0x80000000);
+      MSYMBOL_TARGET_FLAG_1 (msym) = 1;
       SYMBOL_VALUE_ADDRESS (msym) |= 1;
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c124242..e9f470c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -319,21 +319,6 @@ struct minimal_symbol
 
   struct general_symbol_info ginfo;
 
-  /* The info field is available for caching machine-specific
-     information so it doesn't have to rederive the info constantly
-     (over a serial line).  It is initialized to zero and stays that
-     way until target-dependent code sets it.  Storage for any data
-     pointed to by this field should be allocated on the
-     objfile_obstack for the associated objfile.  The type would be
-     "void *" except for reasons of compatibility with older
-     compilers.  This field is optional.
-
-     Currently, the AMD 29000 tdep.c uses it to remember things it has decoded
-     from the instructions in the function header, and the MIPS-16 code uses
-     it to identify 16-bit procedures.  */
-
-  char *info;
-
   /* Size of this symbol.  end_psymtab in dbxread.c uses this
      information to calculate the end of the partial symtab based on the
      address of the last symbol plus the size of the last symbol.  */
@@ -347,6 +332,10 @@ struct minimal_symbol
 
   ENUM_BITFIELD(minimal_symbol_type) type : 8;
 
+  /* Two flag bit provided for the use of the target.  */
+  unsigned int target_flag_1 : 1;
+  unsigned int target_flag_2 : 1;
+
   /* Minimal symbols with the same hash key are kept on a linked
      list.  This is the link.  */
 
@@ -358,7 +347,8 @@ struct minimal_symbol
   struct minimal_symbol *demangled_hash_next;
 };
 
-#define MSYMBOL_INFO(msymbol)		(msymbol)->info
+#define MSYMBOL_TARGET_FLAG_1(msymbol)  (msymbol)->target_flag_1
+#define MSYMBOL_TARGET_FLAG_2(msymbol)  (msymbol)->target_flag_2
 #define MSYMBOL_SIZE(msymbol)		(msymbol)->size
 #define MSYMBOL_TYPE(msymbol)		(msymbol)->type
 
@@ -1100,7 +1090,7 @@ extern void prim_record_minimal_symbol (const char *, CORE_ADDR,
 extern struct minimal_symbol *prim_record_minimal_symbol_and_info
   (const char *, CORE_ADDR,
    enum minimal_symbol_type,
-   char *info, int section, asection * bfd_section, struct objfile *);
+   int section, asection * bfd_section, struct objfile *);
 
 extern unsigned int msymbol_hash_iw (const char *);
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 54e2aba..e7941ac 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -834,7 +834,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset, unsigned endoff
   namestr = (NAME); \
   if (namestr[0] == '.') ++namestr; \
   prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
-				       (char *)NULL, (SECTION), (asection *)NULL, (OBJFILE)); \
+				       (SECTION), (asection *)NULL, (OBJFILE)); \
   misc_func_recorded = 1;					\
 }
 
@@ -2285,7 +2285,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 		      prim_record_minimal_symbol_and_info
 			(namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_data : mst_data,
-			 NULL, secnum_to_section (symbol.n_scnum, objfile),
+			 secnum_to_section (symbol.n_scnum, objfile),
 			 NULL, objfile);
 		    break;
 
@@ -2360,7 +2360,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 		      prim_record_minimal_symbol_and_info
 			(namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_data : mst_data,
-			 NULL, secnum_to_section (symbol.n_scnum, objfile),
+			 secnum_to_section (symbol.n_scnum, objfile),
 			 NULL, objfile);
 		    break;
 		  }
@@ -2377,7 +2377,7 @@ scan_xcoff_symtab (struct objfile *objfile)
 		      prim_record_minimal_symbol_and_info
 			(namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_bss : mst_bss,
-			 NULL, secnum_to_section (symbol.n_scnum, objfile),
+			 secnum_to_section (symbol.n_scnum, objfile),
 			 NULL, objfile);
 		    break;
 		  }


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