From patchwork Fri Aug 11 11:06:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wiederhake, Tim" X-Patchwork-Id: 22075 Received: (qmail 70688 invoked by alias); 11 Aug 2017 11:07:32 -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 70512 invoked by uid 89); 11 Aug 2017 11:07:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Aug 2017 11:07:28 +0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Aug 2017 04:07:24 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga004.jf.intel.com with ESMTP; 11 Aug 2017 04:07:22 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id v7BB7LuD007192; Fri, 11 Aug 2017 12:07:21 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id v7BB7Fbk009152; Fri, 11 Aug 2017 13:07:15 +0200 Received: (from twiederh@localhost) by ulvlx001.iul.intel.com with LOCAL id v7BB7F4N009148; Fri, 11 Aug 2017 13:07:15 +0200 From: Tim Wiederhake To: gdb-patches@sourceware.org Cc: qiyaoltc@gmail.com, Bernhard Heckel Subject: [PATCH v3 5/6] Fortran: Enable setting breakpoint on nested functions. Date: Fri, 11 Aug 2017 13:06:50 +0200 Message-Id: <1502449611-8865-6-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1502449611-8865-1-git-send-email-tim.wiederhake@intel.com> References: <1502449611-8865-1-git-send-email-tim.wiederhake@intel.com> X-IsSubscribed: yes From: Bernhard Heckel Like in Ada, we want to be able to set a breakpoint on nested functions, called "contained routines" in Fortran. xxxx-yy-zz Bernhard Heckel gdb/ChangeLog: * dwarf2read.c (add_partial_symbol): Enable for Fortran as well. (new_symbol_full): Same. (add_partial_subprogram): Check for subprogram tag. gdb/testsuite/ChangeLog: * gdb.fortran/nested-funcs.exp: Set breakpoint on contained routines. --- gdb/dwarf2read.c | 9 +++++++-- gdb/testsuite/gdb.fortran/nested-funcs.exp | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) mode change 100755 => 100644 gdb/testsuite/gdb.fortran/nested-funcs.exp diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0349db0..894e6a0 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -7159,7 +7159,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) } case DW_TAG_subprogram: addr = gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr); - if (pdi->is_external || cu->language == language_ada) + if (pdi->is_external + || cu->language == language_ada + || cu->language == language_fortran) { /* brobecker/2007-12-26: Normally, only "external" DIEs are part of the global scope. But in Ada, we want to be able to access @@ -7447,6 +7449,8 @@ add_partial_subprogram (struct partial_die_info *pdi, { if (pdi->tag == DW_TAG_entry_point) add_partial_entry_point (pdi, lowpc, highpc, set_addrmap, cu); + else if (pdi->tag == DW_TAG_subprogram) + add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu); pdi = pdi->die_sibling; } } @@ -19155,7 +19159,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, attr2 = dwarf2_attr (die->tag == DW_TAG_entry_point ? die->parent : die, DW_AT_external, cu); if ((attr2 != NULL && (DW_UNSND (attr2) != 0)) - || cu->language == language_ada) + || cu->language == language_ada + || cu->language == language_fortran) { /* Subprograms marked external are stored as a global symbol. Ada subprograms, whether marked external or not, are always diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp old mode 100755 new mode 100644 index f6a5335..4c2ee2a --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp @@ -30,6 +30,10 @@ if ![runto MAIN__] then { continue } +# Test if we can set a breakpoint in a nested function +gdb_breakpoint "sub_nested_outer" +gdb_continue_to_breakpoint "sub_nested_outer" ".*local_int = 19" + # Test if we can access local and # non-local variables defined one level up. gdb_breakpoint [gdb_get_line_number "! BP_outer"] @@ -43,6 +47,10 @@ gdb_test "print local_int" "= 19" "print local_int in outer function" gdb_test "up" gdb_test "print index" "= 42" "print index at BP1, one frame up" +# Test if we can set a breakpoint in a nested function +gdb_breakpoint "sub_nested_inner" +gdb_continue_to_breakpoint "sub_nested_inner" ".*local_int = 17" + # Test if we can access local and # non-local variables defined two level up. gdb_breakpoint [gdb_get_line_number "! BP_inner"]