public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Richard Bunt <richard.bunt@linaro.org>
To: gdb-patches@sourceware.org
Cc: Richard Bunt <richard.bunt@linaro.org>,
	Josh Cottingham <josh.cottingham@arm.com>
Subject: [PATCH] gdb/mi: Fix printing of fortran strings in stack
Date: Wed, 10 May 2023 11:20:31 +0100	[thread overview]
Message-ID: <20230510102031.2125810-1-richard.bunt@linaro.org> (raw)

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


             reply	other threads:[~2023-05-10 10:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10 10:20 Richard Bunt [this message]
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

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=20230510102031.2125810-1-richard.bunt@linaro.org \
    --to=richard.bunt@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=josh.cottingham@arm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).