[RFA/code+NEWS] new "set/show serial baud" command (was: "Re: Setting parity for remote serial")

Joel Brobecker
2013-10-08T14:16:46Z

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

> > I'd rather we do it right the first time. If we're a go with
> > the "set serial baud" command, I don't mind taking care of
> > that part. As Pedro hints, it's a fairly easy change to make.
> >
> > Pedro, should we go ahead? It's only been a day or two, but we haven't
> > had any objection so far.
>
> Yeah, I think so.

Attached is a patch that implements that.

gdb/ChangeLog:

* cli/cli-cmds.c (show_baud_rate): Moved to serial.c as
serial_baud_show_cmd.
(_initialize_cli_cmds): Delete the code creating the
"set/show remotebaud" commands.
* serial.c (baud_rate): Move here from top.c.
(serial_baud_show_cmd): Move here from cli/cli-cmds.c.
(_initialize_serial): Create "set/show serial baud" commands.
Add "set/show remotebaud" command aliases.
* top.c (baud_rate): Moved to serial.c.
* NEWS: Document the new "set/show serial baud" commands,
replacing "set/show remotebaud".

Tested on x86_64-linux, with no regression (I almost expected one,
as we used to test thhe output "help set", or soemthing like that).

OK to commit?

Thanks,
--
Joel

[-- Attachment #2: 0001-Rename-set-show-remotebaud-command-into-set-show-ser.patch --]
[-- Type: text/x-diff, Size: 5872 bytes --]

From 94708a66478aadeb7e0bff57e6f83339e2b13bdd Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Tue, 8 Oct 2013 17:55:02 +0400
Subject: [PATCH] Rename "set/show remotebaud" command into "set/show serial
baud"

This patch renames the "set/show remotebaud" commands into
"set/show serial baud", and moves its implementation into serial.c.
It also moves the "baud_rate" global from top.c to serial.c, where
the new code is being added (the alternative was to add an include
of target.h).

And to facilitate the transition to the new setting name, this
patch also preserves the old command names via command aliases.

gdb/ChangeLog:

* cli/cli-cmds.c (show_baud_rate): Moved to serial.c as
serial_baud_show_cmd.
(_initialize_cli_cmds): Delete the code creating the
"set/show remotebaud" commands.
* serial.c (baud_rate): Move here from top.c.
(serial_baud_show_cmd): Move here from cli/cli-cmds.c.
(_initialize_serial): Create "set/show serial baud" commands.
Add "set/show remotebaud" command aliases.
* top.c (baud_rate): Moved to serial.c.
* NEWS: Document the new "set/show serial baud" commands,
replacing "set/show remotebaud".
---
gdb/NEWS | 5 +++++
gdb/cli/cli-cmds.c | 19 -------------------
gdb/serial.c | 30 ++++++++++++++++++++++++++++++
gdb/top.c | 7 -------
4 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 8114fb1..4e627b0 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -200,6 +200,11 @@ qXfer:libraries-svr4:read's annex

* GDB can now use Windows x64 unwinding data.

+* The "set remotebaud" command has been replaced by "set serial baud".
+ Similarly, "show remotebaud" has been replaced by "show serial baud".
+ The "set remotebaud" and "show remotebaud" commands are still available
+ to provide backward compatibility with older versions of GDB.
+
*** Changes in GDB 7.6

* Target record has been renamed to record-full.
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 886ba7a..460b719 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1582,14 +1582,6 @@ show_history_expansion_p (struct ui_file *file, int from_tty,
}

static void
-show_baud_rate (struct ui_file *file, int from_tty,
- struct cmd_list_element *c, const char *value)
-{
- fprintf_filtered (file, _("Baud rate for remote serial I/O is %s.\n"),
- value);
-}
-
-static void
show_remote_debug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
@@ -1748,17 +1740,6 @@ the previous command number shown."),
add_cmd ("configuration", no_set_class, show_configuration,
_("Show how GDB was configured at build time."), &showlist);

- /* If target is open when baud changes, it doesn't take effect until
- the next open (I think, not sure). */
- add_setshow_zinteger_cmd ("remotebaud", no_class, &baud_rate, _("\
-Set baud rate for remote serial I/O."), _("\
-Show baud rate for remote serial I/O."), _("\
-This value is used to set the speed of the serial port when debugging\n\
-using remote targets."),
- NULL,
- show_baud_rate,
- &setlist, &showlist);
-
add_setshow_zinteger_cmd ("remote", no_class, &remote_debug, _("\
Set debugging of remote protocol."), _("\
Show debugging of remote protocol."), _("\
diff --git a/gdb/serial.c b/gdb/serial.c
index ee3f1ea..434cde4 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -621,6 +621,20 @@ serial_show_cmd (char *args, int from_tty)
cmd_show_list (serial_show_cmdlist, from_tty, "");
}

+/* Baud rate specified for talking to serial target systems. Default
+ is left as -1, so targets can choose their own defaults. */
+/* FIXME: This means that "show remotebaud" and gr_files_info can
+ print -1 or (unsigned int)-1. This is a Bad User Interface. */
+
+int baud_rate = -1;
+
+static void
+serial_baud_show_cmd (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Baud rate for remote serial I/O is %s.\n"),
+ value);
+}

void
_initialize_serial (void)
@@ -643,6 +657,22 @@ Show default serial/parallel port configuration."),
0/*allow-unknown*/,
&showlist);

+ /* If target is open when baud changes, it doesn't take effect until
+ the next open (I think, not sure). */
+ add_setshow_zinteger_cmd ("baud", no_class, &baud_rate, _("\
+Set baud rate for remote serial I/O."), _("\
+Show baud rate for remote serial I/O."), _("\
+This value is used to set the speed of the serial port when debugging\n\
+using remote targets."),
+ NULL,
+ serial_baud_show_cmd,
+ &serial_set_cmdlist, &serial_show_cmdlist);
+
+ /* The commands "set/show serial baud" used to have a different name.
+ Add aliases to those names to facilitate the transition. */
+ add_alias_cmd ("remotebaud", "serial baud", no_class, 0, &setlist);
+ add_alias_cmd ("remotebaud", "serial baud", no_class, 0, &showlist);
+
add_setshow_filename_cmd ("remotelogfile", no_class, &serial_logfile, _("\
Set filename for remote session recording."), _("\
Show filename for remote session recording."), _("\
diff --git a/gdb/top.c b/gdb/top.c
index d9128a3..c473d8c 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -144,13 +144,6 @@ int saved_command_line_size = 100;
is issuing commands too. */
int server_command;

-/* Baud rate specified for talking to serial target systems. Default
- is left as -1, so targets can choose their own defaults. */
-/* FIXME: This means that "show remotebaud" and gr_files_info can
- print -1 or (unsigned int)-1. This is a Bad User Interface. */
-
-int baud_rate = -1;
-
/* Timeout limit for response from target. */

/* The default value has been changed many times over the years. It
--
1.8.1.2