From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28309 invoked by alias); 3 Nov 2010 01:34:16 -0000 Received: (qmail 27905 invoked by uid 22791); 3 Nov 2010 01:34:15 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.windriver.com (HELO mail.windriver.com) (147.11.1.11) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Nov 2010 01:34:10 +0000 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.windriver.com (8.14.3/8.14.3) with ESMTP id oA31Xlls004690; Tue, 2 Nov 2010 18:33:47 -0700 (PDT) Received: from ala-mail06.corp.ad.wrs.com ([147.11.57.147]) by ALA-MAIL03.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 2 Nov 2010 18:33:46 -0700 Received: from [128.224.158.168] ([128.224.158.168]) by ala-mail06.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 2 Nov 2010 18:33:47 -0700 Message-ID: <4CD0BC2C.8000307@windriver.com> Date: Wed, 03 Nov 2010 01:34:00 -0000 From: "Liu, Lei" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH] call cp_lookup_symbol_namespace recursively to search symbols in C++ base classes References: <4CCF89F0.5090100@windriver.com> <1288685151.4864.31.camel@yaolp> In-Reply-To: <1288685151.4864.31.camel@yaolp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00057.txt.bz2 On 2010年11月02日 16:05, Yao Qi wrote: > On Tue, 2010-11-02 at 11:48 +0800, Liu, Lei wrote: > > Here are my two cents on coding conventions. > > >> diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c >> index 16f58ca..822423e 100644 >> --- a/gdb/cp-namespace.c >> +++ b/gdb/cp-namespace.c >> @@ -513,6 +513,8 @@ cp_lookup_symbol_namespace (const char *scope, >> const domain_enum domain) >> { >> struct symbol *sym; >> + struct symbol *scope_sym; >> + struct type *scope_type; >> >> > Add one more space before "struct". > > >> /* First, try to find the symbol in the given namespace. */ >> sym = cp_lookup_symbol_in_namespace (scope, name, block, 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; >> + >> + scope_sym = lookup_symbol (scope, NULL, VAR_DOMAIN, NULL); >> + if (scope_sym == NULL) >> + return NULL; >> + >> + scope_type = SYMBOL_TYPE(scope_sym); >> > Add a space between SYMBOL_TYPE and "(". > > >> + if (scope_type == NULL) >> + return NULL; >> + >> + if (TYPE_CODE (scope_type) == TYPE_CODE_STRUCT) >> + { >> + int nbases = TYPE_N_BASECLASSES (scope_type); >> + int i; >> + for (i = 0; i< nbases; i++) >> + { >> + const char *base_name = TYPE_BASECLASS_NAME (scope_type, i); >> + sym = cp_lookup_symbol_namespace (base_name, name, block, >> domain); >> + if (sym != NULL) >> + return sym; >> + } >> + } >> + >> return NULL; >> } >> > Thanks for the corrections. Lei