From patchwork Sun Oct 11 11:23:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 9046 Received: (qmail 36386 invoked by alias); 11 Oct 2015 11:23:41 -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 36368 invoked by uid 89); 11 Oct 2015 11:23:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 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-f169.google.com Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 11 Oct 2015 11:23:39 +0000 Received: by wijq8 with SMTP id q8so21149252wij.0 for ; Sun, 11 Oct 2015 04:23:36 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.11.175 with SMTP id r15mr9232243wib.74.1444562616091; Sun, 11 Oct 2015 04:23:36 -0700 (PDT) Received: by 10.27.191.196 with HTTP; Sun, 11 Oct 2015 04:23:35 -0700 (PDT) Date: Sun, 11 Oct 2015 13:23:35 +0200 Message-ID: Subject: [PATCH 1/2] [D] Don't recursively look for a symbol in all imports of imported modules. From: Iain Buclaw To: GDB Patches X-IsSubscribed: yes Consider the following pathological case: --- module A; import B, C; --- module C; import A; --- When looking up a symbol in module 'B' from module 'A', although it won't lead to infinite recursion, it will cause a to and fro to occur between the two cyclic imports. This get exponentially worse when there are tens or hundreds of modules all importing each other. Although there is a genuine case to recursively search imports from foreign modules, this only makes sense in D for 'public' imports, which would be expressed as: --- module A; import B; --- module B; public import C; // All symbols in 'C' are available to any module that imports 'B' --- However there is no way to detect this as of today in DWARFv4. Only DW_TAG_imported_declarations get a DW_AT_accessibility attribute. Though perhaps DW_AT_visibility would be more accurate because 'static import' would be considered as qualified. But I digress on matters outside the scope of this patch. :-) Regards, Iain. --- gdb/ChangeLog: * d-namespace.c (d_lookup_symbol_imports): Avoid recursive lookups from cyclic imports. --- diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index e8f4c6f..da5da58 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -508,9 +508,9 @@ d_lookup_symbol_imports (const char *scope, const char *name, { /* Skip the '.' */ name_scope++; - sym = d_lookup_symbol_imports (current->import_src, - name + name_scope, - block, domain, 0); + sym = d_lookup_symbol_in_module (current->import_src, + name + name_scope, + block, domain, 1); } } } @@ -519,8 +519,8 @@ d_lookup_symbol_imports (const char *scope, const char *name, /* If this import statement creates no alias, pass current->import_src as MODULE to direct the search towards the imported module. */ - sym = d_lookup_symbol_imports (current->import_src, - name, block, domain, 0); + sym = d_lookup_symbol_in_module (current->import_src, + name, block, domain, 1); } current->searched = 0; discard_cleanups (searched_cleanup);