[PATCH 1/2] gdb: Improve formatting of 'show architecture' messages

Andrew Burgess
2020-07-08T08:55:01Z

This commit changes the output of 'show architecture'. Here is a
session before this commit:

(gdb) show architecture
The target architecture is set automatically (currently i386)
(gdb) set architecture mips
The target architecture is assumed to be mips
(gdb) show architecture
The target architecture is assumed to be mips
(gdb)

After this commit the session now looks like this:

(gdb) show architecture
The target architecture is set to "auto" (currently i386).
(gdb) set architecture mips
The target architecture is set to "mips".
(gdb) show architecture
The target architecture is set to "mips".
(gdb)

The changes are:

1. The value is now enclosed in quotes,
2. Each line ends with '.', and
3. After setting the architecture GDB is now a little more
assertive; 'architecture is set to' not 'is assumed to be', the user
did just tell us after all!

gdb/ChangeLog:

* arch-utils.c (show_architecture): Update formatting of messages.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-osabi.exp: Update.
* gdb.base/all-architectures.exp.tcl: Update.
* gdb.base/attach-pie-noexec.exp: Update.
* gdb.base/catch-syscall.exp: Update.
* gdb.xml/tdesc-arch.exp: Update.
---
gdb/ChangeLog | 4 ++++
gdb/arch-utils.c | 6 +++---
gdb/testsuite/ChangeLog | 8 ++++++++
gdb/testsuite/gdb.arch/amd64-osabi.exp | 2 +-
gdb/testsuite/gdb.base/all-architectures.exp.tcl | 2 +-
gdb/testsuite/gdb.base/attach-pie-noexec.exp | 4 ++--
gdb/testsuite/gdb.base/catch-syscall.exp | 4 ++--
gdb/testsuite/gdb.xml/tdesc-arch.exp | 6 +++---
8 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 04955ea847b..a19fc026623 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -476,11 +476,11 @@ show_architecture (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
if (target_architecture_user == NULL)
- fprintf_filtered (file, _("The target architecture is set "
- "automatically (currently %s)\n"),
+ fprintf_filtered (file, _("The target architecture is set to "
+ "\"auto\" (currently %s).\n"),
gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
else
- fprintf_filtered (file, _("The target architecture is assumed to be %s\n"),
+ fprintf_filtered (file, _("The target architecture is set to \"%s\".\n"),
set_architecture_string);
}

diff --git a/gdb/testsuite/gdb.arch/amd64-osabi.exp b/gdb/testsuite/gdb.arch/amd64-osabi.exp
index aebaaffeeae..7702af99bc8 100644
--- a/gdb/testsuite/gdb.arch/amd64-osabi.exp
+++ b/gdb/testsuite/gdb.arch/amd64-osabi.exp
@@ -24,7 +24,7 @@ if { ![istarget x86_64-*-* ] } {
proc test_osabi_none { arch void_ptr_size long_double_size } {
clean_restart

- gdb_test "set architecture i386:x86-64" "The target architecture is assumed to be i386:x86-64"
+ gdb_test "set architecture i386:x86-64" "The target architecture is set to \"i386:x86-64\"\\."
gdb_test_no_output "set osabi none" "set osabi none"
gdb_test "print sizeof (void*)" " = 8"
gdb_test "print sizeof (long double)" " = 16"
diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.tcl b/gdb/testsuite/gdb.base/all-architectures.exp.tcl
index ebdd3444540..4c59728b8c0 100644
--- a/gdb/testsuite/gdb.base/all-architectures.exp.tcl
+++ b/gdb/testsuite/gdb.base/all-architectures.exp.tcl
@@ -246,7 +246,7 @@ with_test_prefix "tests" {
set arch_re [string_to_regexp $arch]
set test "set architecture $arch"
gdb_test_multiple $test $test {
- -re "^set architecture $arch_re\r\n(${osabi_warning})?The target architecture is assumed to be $arch_re\r\n$gdb_prompt $" {
+ -re "^set architecture $arch_re\r\n(${osabi_warning})?The target architecture is set to \"$arch_re\"\\.\r\n$gdb_prompt $" {
internal_pass $test
}
-re "Architecture .* not recognized.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
index 08573a1c21f..f0d1aab101d 100644
--- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp
+++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
@@ -28,7 +28,7 @@ clean_restart $executable
set arch ""
set test "show architecture"
gdb_test_multiple $test $test {
- -re "The target architecture is set automatically \\(currently (.*)\\)\r\n$gdb_prompt $" {
+ -re "The target architecture is set to \"auto\" \\(currently (.*)\\)\\.\r\n$gdb_prompt $" {
set arch $expect_out(1,string)
pass $test
}
@@ -61,7 +61,7 @@ set testpid [spawn_id_get_pid $test_spawn_id]
gdb_start
file delete -- $binfile
gdb_test "attach $testpid" "Attaching to process $testpid\r\n.*" "attach"
-gdb_test "set architecture $arch" "The target architecture is assumed to be $arch"
+gdb_test "set architecture $arch" "The target architecture is set to \"$arch\"\\."
gdb_test "info shared" "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*"

kill_wait_spawned_process $test_spawn_id
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index d5f5862c5c1..eb4fdb5e7c1 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -593,14 +593,14 @@ proc test_catch_syscall_multi_arch {} {
gdb_start

gdb_test "set architecture $arch1" \
- "The target architecture is assumed to be $arch1"
+ "The target architecture is set to \"$arch1\"\\."

gdb_test "catch syscall $syscall_number" \
"Catchpoint $decimal \\(syscall .${syscall1_name}. \\\[${syscall_number}\\\]\\)" \
"insert catch syscall on syscall $syscall_number -- $syscall1_name on $arch1"

gdb_test "set architecture $arch2" \
- "The target architecture is assumed to be $arch2"
+ "The target architecture is set to \"$arch2\"\\."

gdb_test "catch syscall $syscall_number" \
"Catchpoint $decimal \\(syscall .${syscall2_name}. \\\[${syscall_number}\\\]\\)" \
diff --git a/gdb/testsuite/gdb.xml/tdesc-arch.exp b/gdb/testsuite/gdb.xml/tdesc-arch.exp
index 386435dd171..144ff8b2672 100644
--- a/gdb/testsuite/gdb.xml/tdesc-arch.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-arch.exp
@@ -41,7 +41,7 @@ gdb_test_multiple "set architecture" $msg {
set default_arch ""
set msg "read default architecture"
gdb_test_multiple "show architecture" $msg {
- -re "The target architecture is set automatically \\(currently (\[^ \]*)\\)\r\n$gdb_prompt $" {
+ -re "The target architecture is set to \"auto\" \\(currently (\[^ \]*)\\)\\.\r\n$gdb_prompt $" {
set default_arch $expect_out(1,string)
pass $msg
}
@@ -89,7 +89,7 @@ proc set_arch { arch which trans_mode } {

set cmd "show architecture"
gdb_test $cmd \
- "The target architecture is set automatically \\(currently $arch\\)" \
+ "The target architecture is set to \"auto\" \\(currently $arch\\)\\." \
"$cmd ($which architecture)"

remote_file host delete $filename
@@ -122,7 +122,7 @@ gdb_test $cmd \

set cmd "show architecture"
gdb_test $cmd \
- "The target architecture is set automatically \\(currently $default_arch\\)" \
+ "The target architecture is set to \"auto\" \\(currently $default_arch\\)\\." \
"$cmd (invalid architecture)"

remote_file host delete $filename
--
2.25.4