Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Liu, Lei" <lei.liu2@windriver.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] call cp_lookup_symbol_namespace recursively to search symbols in C++ base classes
Date: Wed, 03 Nov 2010 02:55:00 -0000	[thread overview]
Message-ID: <4CD0CF42.8010203@windriver.com> (raw)
In-Reply-To: <201011030009.47662.pedro@codesourcery.com>

On 2010年11月03日 08:09, Pedro Alves wrote:
> Hi!
>
> I'm looking at this exact problem as well.  :-)
>
>> 2010-11-02  Lei Liu<lei.liu2@windriver.com>
>>
>>       * cp-namespace.c (cp_lookup_symbol_namespace): Recursively call
>>       itself to search C++ base classes.
>
>> @@ -513,6 +513,8 @@ cp_lookup_symbol_namespace (const char *scope,
>>                                const domain_enum domain)
>>    {
> ...
>> @@ -530,6 +532,31 @@ cp_lookup_symbol_namespace (const char *scope,
>>          block = BLOCK_SUPERBLOCK (block);
>>        }
>>
>> +  /* If scope is a C++ class, we need to search all its base classes.  */
>> +  if (scope == NULL || scope[0] == '\0')
>> +    return NULL;
>
> Your testcase is not hitting this empty scope check, due to your
> "#include<cstdio>", which does namespace things, and
> ends up emitting DW_TAG_namespace in the debug info, and
> so dwarf2read.c sets the processing_has_namespace_info
> global, and so a "namespace" for you test's class
> is installed by:
>
>    /* For C++, set the block's scope.  */
>    if (cu->language == language_cplus || cu->language == language_fortran)
>      cp_set_block_scope (new->name, block,&objfile->objfile_obstack,
> 			determine_prefix (die, cu),
> 			processing_has_namespace_info);
>
> If I remove that include from your test (and the printf), then
> the patch no longer works.  We need to do something here.

Right. There is a problem here. It seems that we can't rely on the
scope name as C++ class name since it may not be set in some cases.
Is there any other way to get the class name from a block? If not,
I think we need to set the scope regardless of value of
processing_has_namespace_info.

>
> A related issue that should be addressed as well, I think, is:
>
>   class A {
>   public:
>     enum E { X, Y, Z };
>   };
>
>   A a;
>
> Both "print a.X" and "ptype a.X" should work.  I've got a
> patch that fixes this part, and a dejagnuified testcase,
> but haven't sorted out the processing_has_namespace_info
> part yet.
>
Thanks.
Lei


  reply	other threads:[~2010-11-03  2:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-02  3:47 Liu, Lei
2010-11-02  8:06 ` Yao Qi
2010-11-03  1:34   ` Liu, Lei
2010-11-02 20:31 ` Tom Tromey
2010-11-03  1:41   ` Liu, Lei
2010-11-03  0:10 ` Pedro Alves
2010-11-03  2:55   ` Liu, Lei [this message]
2010-11-03 17:57     ` Pedro Alves
2010-11-04  8:51   ` Liu, Lei
2010-11-07 10:04     ` Yao Qi
2010-11-08  1:38       ` Liu, Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CD0CF42.8010203@windriver.com \
    --to=lei.liu2@windriver.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox