This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] create and use symbol_set_language
- From: Doug Evans <dje at google dot com>
- To: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>
- Cc: sami wagiaalla <swagiaal at redhat dot com>, gdb-patches at sourceware dot org
- Date: Wed, 4 Aug 2010 14:56:41 -0700
- Subject: Re: [patch] create and use symbol_set_language
- References: <4C582E25.1030505@redhat.com> <6308127460174723176@unknownmsgid>
On Wed, Aug 4, 2010 at 12:27 AM, Pierre Muller
<pierre.muller@ics-cnrs.unistra.fr> wrote:
> Hi Sami,
>
> ?I just looked at your patch, which seems
> quite straightforward.
>
> ?Nevertheless, it seems that
> it contains a change that is not commented:
>
> @@ -393,13 +393,11 @@ symbol_get_demangled_name (const struct
> general_symbol_info *gsymbol)
> ?/* 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)
> +symbol_set_language (struct general_symbol_info *gsymbol,
> + ? ? ? ? ? ? ? ? ? ? enum language language)
> ?{
> -
> ? gsymbol->language = language;
> - ?if (gsymbol->language == language_cplus
> - ? ? ?|| gsymbol->language == language_d
> + ?if (gsymbol->language == language_d
> ? ? ? || gsymbol->language == language_java
> ? ? ? || gsymbol->language == language_objc
> ? ? ? || gsymbol->language == language_fortran)
>
> ?The removal of the 'gsymbol->language == language_cplus'
> condition seems to be outside of the scope of the patch you
> describe, which seems otherwise quite straightforward.
>
> ?Could you please comment on the reason of that specific change?
> Is it really part of that patch or shouldn't it be submitted
> separately? I must confess that I didn't even try to
> look at the source code after the 'if', but just reacted quickly
> on something that seem 'off topic' as compared to
> your patch description.
Yeah. This part of the patch is correct, it just needs a ChangeLog entry.
[One could submit it separately, but I don't mind it being included here.]
What's happening here is that language_cplus is being checked for twice.
Here's the current definition of the function.
void
symbol_init_language_specific (struct general_symbol_info *gsymbol,
enum language language)
{
gsymbol->language = language;
if (gsymbol->language == language_cplus
|| gsymbol->language == language_d
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
{
symbol_set_demangled_name (gsymbol, NULL, NULL);
}
else if (gsymbol->language == language_cplus)
gsymbol->language_specific.cplus_specific = NULL;
else
{
memset (&gsymbol->language_specific, 0,
sizeof (gsymbol->language_specific));
}
}
The patch is generally ok, but a bit more is required:
- the additional ChangeLog entry to mention fixing test of language_cplus
- after applying the patch, grepping for SYMBOL_INIT still has a few
hits that need to be addressed:
gdb$ grep SYMBOL_INIT *.[ch]
buildsym.c:#include "demangle.h" /* Needed by
SYMBOL_INIT_DEMANGLED_NAME. */
symtab.h: the SYMBOL_INIT_LANGUAGE_SPECIFIC, SYMBOL_DEMANGLED_NAME, etc.
- one potential formatting nit:
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index b62156c..ea9d1e0 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -704,7 +704,7 @@ define_symbol (CORE_ADDR valu, char *string, int
desc, int type,
else
{
normal:
- SYMBOL_LANGUAGE (sym) = current_subfile->language;
+ SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
{
char *name = alloca (p - string + 1);
I'm happy with the patch with those changes.