From patchwork Wed Sep 25 22:53:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 34664 Received: (qmail 49210 invoked by alias); 25 Sep 2019 22:53:14 -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 49196 invoked by uid 89); 25 Sep 2019 22:53:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=1.2, HX-Languages-Length:4244, format_string X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Sep 2019 22:53:12 +0000 Received: by mail-wm1-f65.google.com with SMTP id r19so433717wmh.2 for ; Wed, 25 Sep 2019 15:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hJHv2sLPIllhRuuwobJDqBwSteVHSdIKIPwbxVcogXY=; b=PB/zNru1++aex4bzJdUvMZMI5f1UBbuPcTV0N0MKQeQBZeXD3xRcV8BCrTShA+4J+m SIJFwxZ6j8tXT1Cjh2/zRtVUd5XX+U2yGFGYeeIcDjGbvgFd1eff0re9I/nfZq/ofHld MmZpw733qxVsZCGtUswtwcgn07RkwNGlxH4niebk1BQdoF0dgZscvRUKTDIKzVBm30WH llwNMuTrjXnuhnPsX7HSsItriHo1sNHjeZE56+GGKI+pLu5sxrGx4Ilt0sbCe4LqaHTn hv/i3BdiVMKQXS/HSEeooYpOdVLW+5LbyZwFUAyQbiid9GuBKE1rZ2yd2zClSsULQi9n trZw== Return-Path: Received: from localhost (host86-128-12-122.range86-128.btcentralplus.com. [86.128.12.122]) by smtp.gmail.com with ESMTPSA id s12sm1098721wra.82.2019.09.25.15.53.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Sep 2019 15:53:09 -0700 (PDT) Date: Wed, 25 Sep 2019 23:53:08 +0100 From: Andrew Burgess To: Simon Marchi Cc: gdb-patches@sourceware.org, Richard Bunt Subject: Re: [PATCH 2/2] gdb/fortran: Allow for matching symbols with missing scope Message-ID: <20190925225308.GQ4962@embecosm.com> References: <4fa7b0c3-cc43-b2ad-2d37-96db443654ca@simark.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4fa7b0c3-cc43-b2ad-2d37-96db443654ca@simark.ca> X-Fortune: You will be recognized and honored as a community leader. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Simon Marchi [2019-09-24 22:28:46 -0400]: > > That's nice, it would now match the C++ behavior. Please consider adding some NEWS > entries for this (and maybe the previous patch too, or a combined entry for both). Thanks for the review. The only change in the patch below is the addition of a NEWS entry - I guess for Eli to review. Thanks, Andrew --- commit 7b1377da89bf23df400ddf51299c7e0955372607 Author: Andrew Burgess Date: Mon Sep 2 23:31:10 2019 +0100 gdb/fortran: Allow for matching symbols with missing scope This commit allows symbol matching within Fortran code without having to specify all of the symbol's scope. For example, given this Fortran code: module aaa contains subroutine foo print *, "hello." end subroutine foo end module aaa subroutine foo print *, "hello." end subroutine foo program test call foo contains subroutine foo print *, "hello." end subroutine foo subroutine bar use aaa call foo end subroutine bar end program test The user can now do this: (gdb) b foo Breakpoint 1 at 0x4006c2: foo. (3 locations) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x00000000004006c2 in aaa::foo at nest.f90:4 1.2 y 0x0000000000400730 in foo at nest.f90:9 1.3 y 0x00000000004007c3 in test::foo at nest.f90:16 The user asks for a breakpoint on 'foo' and is given a breakpoint on all three possible 'foo' locations. The user is, of course, still able to specify the scope in order to place a single breakpoint on just one of the foo functions (or use 'break -qualified foo' to break on just the global foo). gdb/ChangeLog: * f-lang.c (f_language_defn): Use cp_get_symbol_name_matcher and cp_search_name_hash. * NEWS: Add entry about nested function support. gdb/testsuite/ChangeLog: * gdb.fortran/nested-funcs-2.exp: Run tests with and without the nested function prefix. diff --git a/gdb/NEWS b/gdb/NEWS index 779fd91d3a6..f30024d283d 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -34,6 +34,15 @@ * GDB can now be compiled with Python 3 on Windows. +* GDB can now place breakpoints on nested functions and subroutines in + Fortran code. The '::' operator can be used between parent and + child scopes when placing breakpoints, for example: + + (gdb) break outer_function::inner_function + + The 'outer_function::' prefix is only needed if 'inner_function' is + not visible in the current scope. + * Python API ** The gdb.Value type has a new method 'format_string' which returns a diff --git a/gdb/f-lang.c b/gdb/f-lang.c index ce7f1471c52..5681379b3b3 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -673,9 +673,9 @@ extern const struct language_defn f_language_defn = default_pass_by_reference, default_get_string, c_watch_location_expression, - NULL, /* la_get_symbol_name_matcher */ + cp_get_symbol_name_matcher, /* la_get_symbol_name_matcher */ iterate_over_symbols, - default_search_name_hash, + cp_search_name_hash, &default_varobj_ops, NULL, NULL, diff --git a/gdb/testsuite/gdb.fortran/nested-funcs-2.exp b/gdb/testsuite/gdb.fortran/nested-funcs-2.exp index e23d8bad4b2..9fa04ae9af3 100644 --- a/gdb/testsuite/gdb.fortran/nested-funcs-2.exp +++ b/gdb/testsuite/gdb.fortran/nested-funcs-2.exp @@ -121,12 +121,6 @@ proc do_bp_tests {with_src_prefix_p with_nest_prefix_p} { ".*print \\\*, program_i ! post_hidden" gdb_test "p program_i" " = 30" "printing hidden global" - # Check that the methods in the container module still require the - # module name as context. - gdb_test_no_output "set confirm off" - gdb_test "break print_from_module" \ - "Function \\\"print_from_module\\\" not defined." - # Check info symbol, whatis and ptype can find information on # these nested functions. foreach entry \ @@ -147,10 +141,7 @@ proc do_bp_tests {with_src_prefix_p with_nest_prefix_p} { } foreach_with_prefix src_prefix { 0 1 } { - # For now this loop is only run with a value of '1'. A later - # patch will extend this with the value '0', at which point this - # comment will be removed. - foreach_with_prefix nest_prefix { 1 } { + foreach_with_prefix nest_prefix { 0 1 } { do_bp_tests ${src_prefix} ${nest_prefix} } }