From patchwork Mon Nov 19 21:38:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Wodkowski X-Patchwork-Id: 30208 Received: (qmail 110329 invoked by alias); 19 Nov 2018 21:40:22 -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 110224 invoked by uid 89); 19 Nov 2018 21:40:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, SPF_FAIL autolearn=ham version=3.3.2 spammy= X-HELO: mga07.intel.com Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Nov 2018 21:40:20 +0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 13:40:18 -0800 Received: from kraken.imu.intel.com ([10.217.246.153]) by orsmga004.jf.intel.com with ESMTP; 19 Nov 2018 13:40:16 -0800 From: Pawel Wodkowski To: gdb-patches@sourceware.org, murbanski@pl.sii.eu, sbasierski@pl.sii.eu Cc: tim.wiederhake@intel.com, dragos.carciumaru@intel.com, Bernhard Heckel Subject: [PATCH v2 5/7] Fortran: Enable setting breakpoint on nested functions. Date: Mon, 19 Nov 2018 22:38:48 +0100 Message-Id: <1542663530-140490-5-git-send-email-pwodkowski@pl.sii.eu> In-Reply-To: <1542663530-140490-1-git-send-email-pwodkowski@pl.sii.eu> References: <1542663530-140490-1-git-send-email-pwodkowski@pl.sii.eu> From: Bernhard Heckel Like in Ada, we want to be able to set a breakpoint on nested functions, called "contained routines" in Fortran. 2016-06-30 Bernhard Heckel gdb/Changelog: * dwarf2read.c (add_partial_symbol): store fortran subprograms in global scope. (add_partial_subprogram): Save fortran DW_TAG_subprogram. gdb/Changelog: * gdb.fortran/nested-funcs.exp: Set breakpoint on contained routines. Changes from V1 to V2: Fill commit message gaps. --- gdb/dwarf2read.c | 9 +++++++-- gdb/testsuite/gdb.fortran/nested-funcs.exp | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 88e57d7ab68e..dcf9da8372df 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8910,7 +8910,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) - 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 @@ -9206,6 +9208,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; } } @@ -21543,7 +21547,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK; attr2 = dwarf2_attr (die, DW_AT_external, cu); if ((attr2 && (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 index 2481d256af69..5e28b0e1a3e2 100755 --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp @@ -29,6 +29,9 @@ if ![runto MAIN__] then { perror "couldn't run to breakpoint MAIN__" 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. @@ -43,6 +46,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"]