From patchwork Mon Sep 14 13:50:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 8674 Received: (qmail 52457 invoked by alias); 14 Sep 2015 13:50:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 52446 invoked by uid 89); 14 Sep 2015 13:50:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f171.google.com Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 14 Sep 2015 13:50:03 +0000 Received: by wiclk2 with SMTP id lk2so141746684wic.0 for ; Mon, 14 Sep 2015 06:50:00 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.11.175 with SMTP id r15mr26790136wib.74.1442238600507; Mon, 14 Sep 2015 06:50:00 -0700 (PDT) Received: by 10.27.83.201 with HTTP; Mon, 14 Sep 2015 06:50:00 -0700 (PDT) Date: Mon, 14 Sep 2015 15:50:00 +0200 Message-ID: Subject: [PATCH] [D] Fix regression in py-lookup-type.exp From: Iain Buclaw To: GDB Patches X-IsSubscribed: yes Hi, Implementation shamelessly borrowed from Doug Evans. :-) Regards Iain gdb/ChangeLog: * d-namespace.c (d_lookup_symbol): New arg langdef. All callers updated. Support looking up symbol as a primitive type. (lookup_module_scope): New arg langdef. All callers updated. Call d_lookup_symbol directly for simple bare symbols. diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index bed8d5b..1b6cafc 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -74,7 +74,8 @@ d_entire_prefix_len (const char *name) symbol. Other arguments are as in d_lookup_symbol_nonlocal. */ static struct block_symbol -d_lookup_symbol (const char *name, const struct block *block, +d_lookup_symbol (const struct language_defn *langdef, + const char *name, const struct block *block, const domain_enum domain, int search) { struct block_symbol sym; @@ -83,6 +84,23 @@ d_lookup_symbol (const char *name, const struct block *block, if (sym.symbol != NULL) return sym; + /* If we didn't find a definition for a builtin type in the static block, + such as "ucent" which is a specialist type, search for it now. */ + if (langdef != NULL && domain == VAR_DOMAIN) + { + struct gdbarch *gdbarch; + + if (block == NULL) + gdbarch = target_gdbarch (); + else + gdbarch = block_gdbarch (block); + sym.symbol + = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name); + sym.block = NULL; + if (sym.symbol != NULL) + return sym; + } + sym = lookup_global_symbol (name, block, domain); if (sym.symbol != NULL) @@ -174,7 +192,7 @@ d_lookup_symbol_in_module (const char *module, const char *name, name = concatenated_name; } - return d_lookup_symbol (name, block, domain, search); + return d_lookup_symbol (NULL, name, block, domain, search); } /* Lookup NAME at module scope. SCOPE is the module that the current @@ -190,7 +208,8 @@ d_lookup_symbol_in_module (const char *module, const char *name, and if that call fails, then the first call looks for "x". */ static struct block_symbol -lookup_module_scope (const char *name, const struct block *block, +lookup_module_scope (const struct language_defn *langdef, + const char *name, const struct block *block, const domain_enum domain, const char *scope, int scope_len) { @@ -210,14 +229,22 @@ lookup_module_scope (const char *name, const struct block *block, new_scope_len++; } new_scope_len += d_find_first_component (scope + new_scope_len); - sym = lookup_module_scope (name, block, domain, + sym = lookup_module_scope (langdef, name, block, domain, scope, new_scope_len); if (sym.symbol != NULL) return sym; } /* Okay, we didn't find a match in our children, so look for the - name in the current module. */ + name in the current module. + + If we there is no scope and we know we have a bare symbol, then short + circuit everything and call d_lookup_symbol directly. + This isn't an optimization, rather it allows us to pass LANGDEF which + is needed for primitive type lookup. */ + + if (scope_len == 0 && strchr (name, '.') == NULL) + return d_lookup_symbol (langdef, name, block, domain, 1); module = alloca (scope_len + 1); strncpy (module, scope, scope_len); @@ -465,7 +492,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, /* If the alias matches the sought name. Pass current->import_src as the NAME to direct the search towards the aliased module. */ - sym = lookup_module_scope (current->import_src, block, + sym = lookup_module_scope (NULL, current->import_src, block, domain, scope, 0); } else @@ -554,7 +581,7 @@ d_lookup_symbol_nonlocal (const struct language_defn *langdef, struct block_symbol sym; const char *scope = block_scope (block); - sym = lookup_module_scope (name, block, domain, scope, 0); + sym = lookup_module_scope (langdef, name, block, domain, scope, 0); if (sym.symbol != NULL) return sym;