Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/backtrace] Fix printing of fortran string args
Date: Sat, 15 Aug 2020 09:16:02 +0100	[thread overview]
Message-ID: <20200815081602.GG853475@embecosm.com> (raw)
In-Reply-To: <20200815055446.GA6668@delia>

* Tom de Vries <tdevries@suse.de> [2020-08-15 07:54:48 +0200]:

> Hi,
> 
> When running test-case gdb.fortran/mixed-lang-stack.exp, it passes, but we
> find in gdb.log:
> ...
>  (gdb) bt^M
>    ...
>  #7  0x000000000040113c in mixed_func_1b (a=1, b=2, c=3, d=(4,5), \
>    e=<error reading variable: value requires 140737488341744 bytes, which \
>    is more than max-value-size>, g=..., _e=6) at mixed-lang-stack.f90:87^M
> ...
> while a bit later in gdb.log, we have instead for the same frame (after
> adding a gdb_test_no_output "set print frame-arguments all" to prevent
> getting "e=..."):
> ...
>  (gdb) up^M
>  #7  0x000000000040113c in mixed_func_1b (a=1, b=2, c=3, d=(4,5), \
>    e='abcdef', g=( a = 1.5, b = 2.5 ), _e=6) at mixed-lang-stack.f90:87^M
> ...
> 
> The difference is that in the latter case, we print the frame while it's
> selected, while in the former, it's not.
> 
> The problem is that the while trying to resolve the dynamic type of e in
> resolve_dynamic_type, we call dwarf2_evaluate_property with a frame == NULL
> argument, and then use the selected frame as the context in which to evaluate
> the dwarf property, effectively evaluating a DW_OP_fbreg operation in the
> wrong frame context.
> 
> Fix this by temporarily selecting the frame of which we're trying to print the
> arguments in print_frame_args, borrowing code from print_frame_local_vars that
> was added to fix a similar issue in commit 16c3b12f19 "error/internal-error
> printing local variable during "bt full".
> 
> Build and tested on x86_64-linux.
> 
> Any comments?
> 
> Thanks,
> - Tom
> 
> [gdb/backtrace] Fix printing of fortran string args
> 
> gdb/ChangeLog:
> 
> 2020-08-14  Tom de Vries  <tdevries@suse.de>
> 
> 	PR backtrace/26390
> 	* stack.c (print_frame_args): Temporarily set the selected
> 	frame to FRAME while printing the frame's arguments.
> 
> gdb/testsuite/ChangeLog:
> 
> 2020-08-14  Tom de Vries  <tdevries@suse.de>
> 
> 	PR backtrace/26390
> 	* gdb.fortran/mixed-lang-stack.exp: Call bt with -frame-arguments all.
> 	Update expected pattern.

LGTM.

Thanks,
Andrew

> 
> ---
>  gdb/stack.c                                    |  6 ++++++
>  gdb/testsuite/gdb.fortran/mixed-lang-stack.exp | 30 +++++++++++++++-----------
>  2 files changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/gdb/stack.c b/gdb/stack.c
> index 265e764dc2..616b629e20 100644
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
> @@ -744,6 +744,12 @@ print_frame_args (const frame_print_options &fp_opts,
>      = (print_names
>         && fp_opts.print_frame_arguments != print_frame_arguments_none);
>  
> +  /* Temporarily change the selected frame to the given FRAME.
> +     This allows routines that rely on the selected frame instead
> +     of being given a frame as parameter to use the correct frame.  */
> +  scoped_restore_selected_frame restore_selected_frame;
> +  select_frame (frame);
> +
>    if (func)
>      {
>        const struct block *b = SYMBOL_BLOCK_VALUE (func);
> diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
> index 793318626d..edf2508537 100644
> --- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
> +++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
> @@ -59,19 +59,23 @@ proc run_tests { lang } {
>  	}
>  
>  	# Check the backtrace.
> -	set bt_stack [multi_line \
> -			  "#0\\s+breakpt \\(\\) at \[^\r\n\]+" \
> -			  "#1\\s+$hex in mixed_func_1h \\(\\) at \[^\r\n\]+" \
> -			  "#2\\s+$hex in mixed_func_1g \\(obj=\\.\\.\\.\\) at \[^\r\n\]+" \
> -			  "#3\\s+$hex in mixed_func_1f \\(\\) at \[^\r\n\]+" \
> -			  "#4\\s+$hex in mixed_func_1e \\(\\) at \[^\r\n\]+" \
> -			  "#5\\s+$hex in mixed_func_1d \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
> -			  "#6\\s+$hex in mixed_func_1c \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
> -			  "#7\\s+$hex in mixed_func_1b \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
> -			  "#8\\s+$hex in mixed_func_1a \\(\\) at \[^\r\n\]+" \
> -			  "#9\\s+$hex in mixed_stack_main \\(\\) at \[^\r\n\]+" \
> -			  "#10\\s+$hex in main \\(\[^\r\n\]+\\) at .*" ]
> -	gdb_test "bt" $bt_stack
> +	set e_arg "\['\"\]abcdef\['\"\]"
> +	set 1b_args "\[^\r\n\]+$e_arg\[^\r\n\]+"
> +	set 1g_args "obj=\[^\r\n\]+"
> +	set bt_stack \
> +	    [multi_line \
> +		 "#0\\s+breakpt \\(\\) at \[^\r\n\]+" \
> +		 "#1\\s+$hex in mixed_func_1h \\(\\) at \[^\r\n\]+" \
> +		 "#2\\s+$hex in mixed_func_1g \\($1g_args\\) at \[^\r\n\]+" \
> +		 "#3\\s+$hex in mixed_func_1f \\(\\) at \[^\r\n\]+" \
> +		 "#4\\s+$hex in mixed_func_1e \\(\\) at \[^\r\n\]+" \
> +		 "#5\\s+$hex in mixed_func_1d \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
> +		 "#6\\s+$hex in mixed_func_1c \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
> +		 "#7\\s+$hex in mixed_func_1b \\($1b_args\\) at \[^\r\n\]+" \
> +		 "#8\\s+$hex in mixed_func_1a \\(\\) at \[^\r\n\]+" \
> +		 "#9\\s+$hex in mixed_stack_main \\(\\) at \[^\r\n\]+" \
> +		 "#10\\s+$hex in main \\(\[^\r\n\]+\\) at .*" ]
> +	gdb_test "bt -frame-arguments all" $bt_stack
>  
>  	# Check the language for frame #0.
>  	gdb_test "info frame" "source language fortran\..*" \


      reply	other threads:[~2020-08-15  8:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-15  5:54 Tom de Vries
2020-08-15  8:16 ` Andrew Burgess [this message]

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=20200815081602.GG853475@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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