Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pawel Wodkowski <pwodkowski@pl.sii.eu>
To: gdb-patches@sourceware.org,	murbanski@pl.sii.eu,	sbasierski@pl.sii.eu
Cc: tim.wiederhake@intel.com,	dragos.carciumaru@intel.com,
	Bernhard Heckel <bernhard.heckel@intel.com>
Subject: [PATCH 5/7] Fortran: Enable setting breakpoint on nested functions.
Date: Fri, 16 Nov 2018 13:11:00 -0000	[thread overview]
Message-ID: <1542373804-76019-5-git-send-email-pwodkowski@pl.sii.eu> (raw)
In-Reply-To: <1542373804-76019-1-git-send-email-pwodkowski@pl.sii.eu>

From: Bernhard Heckel <bernhard.heckel@intel.com>

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  <bernhard.heckel@intel.com>

gdb/Changelog:
	* dwarf2read.c (todo)

gdb/Changelog:
	* gdb.fortran/nested-funcs.exp: Set breakpoint on contained routines.
---
 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"]
-- 
2.7.4


  parent reply	other threads:[~2018-11-16 13:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 13:11 [PATCH 1/7] DWARF: Don't add nameless modules to partial symbol table Pawel Wodkowski
2018-11-16 13:11 ` [PATCH 2/7] Dwarf: Fortran, support DW_TAG_entry_point Pawel Wodkowski
2018-11-16 13:11 ` [PATCH 7/7] Fortran: Document scope operator Pawel Wodkowski
2018-11-16 14:50   ` Eli Zaretskii
2018-11-16 13:11 ` [PATCH 3/7] Fortran: Accessing fields of inherited types via fully qualified name Pawel Wodkowski
2018-11-16 13:11 ` [PATCH 6/7] Fortran: Nested functions, add scope parameter Pawel Wodkowski
2018-11-16 13:11 ` Pawel Wodkowski [this message]
2018-11-16 13:11 ` [PATCH 4/7] Fortran: Ptype, print type extension Pawel Wodkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542373804-76019-5-git-send-email-pwodkowski@pl.sii.eu \
    --to=pwodkowski@pl.sii.eu \
    --cc=bernhard.heckel@intel.com \
    --cc=dragos.carciumaru@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=murbanski@pl.sii.eu \
    --cc=sbasierski@pl.sii.eu \
    --cc=tim.wiederhake@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox