public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/mi: Fix printing of fortran strings in stack
@ 2023-05-10 10:20 Richard Bunt
  2023-05-10 13:13 ` Andrew Burgess
  2023-05-10 14:52 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Richard Bunt @ 2023-05-10 10:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Richard Bunt, Josh Cottingham

547ce8f00b4ef826bdc9bf9a74f119fe9768852e fixed an issue where dynamic
types were not being resolved correctly prior to printing a value. The
same issue was discovered when printing the value using MI-mode. Solved
by porting the fix to the MI mode code path.

GDB built with GCC 13.

No test suite regressions detected. Compilers: GCC 12.1.0, ACfL 22.1,
Intel 22.1; Platforms: x86_64, aarch64.

Co-Authored-By: Josh Cottingham <josh.cottingham@arm.com>

---
 gdb/mi/mi-cmd-stack.c                          |  3 +++
 gdb/testsuite/gdb.fortran/mixed-lang-stack.exp | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 0172bf9814d..70762880c49 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -590,6 +590,9 @@ list_args_or_locals (const frame_print_options &fp_opts,
 
   ui_out_emit_list list_emitter (uiout, name_of_result);
 
+  scoped_restore_selected_frame restore_selected_frame;
+  select_frame (fi);
+
   while (block != 0)
     {
       for (struct symbol *sym : block_iterator_range (block))
diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
index 6ab3f8adeba..5fc36f7b95b 100644
--- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
+++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
@@ -92,6 +92,18 @@ proc run_tests { lang } {
 	    }
 	}
 
+	# Check backtrace arguments in MI mode.
+	set mi_a "\{name=\"a\",value=\"1\"\}"
+	set mi_b "\{name=\"b\",value=\"2\"\}"
+	set mi_c "\{name=\"c\",value=\"3\"\}"
+	set mi_d "\{name=\"d\",value=\"\\(4,5\\)\"\}"
+	set mi_e "\{name=\"e\",value=\"$e_arg\"\}"
+	set mi_g "\{name=\"g\",value=\"\\( a = 1.5, b = 2.5 \\)\"\}"
+	# Hidden argument name changes depending on compiler.
+	set mi_hidden "\{name=\"\[^\r\n\]+\",value=\"6\"\}"
+	gdb_test "interpreter-exec mi '-stack-list-arguments --no-frame-filters --all-values 7 7'" \
+		 "\\^done,stack-args=\\\[frame=\{level=\"7\",args=\\\[$mi_a,$mi_b,$mi_c,$mi_d,$mi_e,$mi_g,$mi_hidden\\\]\}\\\]"
+
 	# Check the language for frame #0.
 	gdb_test "info frame" "source language fortran\..*" \
 	    "info frame in frame #0"
-- 
2.32.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/mi: Fix printing of fortran strings in stack
  2023-05-10 10:20 [PATCH] gdb/mi: Fix printing of fortran strings in stack Richard Bunt
@ 2023-05-10 13:13 ` Andrew Burgess
  2023-05-10 14:52 ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Burgess @ 2023-05-10 13:13 UTC (permalink / raw)
  To: Richard Bunt via Gdb-patches, gdb-patches; +Cc: Richard Bunt, Josh Cottingham

Richard Bunt via Gdb-patches <gdb-patches@sourceware.org> writes:

> 547ce8f00b4ef826bdc9bf9a74f119fe9768852e fixed an issue where dynamic
> types were not being resolved correctly prior to printing a value. The
> same issue was discovered when printing the value using MI-mode. Solved
> by porting the fix to the MI mode code path.
>
> GDB built with GCC 13.
>
> No test suite regressions detected. Compilers: GCC 12.1.0, ACfL 22.1,
> Intel 22.1; Platforms: x86_64, aarch64.
>
> Co-Authored-By: Josh Cottingham <josh.cottingham@arm.com>

Thanks for fixing this.  Looks good to me.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> ---
>  gdb/mi/mi-cmd-stack.c                          |  3 +++
>  gdb/testsuite/gdb.fortran/mixed-lang-stack.exp | 12 ++++++++++++
>  2 files changed, 15 insertions(+)
>
> diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
> index 0172bf9814d..70762880c49 100644
> --- a/gdb/mi/mi-cmd-stack.c
> +++ b/gdb/mi/mi-cmd-stack.c
> @@ -590,6 +590,9 @@ list_args_or_locals (const frame_print_options &fp_opts,
>  
>    ui_out_emit_list list_emitter (uiout, name_of_result);
>  
> +  scoped_restore_selected_frame restore_selected_frame;
> +  select_frame (fi);
> +
>    while (block != 0)
>      {
>        for (struct symbol *sym : block_iterator_range (block))
> diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
> index 6ab3f8adeba..5fc36f7b95b 100644
> --- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
> +++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
> @@ -92,6 +92,18 @@ proc run_tests { lang } {
>  	    }
>  	}
>  
> +	# Check backtrace arguments in MI mode.
> +	set mi_a "\{name=\"a\",value=\"1\"\}"
> +	set mi_b "\{name=\"b\",value=\"2\"\}"
> +	set mi_c "\{name=\"c\",value=\"3\"\}"
> +	set mi_d "\{name=\"d\",value=\"\\(4,5\\)\"\}"
> +	set mi_e "\{name=\"e\",value=\"$e_arg\"\}"
> +	set mi_g "\{name=\"g\",value=\"\\( a = 1.5, b = 2.5 \\)\"\}"
> +	# Hidden argument name changes depending on compiler.
> +	set mi_hidden "\{name=\"\[^\r\n\]+\",value=\"6\"\}"
> +	gdb_test "interpreter-exec mi '-stack-list-arguments --no-frame-filters --all-values 7 7'" \
> +		 "\\^done,stack-args=\\\[frame=\{level=\"7\",args=\\\[$mi_a,$mi_b,$mi_c,$mi_d,$mi_e,$mi_g,$mi_hidden\\\]\}\\\]"
> +
>  	# Check the language for frame #0.
>  	gdb_test "info frame" "source language fortran\..*" \
>  	    "info frame in frame #0"
> -- 
> 2.32.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/mi: Fix printing of fortran strings in stack
  2023-05-10 10:20 [PATCH] gdb/mi: Fix printing of fortran strings in stack Richard Bunt
  2023-05-10 13:13 ` Andrew Burgess
@ 2023-05-10 14:52 ` Tom Tromey
  2023-05-10 16:36   ` Richard Bunt
  1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2023-05-10 14:52 UTC (permalink / raw)
  To: Richard Bunt via Gdb-patches; +Cc: Richard Bunt, Josh Cottingham

>>>>> "Richard" == Richard Bunt via Gdb-patches <gdb-patches@sourceware.org> writes:

Richard> 547ce8f00b4ef826bdc9bf9a74f119fe9768852e fixed an issue where dynamic
Richard> types were not being resolved correctly prior to printing a value. The
Richard> same issue was discovered when printing the value using MI-mode. Solved
Richard> by porting the fix to the MI mode code path.

I wonder if this can be fixed more directly after
2fc3b8a4cb8439fc53975c4e70336d76e3ddc531 and its predecessors.
(Not that there's anything wrong with this patch.)

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/mi: Fix printing of fortran strings in stack
  2023-05-10 14:52 ` Tom Tromey
@ 2023-05-10 16:36   ` Richard Bunt
  2023-05-12 18:38     ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Bunt @ 2023-05-10 16:36 UTC (permalink / raw)
  To: Tom Tromey, Richard Bunt via Gdb-patches; +Cc: Josh Cottingham



On 10/05/2023 15:52, Tom Tromey wrote:
>>>>>> "Richard" == Richard Bunt via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Richard> 547ce8f00b4ef826bdc9bf9a74f119fe9768852e fixed an issue where dynamic
> Richard> types were not being resolved correctly prior to printing a value. The
> Richard> same issue was discovered when printing the value using MI-mode. Solved
> Richard> by porting the fix to the MI mode code path.
> 

Hi Tom,

Thanks for pointing me in the direction of that patch set.

> I wonder if this can be fixed more directly after
> 2fc3b8a4cb8439fc53975c4e70336d76e3ddc531 and its predecessors.
> (Not that there's anything wrong with this patch.)
> 
> Tom

Even better than that, it fixes the issue I was seeing. I mistakenly 
thought I was sufficiently in a corner that I'd not need to retest for 
the failure after rebasing.

If it is OK, I'd like to propose the test case for upstream as I believe 
it covers a legitimate gap, even if there is no known bug here.

Many thanks,

Rich.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/mi: Fix printing of fortran strings in stack
  2023-05-10 16:36   ` Richard Bunt
@ 2023-05-12 18:38     ` Tom Tromey
  2023-05-16 16:24       ` Richard Bunt
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2023-05-12 18:38 UTC (permalink / raw)
  To: Richard Bunt via Gdb-patches; +Cc: Tom Tromey, Richard Bunt, Josh Cottingham

>>>>> "Richard" == Richard Bunt via Gdb-patches <gdb-patches@sourceware.org> writes:

>> I wonder if this can be fixed more directly after
>> 2fc3b8a4cb8439fc53975c4e70336d76e3ddc531 and its predecessors.
>> (Not that there's anything wrong with this patch.)
>> Tom

Richard> Even better than that, it fixes the issue I was seeing.

Nice.  I wonder if we can remove the old fix then.

Richard> If it is OK, I'd like to propose the test case for upstream as I
Richard> believe it covers a legitimate gap, even if there is no known bug
Richard> here.

Yes, that would be great.  Thank you.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/mi: Fix printing of fortran strings in stack
  2023-05-12 18:38     ` Tom Tromey
@ 2023-05-16 16:24       ` Richard Bunt
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Bunt @ 2023-05-16 16:24 UTC (permalink / raw)
  To: Tom Tromey, Richard Bunt via Gdb-patches



On 12/05/2023 19:38, Tom Tromey wrote:
>>>>>> "Richard" == Richard Bunt via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
>>> I wonder if this can be fixed more directly after
>>> 2fc3b8a4cb8439fc53975c4e70336d76e3ddc531 and its predecessors.
>>> (Not that there's anything wrong with this patch.)
>>> Tom
> 
> Richard> Even better than that, it fixes the issue I was seeing.
> 
> Nice.  I wonder if we can remove the old fix then.

I have confirmed that the fix applied to the cli-mode code path can be
removed.

I'll prepare a v2.

> 
> Richard> If it is OK, I'd like to propose the test case for upstream as I
> Richard> believe it covers a legitimate gap, even if there is no known bug
> Richard> here.
> 
> Yes, that would be great.  Thank you.
> 
> Tom

Thanks,

Rich.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-16 16:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-10 10:20 [PATCH] gdb/mi: Fix printing of fortran strings in stack Richard Bunt
2023-05-10 13:13 ` Andrew Burgess
2023-05-10 14:52 ` Tom Tromey
2023-05-10 16:36   ` Richard Bunt
2023-05-12 18:38     ` Tom Tromey
2023-05-16 16:24       ` Richard Bunt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).