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]

[11/17] introduce new union in general_symbol_info


This patch changes general_symbol_info to replace the obj_section field
with a union.  We're going to use an integer index for minimal symbols,
and a pointer for everything else.

This patch doesn't make the switch, just lays the groundwork.
You can see that by separating out MSYMBOL_OBJ_SECTION, we've made the
next steps easier...

Tom

>From bf6515b08e6904f1224037061933d899ca73aa18 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Wed, 7 Dec 2011 11:36:38 -0700
Subject: [PATCH 11/18] introduce new union into ginfo

	* ada-lang.c (ada_decode_symbol): Update.
	* symtab.c (fixup_section): Update.
	* symtab.h (struct general_symbol_info) <sinfo>: New union field.
	(SYMBOL_OBJ_SECTION): Update.
	(MSYMBOL_OBJ_SECTION): Update.
---
 gdb/ada-lang.c |    4 ++--
 gdb/symtab.c   |    4 ++--
 gdb/symtab.h   |   15 +++++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1857f89..81a0fe6 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1256,9 +1256,9 @@ ada_decode_symbol (const struct general_symbol_info *gsymbol)
     {
       const char *decoded = ada_decode (gsymbol->name);
 
-      if (gsymbol->obj_section != NULL)
+      if (gsymbol->sinfo.obj_section != NULL)
         {
-	  struct objfile *objf = gsymbol->obj_section->objfile;
+	  struct objfile *objf = gsymbol->sinfo.obj_section->objfile;
 
 	  *resultp = obsavestring (decoded, strlen (decoded),
 				   &objf->objfile_obstack);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 4837235..071c203 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -951,7 +951,7 @@ fixup_section (struct general_symbol_info *ginfo,
   msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->name, objfile);
   if (msym)
     {
-      ginfo->obj_section = MSYMBOL_OBJ_SECTION (msym);
+      ginfo->sinfo.obj_section = MSYMBOL_OBJ_SECTION (msym);
       ginfo->section = MSYMBOL_SECTION (msym);
     }
   else
@@ -1002,7 +1002,7 @@ fixup_section (struct general_symbol_info *ginfo,
 	  if (obj_section_addr (s) - offset <= addr
 	      && addr < obj_section_endaddr (s) - offset)
 	    {
-	      ginfo->obj_section = s;
+	      ginfo->sinfo.obj_section = s;
 	      ginfo->section = idx;
 	      return;
 	    }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 5de89db..864d8c8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -159,9 +159,16 @@ struct general_symbol_info
 
   short section;
 
-  /* The section associated with this symbol.  It can be NULL.  */
+  union
+  {
+    /* The section associated with this symbol.  It can be NULL.  */
+
+    struct obj_section *obj_section;
 
-  struct obj_section *obj_section;
+    /* For minimal symbols, we instead record an index into the
+       objfile's 'sections' array.  */
+    unsigned int index;
+  } sinfo;
 };
 
 extern void symbol_set_demangled_name (struct general_symbol_info *, char *,
@@ -186,7 +193,7 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 #define SYMBOL_VALUE_CHAIN(symbol)	(symbol)->ginfo.value.chain
 #define SYMBOL_LANGUAGE(symbol)		(symbol)->ginfo.language
 #define SYMBOL_SECTION(symbol)		(symbol)->ginfo.section
-#define SYMBOL_OBJ_SECTION(symbol)	(symbol)->ginfo.obj_section
+#define SYMBOL_OBJ_SECTION(symbol)	(symbol)->ginfo.sinfo.obj_section
 
 /* Initializes the language dependent portion of a symbol
    depending upon the language for the symbol.  */
@@ -380,7 +387,7 @@ struct minimal_symbol
 #define MSYMBOL_VALUE_CHAIN(symbol)	(symbol)->mginfo.value.chain
 #define MSYMBOL_LANGUAGE(symbol)	(symbol)->mginfo.language
 #define MSYMBOL_SECTION(symbol)		(symbol)->mginfo.section
-#define MSYMBOL_OBJ_SECTION(symbol)	(symbol)->mginfo.obj_section
+#define MSYMBOL_OBJ_SECTION(symbol)	(symbol)->mginfo.sinfo.obj_section
 
 #define MSYMBOL_NATURAL_NAME(symbol) \
   (symbol_natural_name (&(symbol)->mginfo))
-- 
1.7.6.4


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