Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tim Wiederhake <tim.wiederhake@intel.com>
To: gdb-patches@sourceware.org
Cc: qiyaoltc@gmail.com, Bernhard Heckel <bernhard.heckel@intel.com>
Subject: [PATCH v3 5/6] Fortran: Enable setting breakpoint on nested functions.
Date: Fri, 11 Aug 2017 11:07:00 -0000	[thread overview]
Message-ID: <1502449611-8865-6-git-send-email-tim.wiederhake@intel.com> (raw)
In-Reply-To: <1502449611-8865-1-git-send-email-tim.wiederhake@intel.com>

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.

xxxx-yy-zz  Bernhard Heckel  <bernhard.heckel@intel.com>

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"]
-- 
2.7.4


  parent reply	other threads:[~2017-08-11 11:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 11:07 [PATCH v3 0/6] Some Fortran Patches Tim Wiederhake
2017-08-11 11:07 ` [PATCH v3 6/6] Fortran: Nested functions, add scope parameter Tim Wiederhake
2017-09-04  9:58   ` Yao Qi
2017-09-08 12:13     ` Wiederhake, Tim
2017-08-11 11:07 ` [PATCH v3 3/6] Fortran: Ptype, print type extension Tim Wiederhake
2017-08-23 11:05   ` Yao Qi
2017-08-24 12:36     ` Wiederhake, Tim
2017-08-11 11:07 ` [PATCH v3 4/6] Dwarf: Fortran, support DW_TAG_entry_point Tim Wiederhake
2017-09-04  8:37   ` Yao Qi
2017-08-11 11:07 ` [PATCH v3 2/6] Fortran: Accessing fields of inherited types via fully qualified name Tim Wiederhake
2017-08-11 11:07 ` [PATCH v3 1/6] DWARF: Don't add nameless modules to partial symbol table Tim Wiederhake
2017-08-11 11:07 ` Tim Wiederhake [this message]
2017-09-04  9:22   ` [PATCH v3 5/6] Fortran: Enable setting breakpoint on nested functions Yao Qi

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=1502449611-8865-6-git-send-email-tim.wiederhake@intel.com \
    --to=tim.wiederhake@intel.com \
    --cc=bernhard.heckel@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.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