This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] symtab.h: Remove cplus_specific.
- From: dje at google dot com (Doug Evans)
- To: swagiaal at redhat dot com, tromey at redhat dot com, gdb-patches at sourceware dot org
- Date: Sat, 10 Dec 2011 18:28:50 -0800 (PST)
- Subject: [RFA] symtab.h: Remove cplus_specific.
Hi.
symtab.h:cplus_specific was moved out of general_symbol_info here:
2010-07-16 Sami Wagiaalla <swagiaal@redhat.com>
* symtab.h (symbol_set_demangled_name): Now takes an optional objfile*
argument.
(cplus_specific): New struct.
* symtab.c (symbol_set_demangled_name): Updated.
Use cplus_specific for cplus symbols.
(symbol_get_demangled_name): Retrive the name from the cplus_specific
struct for cplus symbols.
(symbol_init_language_specific): Set cplus_specific for cplus symbols.
(symbol_set_names): Pass objfile to symbol_set_demangled_name.
* symtab.c (symbol_init_cplus_specific): New function.
originally proposed here:
http://sourceware.org/ml/gdb-patches/2010-05/msg00594.html
However it still has only has one member: demangled_name.
Does Redhat have further plans for cplus_specific?
This patch simplifies things a fair bit.
Maybe too much, but OTOH are there currently any plans to add, say,
more to struct mangled_lang? [Setting aside cplus_specific which is
my first question above.] I suspect not, and thus I'd like to
keep things simple until the complexity is needed.
[And if/when one might want to add more to, say, mangled_lang,
I suspect one would instead create a new struct, mylang_specific,
or some such.]
2011-12-10 Doug Evans <dje@google.com>
* symtab.h (cplus_specific): Delete.
(struct general_symbol_info): Merge language_specific members
mangled_lang and cplus_specific into one: demangled_name. All uses
updated.
* symtab.c (symbol_init_cplus_specific): Delete.
(symbol_set_demangled_name): Delete parameter `objfile', all callers
updated.
* cp-namespace.c (cp_lookup_symbol_imports_or_template): Delete unused
locals i, cps.
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.318
diff -u -p -r1.318 ada-lang.c
--- ada-lang.c 6 Dec 2011 18:54:38 -0000 1.318
+++ ada-lang.c 11 Dec 2011 01:29:32 -0000
@@ -1250,7 +1250,7 @@ char *
ada_decode_symbol (const struct general_symbol_info *gsymbol)
{
char **resultp =
- (char **) &gsymbol->language_specific.mangled_lang.demangled_name;
+ (char **) &gsymbol->language_specific.demangled_name;
if (*resultp == NULL)
{
Index: cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.56
diff -u -p -r1.56 cp-namespace.c
--- cp-namespace.c 4 Nov 2011 16:37:17 -0000 1.56
+++ cp-namespace.c 11 Dec 2011 01:29:32 -0000
@@ -474,10 +474,6 @@ cp_lookup_symbol_imports_or_template (co
if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
{
- int i;
- struct cplus_specific *cps
- = function->ginfo.language_specific.cplus_specific;
-
/* Search the function's template parameters. */
if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function))
{
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.586
diff -u -p -r1.586 dwarf2read.c
--- dwarf2read.c 10 Dec 2011 23:57:39 -0000 1.586
+++ dwarf2read.c 11 Dec 2011 01:29:32 -0000
@@ -11741,8 +11737,7 @@ new_symbol_full (struct die_info *die, s
if (cu->language == language_fortran
&& symbol_get_demangled_name (&(sym->ginfo)) == NULL)
symbol_set_demangled_name (&(sym->ginfo),
- (char *) dwarf2_full_name (name, die, cu),
- NULL);
+ (char *) dwarf2_full_name (name, die, cu));
/* Default assumptions.
Use the passed type or decode it from the die. */
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.288
diff -u -p -r1.288 symtab.c
--- symtab.c 6 Dec 2011 18:54:39 -0000 1.288
+++ symtab.c 11 Dec 2011 01:29:32 -0000
@@ -404,55 +404,22 @@ gdb_mangle_name (struct type *type, int
return (mangled_name);
}
-/* Initialize the cplus_specific structure. 'cplus_specific' should
- only be allocated for use with cplus symbols. */
-
-static void
-symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
- struct objfile *objfile)
-{
- /* A language_specific structure should not have been previously
- initialized. */
- gdb_assert (gsymbol->language_specific.cplus_specific == NULL);
- gdb_assert (objfile != NULL);
-
- gsymbol->language_specific.cplus_specific =
- OBSTACK_ZALLOC (&objfile->objfile_obstack, struct cplus_specific);
-}
-
/* Set the demangled name of GSYMBOL to NAME. NAME must be already
- correctly allocated. For C++ symbols a cplus_specific struct is
- allocated so OBJFILE must not be NULL. If this is a non C++ symbol
- OBJFILE can be NULL. */
+ correctly allocated. */
+
void
symbol_set_demangled_name (struct general_symbol_info *gsymbol,
- char *name,
- struct objfile *objfile)
+ char *name)
{
- if (gsymbol->language == language_cplus)
- {
- if (gsymbol->language_specific.cplus_specific == NULL)
- symbol_init_cplus_specific (gsymbol, objfile);
-
- gsymbol->language_specific.cplus_specific->demangled_name = name;
- }
- else
- gsymbol->language_specific.mangled_lang.demangled_name = name;
+ gsymbol->language_specific.demangled_name = name;
}
/* Return the demangled name of GSYMBOL. */
+
char *
symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
{
- if (gsymbol->language == language_cplus)
- {
- if (gsymbol->language_specific.cplus_specific != NULL)
- return gsymbol->language_specific.cplus_specific->demangled_name;
- else
- return NULL;
- }
- else
- return gsymbol->language_specific.mangled_lang.demangled_name;
+ return gsymbol->language_specific.demangled_name;
}
@@ -464,14 +431,13 @@ symbol_set_language (struct general_symb
{
gsymbol->language = language;
if (gsymbol->language == language_d
+ || gsymbol->language == language_cplus
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
{
- symbol_set_demangled_name (gsymbol, NULL, NULL);
+ symbol_set_demangled_name (gsymbol, NULL);
}
- else if (gsymbol->language == language_cplus)
- gsymbol->language_specific.cplus_specific = NULL;
else
{
memset (&gsymbol->language_specific, 0,
@@ -653,7 +619,7 @@ symbol_set_names (struct general_symbol_
memcpy (gsymbol->name, linkage_name, len);
gsymbol->name[len] = '\0';
}
- symbol_set_demangled_name (gsymbol, NULL, NULL);
+ symbol_set_demangled_name (gsymbol, NULL);
return;
}
@@ -749,9 +715,9 @@ symbol_set_names (struct general_symbol_
gsymbol->name = (*slot)->mangled + lookup_len - len;
if ((*slot)->demangled[0] != '\0')
- symbol_set_demangled_name (gsymbol, (*slot)->demangled, objfile);
+ symbol_set_demangled_name (gsymbol, (*slot)->demangled);
else
- symbol_set_demangled_name (gsymbol, NULL, objfile);
+ symbol_set_demangled_name (gsymbol, NULL);
}
/* Return the source code name of a symbol. In languages where
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.193
diff -u -p -r1.193 symtab.h
--- symtab.h 6 Dec 2011 18:54:39 -0000 1.193
+++ symtab.h 11 Dec 2011 01:29:32 -0000
@@ -78,13 +78,6 @@ struct language_defn;
--chastain 2003-08-21 */
-/* Struct for storing C++ specific information. Allocated when needed. */
-
-struct cplus_specific
-{
- char *demangled_name;
-};
-
/* Define a structure for the information that is common to all symbol types,
including minimal symbols, partial symbols, and full symbols. In a
multilanguage environment, some language specific information may need to
@@ -128,19 +121,20 @@ struct general_symbol_info
value;
/* Since one and only one language can apply, wrap the language specific
- information inside a union. */
+ information inside a union.
+
+ N.B. Since the size of this struct is important to keep minimal, if you
+ need to add something that would otherwise grow the size of this union,
+ allocate it separately and record a pointer to the allocated data here.
+ This will avoid penalizing other languages.
+ For an example of this see the implementation of cplus_specific in
+ GDB 7.3. */
union
{
/* This is used by languages which wish to store a demangled name.
- currently used by Ada, Java, and Objective C. */
- struct mangled_lang
- {
- char *demangled_name;
- }
- mangled_lang;
-
- struct cplus_specific *cplus_specific;
+ currently used by Ada, C++, Java, and Objective C. */
+ char *demangled_name;
}
language_specific;
@@ -164,8 +158,7 @@ struct general_symbol_info
struct obj_section *obj_section;
};
-extern void symbol_set_demangled_name (struct general_symbol_info *, char *,
- struct objfile *);
+extern void symbol_set_demangled_name (struct general_symbol_info *, char *);
extern char *symbol_get_demangled_name (const struct general_symbol_info *);