From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23721 invoked by alias); 23 Dec 2011 10:38:59 -0000 Received: (qmail 23602 invoked by uid 22791); 23 Dec 2011 10:38:56 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,TW_BJ X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Dec 2011 10:38:42 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 821CC2BB4CA; Fri, 23 Dec 2011 05:38:41 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RZ5uwl5DjP1M; Fri, 23 Dec 2011 05:38:41 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 0A69C2BB4C3; Fri, 23 Dec 2011 05:38:41 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id DAC95145616; Fri, 23 Dec 2011 02:38:31 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match... Date: Fri, 23 Dec 2011 10:39:00 -0000 Message-Id: <1324636693-24034-2-git-send-email-brobecker@adacore.com> In-Reply-To: <20111221140128.GK23376@adacore.com> References: <20111221140128.GK23376@adacore.com> 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: 2011-12/txt/msg00801.txt.bz2 ... to avoid code duplication. This is just an independent cleanup which I'll commit shortly. gdb/ChangeLog: * ada-lang.c (should_use_wild_match): New function. (ada_lookup_simple_minsym): Use should_use_wild_match. Minor simplification. Add comment. (ada_lookup_symbol_list): Use should_use_wild_match. Minor simplification. --- gdb/ada-lang.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8f4292f..09ab38d 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4161,6 +4161,18 @@ cache_symbol (const char *name, domain_enum namespace, struct symbol *sym, /* Symbol Lookup */ +/* Return nonzero if wild matching should be used when searching for + all symbols matching LOOKUP_NAME. + + LOOKUP_NAME is expected to be a symbol name after transformation + for Ada lookups (see ada_name_for_lookup). */ + +static int +should_use_wild_match (const char *lookup_name) +{ + return (strstr (lookup_name, "__") == NULL); +} + /* Return the result of a standard (literal, C-like) lookup of NAME in given DOMAIN, visible from lexical block BLOCK. */ @@ -4326,15 +4338,17 @@ ada_lookup_simple_minsym (const char *name) { struct objfile *objfile; struct minimal_symbol *msymbol; - int wild_match; + const int wild_match = should_use_wild_match (name); + /* Special case: If the user specifies a symbol name inside package + Standard, do a non-wild matching of the symbol name without + the "standard__" prefix. This was primarily introduced in order + to allow the user to specifically access the standard exceptions + using, for instance, Standard.Constraint_Error when Constraint_Error + is ambiguous (due to the user defining its own Constraint_Error + entity inside its program). */ if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0) - { - name += sizeof ("standard__") - 1; - wild_match = 0; - } - else - wild_match = (strstr (name, "__") == NULL); + name += sizeof ("standard__") - 1; ALL_MSYMBOLS (objfile, msymbol) { @@ -4979,7 +4993,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, struct symbol *sym; struct block *block; const char *name; - int wild_match; + const int wild_match = should_use_wild_match (name0); int cacheIfUnique; int ndefns; @@ -4990,7 +5004,6 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, /* Search specified block and its superiors. */ - wild_match = (strstr (name0, "__") == NULL); name = name0; block = (struct block *) block0; /* FIXME: No cast ought to be needed, but adding const will @@ -5005,7 +5018,6 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0, entity inside its program). */ if (strncmp (name0, "standard__", sizeof ("standard__") - 1) == 0) { - wild_match = 0; block = NULL; name = name0 + sizeof ("standard__") - 1; } -- 1.7.1