[PUSHED 2/2] gdb: Improve formatting of 'show endian' messages

Andrew Burgess
2020-07-14T12:27:15Z

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

(gdb) show endian
The target endianness is set automatically (currently little endian)
(gdb) set endian big
The target is assumed to be big endian
(gdb) show endian
The target is assumed to be big endian
(gdb)

After this commit the session now looks like this:

(gdb) show endian
The target endianness is set automatically (currently little endian).
(gdb) set endian big
The target is set to big endian.
(gdb) show endian
The target is set to big endian.
(gdb)

The changes are:

1. Each line ends with '.', and
2. After setting the endianness GDB is now a little more assertive;
'target is set to' not 'target is assumed to be', the user did just
tell us after all!
---
gdb/arch-utils.c | 8 ++---
.../gdb.base/all-architectures.exp.tcl | 4 +--
gdb/testsuite/gdb.base/endian.exp | 34 +++++++++----------
3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index f89260a32b7..13ba50abe61 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -317,17 +317,17 @@ show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
fprintf_unfiltered (file, _("The target endianness is set automatically "
- "(currently big endian)\n"));
+ "(currently big endian).\n"));
else
fprintf_unfiltered (file, _("The target endianness is set automatically "
- "(currently little endian)\n"));
+ "(currently little endian).\n"));
else
if (target_byte_order_user == BFD_ENDIAN_BIG)
fprintf_unfiltered (file,
- _("The target is assumed to be big endian\n"));
+ _("The target is set to big endian.\n"));
else
fprintf_unfiltered (file,
- _("The target is assumed to be little endian\n"));
+ _("The target is set to little endian.\n"));
}

static void
diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.tcl b/gdb/testsuite/gdb.base/all-architectures.exp.tcl
index 4c59728b8c0..34afa434b1c 100644
--- a/gdb/testsuite/gdb.base/all-architectures.exp.tcl
+++ b/gdb/testsuite/gdb.base/all-architectures.exp.tcl
@@ -225,7 +225,7 @@ with_test_prefix "tests" {
continue
} elseif {$endian == "auto"} {
gdb_test_multiple "set endian $endian" $test {
- -re "^set endian $endian\r\n(${osabi_warning})?The target endianness is set automatically \\(currently .* endian\\)\r\n$gdb_prompt $" {
+ -re "^set endian $endian\r\n(${osabi_warning})?The target endianness is set automatically \\(currently .* endian\\)\\.\r\n$gdb_prompt $" {
internal_pass $test
}
}
@@ -235,7 +235,7 @@ with_test_prefix "tests" {
internal_pass $test
continue
}
- -re "^set endian $endian\r\n(${osabi_warning})?The target is assumed to be $endian endian\r\n$gdb_prompt $" {
+ -re "^set endian $endian\r\n(${osabi_warning})?The target is set to $endian endian\\.\r\n$gdb_prompt $" {
internal_pass $test
}
}
diff --git a/gdb/testsuite/gdb.base/endian.exp b/gdb/testsuite/gdb.base/endian.exp
index 611b0ff5fbc..3058e6294aa 100644
--- a/gdb/testsuite/gdb.base/endian.exp
+++ b/gdb/testsuite/gdb.base/endian.exp
@@ -18,26 +18,26 @@
standard_testfile

set en_auto "The target endianness is set automatically"
-set en_set "The target is assumed to be"
+set en_set "The target is set to"

clean_restart

# First check that the automatic endianness is updated
# with the `set endian' command.
gdb_test "set endian auto" \
- "$en_auto \\\(currently \(\?:big\|little\) endian\\\)" \
+ "$en_auto \\\(currently \(\?:big\|little\) endian\\\)\\." \
"default target endianness"
-gdb_test "set endian big" "$en_set big endian" \
+gdb_test "set endian big" "$en_set big endian\\." \
"set target endianness"
-gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)" \
+gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
"auto target endianness"
-gdb_test "set endian little" "$en_set little endian" \
+gdb_test "set endian little" "$en_set little endian\\." \
"set target endianness little"
-gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)" \
+gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)\\." \
"auto target endianness little"
-gdb_test "set endian big" "$en_set big endian" \
+gdb_test "set endian big" "$en_set big endian\\." \
"set target endianness big"
-gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)" \
+gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
"auto target endianness big"

if { [build_executable ${testfile}.exp $testfile] } {
@@ -49,7 +49,7 @@ if { [gdb_file_cmd $binfile] } {
}
set test "get target endianness"
if { [gdb_test_multiple "show endian" "$test" {
- -re "$en_auto \\\(currently \(big\|little\) endian\\\).*$gdb_prompt" {
+ -re "$en_auto \\\(currently \(big\|little\) endian\\\)\\..*$gdb_prompt" {
set endian $expect_out(1,string)
pass "$test"
}
@@ -64,31 +64,31 @@ if { [gdb_test_multiple "show endian" "$test" {
if { [gdb_unload] } {
gdb_suppress_entire_file "$pf_prefix cannot unselect executable"
}
-gdb_test "set endian big" "$en_set big endian" \
+gdb_test "set endian big" "$en_set big endian\\." \
"override target endianness big"
-gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)" \
+gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
"override auto target endianness big"
if { [gdb_file_cmd $binfile] } {
gdb_suppress_entire_file "$pf_prefix cannot select executable"
}
-gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)" \
+gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously big default executable endianness"
if { [gdb_unload] } {
gdb_suppress_entire_file "$pf_prefix cannot unselect executable"
}
-gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)" \
+gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously big default no executable endianness"
-gdb_test "set endian little" "$en_set little endian" \
+gdb_test "set endian little" "$en_set little endian\\." \
"override target endianness little"
-gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)" \
+gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)\\." \
"override auto target endianness little"
if { [gdb_file_cmd $binfile] } {
gdb_suppress_entire_file "$pf_prefix cannot select executable"
}
-gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)" \
+gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously little default executable endianness"
if { [gdb_unload] } {
gdb_suppress_entire_file "$pf_prefix cannot unselect executable"
}
-gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)" \
+gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
"previously little default no executable endianness"
--
2.25.4