Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Tim Wiederhake <tim.wiederhake@intel.com>
Cc: gdb-patches@sourceware.org, Bernhard Heckel <bernhard.heckel@intel.com>
Subject: Re: [PATCH v3 6/6] Fortran: Nested functions, add scope parameter.
Date: Mon, 04 Sep 2017 09:58:00 -0000	[thread overview]
Message-ID: <20170904095816.GB8425@1170ee0b50d5> (raw)
In-Reply-To: <1502449611-8865-7-git-send-email-tim.wiederhake@intel.com>

On 17-08-11 13:06:51, Tim Wiederhake wrote:
> From: Bernhard Heckel <bernhard.heckel@intel.com>
> 
> In order to avoid name clashing in GDB, we add a scope
> to nested subroutines. Enveloping function gives the
> scope.

Hi Tim,
Is there any reason that you split it from patch #5?  IMO, both #5 and
#6 should be a single patch, and we need a NEWS entry.

According to your patch #5, I think both Ada and Fortran have the similar
feature here.  I think we need to keep semantics same in both languages,
like, "break func::nest_func"?

> 
> ---
>  gdb/doc/gdb.texinfo                        |  3 ++
>  gdb/dwarf2read.c                           | 26 +++++++++++-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp | 28 +++++++++++--
>  gdb/testsuite/gdb.fortran/nested-funcs.f90 | 66 ++++++++++++++++++++++++++++--
>  4 files changed, 114 insertions(+), 9 deletions(-)
>  mode change 100755 => 100644 gdb/testsuite/gdb.fortran/nested-funcs.f90
> 
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index d098eba..983a570 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -15259,6 +15259,9 @@ The access component operator.  Normally used to access elements in derived
>  types.  Also suitable for unions.  As unions aren't part of regular Fortran,
>  this can only happen when accessing a register that uses a gdbarch-defined
>  union type.
> +@item ::
> +The scope operator.  Normally used to access variables in modules or to set
> +breakpoints on subroutines nested in modules or in other (internal) subroutines.
>  @end table
>  
>  @node Fortran Defaults
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 894e6a0..92a9c49 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -7042,6 +7042,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
>        return NULL;
>      }
>  
> +  /* Internal (nested) subroutines in Fortran get a prefix.  */
>    if (pdi->tag == DW_TAG_enumerator)
>      /* Enumerators should not get the name of the enumeration as a prefix.  */
>      parent->scope = grandparent_scope;
> @@ -7051,7 +7052,10 @@ partial_die_parent_scope (struct partial_die_info *pdi,
>        || parent->tag == DW_TAG_class_type
>        || parent->tag == DW_TAG_interface_type
>        || parent->tag == DW_TAG_union_type
> -      || parent->tag == DW_TAG_enumeration_type)
> +      || parent->tag == DW_TAG_enumeration_type
> +      || (cu->language == language_fortran
> +	  && parent->tag == DW_TAG_subprogram
> +	  && pdi->tag == DW_TAG_subprogram))
>      {
>        if (grandparent_scope == NULL)
>  	parent->scope = parent->name;
> @@ -8560,8 +8564,13 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
>      case DW_TAG_type_unit:
>        read_type_unit_scope (die, cu);
>        break;
> -    case DW_TAG_entry_point:
>      case DW_TAG_subprogram:
> +      /* Internal subprograms in Fortran get a prefix.  */
> +      if (cu->language == language_fortran
> +	  && die->parent != NULL
> +	  && die->parent->tag == DW_TAG_subprogram)
> +      cu->processing_has_namespace_info = 1;

We need some fall-through annotation to suppress warning in GCC 7.

> +    case DW_TAG_entry_point:
>      case DW_TAG_inlined_subroutine:
>        read_func_scope (die, cu);
>        break;
> @@ -20169,6 +20178,19 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
>  	      return TYPE_TAG_NAME (parent_type);
>  	    return "";
>  	  }
> +      case DW_TAG_subprogram:
> +	/* Only internal subroutines in Fortran get a prefix with the name
> +	   of the parent's subroutine.  */
> +	if (cu->language == language_fortran)
> +	  {
> +	    if ((die->tag ==  DW_TAG_subprogram)
> +		&& (dwarf2_name (parent, cu) != NULL))
> +	      return dwarf2_name (parent, cu);
> +	    else
> +	      return "";
> +	  }
> +	else
> +	  return determine_prefix (parent, cu);
>  	/* Fall through.  */
>        default:
>  	return determine_prefix (parent, cu);
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index 4c2ee2a..0c8a416 100644
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -31,8 +31,8 @@ if ![runto MAIN__] then {
>  }
>  
>  # 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"
> +gdb_breakpoint "testnestedfuncs::sub_nested_outer"
> +gdb_continue_to_breakpoint "testnestedfuncs::sub_nested_outer" ".*local_int = 19"
>  
>  # Test if we can access local and
>  # non-local variables defined one level up.
> @@ -43,13 +43,16 @@ gdb_test "set index = 42"
>  gdb_test "print index" "= 42" "print index at BP_outer, manipulated"
>  gdb_test "print local_int" "= 19" "print local_int in outer function"
>  
> +

Unnecessary change, multiple instances.

>  # Non-local variable should be affected in one frame up as well.
>  gdb_test "up"


-- 
Yao (齐尧)


  reply	other threads:[~2017-09-04  9:58 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 1/6] DWARF: Don't add nameless modules to partial symbol table Tim Wiederhake
2017-08-11 11:07 ` [PATCH v3 5/6] Fortran: Enable setting breakpoint on nested functions Tim Wiederhake
2017-09-04  9:22   ` Yao Qi
2017-08-11 11:07 ` [PATCH v3 6/6] Fortran: Nested functions, add scope parameter Tim Wiederhake
2017-09-04  9:58   ` Yao Qi [this message]
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

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=20170904095816.GB8425@1170ee0b50d5 \
    --to=qiyaoltc@gmail.com \
    --cc=bernhard.heckel@intel.com \
    --cc=gdb-patches@sourceware.org \
    --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