From patchwork Mon Feb 22 01:20:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 10977 Received: (qmail 33357 invoked by alias); 22 Feb 2016 01:20:37 -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 33338 invoked by uid 89); 22 Feb 2016 01:20:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f66.google.com Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 22 Feb 2016 01:20:34 +0000 Received: by mail-wm0-f66.google.com with SMTP id a4so16001419wme.3 for ; Sun, 21 Feb 2016 17:20:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:date:message-id:subject:from :to:cc:content-type; bh=zy+vdhMSrkU4sdYMj80I2q56S2gZxmdPfKktrmsnRSw=; b=SZVsXIXtToTy/wmJKReSUZjBUZFsuih4vptYES+Rju7s2uQW6bI53sZ+rTt+M3kFSx BhqZs+seTFZDqAcD3XBRZnQ92aq1JAyemjaYr55354idB1plw59OAXVh2+ioBJTHHH0s z0NGwItir0rs29/JVF59m91j17Gq5QfD0qRAwKycXtlW1bL6YLXC5uoRXg55qEr6BnNe /tdv7ohLrlI6uZlWzQpckdUx/KAgG7lfml/KFScJc9In9GMlTd+Q0pyWK1LYhDolxLym HPC1DQIVuUSA7b2RK0TnAY+hvl3n9q1imopVDnBuYurKpxht6oH8Y1b1FIbURQaoz968 Yr5w== X-Gm-Message-State: AG10YOSahdfBMkARcpiF03rRI3UBSfLtZH7Z5WGgWVd9IJYfIf1MoZvZ94YmgGR/OiclENq6IacL2zmxy7MMLA== MIME-Version: 1.0 X-Received: by 10.194.185.237 with SMTP id ff13mr27997996wjc.129.1456104031545; Sun, 21 Feb 2016 17:20:31 -0800 (PST) Received: by 10.28.21.140 with HTTP; Sun, 21 Feb 2016 17:20:31 -0800 (PST) Date: Mon, 22 Feb 2016 02:20:31 +0100 Message-ID: Subject: [PATCH v3] [D] Don't recursively look for a symbol in all imports of imported modules. From: Iain Buclaw To: GDB Patches Cc: Pedro Alves X-IsSubscribed: yes Hi, Third time's a charm. This time I've removed the x86-specific dwarf assembly file and replaced it with Dwarf::assemble as per Pedro's suggestion. (Thanks!) Tested, and confirmed that without the patch, the circular test given loops forever. Regards, Iain. gdb/ChangeLog: * d-namespace.c (d_lookup_symbol_imports): Avoid recursive lookups from cyclic imports. gdb/testsuite/ChangeLog: * gdb.dlang/circular.c: New file. * gdb.dlang/circular.exp: New file. --- diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 6399ef0..8b8c3cc 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -483,9 +483,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); + sym = d_lookup_symbol_in_module (current->import_src, + name + name_scope, + block, domain, 1); } } } @@ -494,8 +494,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); + sym = d_lookup_symbol_in_module (current->import_src, + name, block, domain, 1); } current->searched = 0; discard_cleanups (searched_cleanup); diff --git a/gdb/testsuite/gdb.dlang/circular.c b/gdb/testsuite/gdb.dlang/circular.c new file mode 100644 index 0000000..a946e3f --- /dev/null +++ b/gdb/testsuite/gdb.dlang/circular.c @@ -0,0 +1,33 @@ +/* Copyright 2016 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +asm ("circular1_found_start: .globl circular1_found_start"); + +/* DWARF will describe this function as being inside a D module. */ + +void +found (void) +{ +} + +asm ("circular1_found_end: .globl circular1_found_end"); + +int +main (void) +{ + found (); + return 0; +} + diff --git a/gdb/testsuite/gdb.dlang/circular.exp b/gdb/testsuite/gdb.dlang/circular.exp new file mode 100644 index 0000000..c6eb789 --- /dev/null +++ b/gdb/testsuite/gdb.dlang/circular.exp @@ -0,0 +1,149 @@ +# Copyright (C) 2016 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test symbol lookup when there are multiple circular imports. + +load_lib "d-support.exp" +load_lib "dwarf.exp" + +if { [skip_d_tests] } { continue } + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +standard_testfile circular.c circular-dw.S + +# Make some DWARF for the test. +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + cu {} { + compile_unit { + {language @DW_LANG_D} + } { + declare_labels circular1_label circular2_label circular3_label + declare_labels circular4_label circular5_label + + extern circular1_found_start circular1_found_end + + circular1_label: module { + {name circular1} + } { + imported_module { + {import :$circular2_label} + } + imported_module { + {import :$circular3_label} + } + imported_module { + {import :$circular4_label} + } + imported_module { + {import :$circular5_label} + } + + subprogram { + {name found} + {external 1 flag_present} + {low_pc circular1_found_start addr} + {high_pc circular1_found_end addr} + } + } + + circular2_label: module { + {name circular2} + } { + imported_module { + {import :$circular1_label} + } + imported_module { + {import :$circular3_label} + } + imported_module { + {import :$circular4_label} + } + imported_module { + {import :$circular5_label} + } + } + + circular3_label: module { + {name circular3} + } { + imported_module { + {import :$circular1_label} + } + imported_module { + {import :$circular2_label} + } + imported_module { + {import :$circular4_label} + } + imported_module { + {import :$circular5_label} + } + } + + circular4_label: module { + {name circular4} + } { + imported_module { + {import :$circular1_label} + } + imported_module { + {import :$circular2_label} + } + imported_module { + {import :$circular3_label} + } + imported_module { + {import :$circular5_label} + } + } + + circular5_label: module { + {name circular5} + } { + imported_module { + {import :$circular1_label} + } + imported_module { + {import :$circular2_label} + } + imported_module { + {import :$circular3_label} + } + imported_module { + {import :$circular4_label} + } + } + } + } +} + +if { [prepare_for_testing ${testfile}.exp ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +gdb_test_no_output "set language d" + +if {![runto "circular1.found"]} { + return -1 +} + +# This last test shouldn't timeout. +gdb_test "print notfound" "No symbol \"notfound\" in current context."