From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fernando Nasser To: Mark Salter Cc: gdb-patches@sources.redhat.com Subject: Re: set/show remotestopbits Date: Wed, 26 Sep 2001 07:35:00 -0000 Message-id: <3BB1E68E.8412414F@redhat.com> References: <200109261227.f8QCRjr27498@deneb.localdomain> X-SW-Source: 2001-09/msg00348.html Mark Salter wrote: > > I have a target board with a stub and a serial port that is fixed > at 2 stopbits, so I need a way to tell gdb to use something other > than the default 1. > > --Mark > Oh yes! This is a good one. However, I believe you've used the deprecated way. The commands to set remote protocol things are now all grouped together: set remote XXXXXX VVVVVVV So, it should be set remote stopbits 2 for instance. (P.S.: It is not under my maintainership so I cannot approve it myself, but I recommend it -- after the syntax update) Regards, Fernando > Index: remote.c > =================================================================== > RCS file: /cvs/src/src/gdb/remote.c,v > retrieving revision 1.62 > diff -u -p -5 -r1.62 remote.c > --- remote.c 2001/08/10 09:59:32 1.62 > +++ remote.c 2001/09/26 12:14:55 > @@ -2159,10 +2159,13 @@ serial device is attached to the remote > serial_close (remote_desc); > perror_with_name (name); > } > } > > + if (stop_bits != -1) > + serial_setstopbits (remote_desc, stop_bits); > + > serial_raw (remote_desc); > > /* If there is something sitting in the buffer we might take it as a > response to a command, which would be bad. */ > serial_flush_input (remote_desc); > @@ -2255,10 +2258,13 @@ serial device is attached to the remote > { > serial_close (remote_desc); > perror_with_name (name); > } > } > + > + if (stop_bits != -1) > + serial_setstopbits (remote_desc, stop_bits); > > serial_raw (remote_desc); > > /* If there is something sitting in the buffer we might take it as a > response to a command, which would be bad. */ > Index: target.h > =================================================================== > RCS file: /cvs/src/src/gdb/target.h,v > retrieving revision 1.20 > diff -u -p -5 -r1.20 target.h > --- target.h 2001/08/11 00:59:29 1.20 > +++ target.h 2001/09/26 12:14:57 > @@ -1209,10 +1209,13 @@ extern void remove_target_sections (bfd > information (higher values, more information). */ > extern int remote_debug; > > /* Speed in bits per second, or -1 which means don't mess with the speed. */ > extern int baud_rate; > +/* Number of stop bits (as defined in serial.h), or -1 which means don't > + mess with the stopbits. */ > +extern int stop_bits; > /* Timeout limit for response from target. */ > extern int remote_timeout; > > > /* Functions for helping to write a native target. */ > Index: top.c > =================================================================== > RCS file: /cvs/src/src/gdb/top.c,v > retrieving revision 1.45 > diff -u -p -5 -r1.45 top.c > --- top.c 2001/09/07 21:33:08 1.45 > +++ top.c 2001/09/26 12:14:57 > @@ -133,10 +133,14 @@ int server_command; > /* 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; > > +/* Stop bits for talking to serial target systems. Default > + is left as -1, so targets can choose their own defaults. */ > +int stop_bits = -1; > + > /* Timeout limit for response from target. */ > > /* The default value has been changed many times over the years. It > was originally 5 seconds. But that was thought to be a long time > to sit and wait, so it was changed to 2 seconds. That was thought > Index: cli/cli-cmds.c > =================================================================== > RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v > retrieving revision 1.10 > diff -u -p -5 -r1.10 cli-cmds.c > --- cli-cmds.c 2001/09/01 21:38:05 1.10 > +++ cli-cmds.c 2001/09/26 12:14:57 > @@ -22,10 +22,11 @@ > #include "completer.h" > #include "target.h" /* For baud_rate, remote_debug and remote_timeout */ > #include "gdb_wait.h" /* For shell escape implementation */ > #include "gdb_regex.h" /* Used by apropos_command */ > #include "filenames.h" /* for DOSish file names */ > +#include "serial.h" > > #ifdef UI_OUT > #include "ui-out.h" > #endif > > @@ -78,10 +79,12 @@ static void show_user (char *, int); > static void make_command (char *, int); > > static void shell_escape (char *, int); > > void apropos_command (char *, int); > + > +static void set_stopbits_command (char *, int); > > /* Define all cmd_list_elements. */ > > /* Chain containing all defined commands. */ > > @@ -160,10 +163,17 @@ struct cmd_list_element *setdebuglist; > struct cmd_list_element *showdebuglist; > > struct cmd_list_element *setchecklist; > > struct cmd_list_element *showchecklist; > + > +/* The "set remotestopbits" command put stuff in this buffer. > + This is to make it work as set/show commands. The user's > + string is copied here, then the set_* commands look at it > + and update it to something that looks nice when it is > + printed out. */ > +static char *stop_bits_str; > > /* Utility used everywhere when at least one argument is needed and > none is supplied. */ > > void > @@ -554,10 +564,46 @@ apropos_command (char *searchstr, int fr > regerror(regcomp(&pattern,searchstr,REG_ICASE),NULL,errorbuffer,512); > error("Error in regular expression:%s",errorbuffer); > } > xfree (pattern_fastmap); > } > + > +/* Set command. Change the setting for type checking. */ > +static void > +set_stopbits_command (char *ignore, int from_tty) > +{ > + if (STREQ (stop_bits_str, "1")) > + stop_bits = SERIAL_1_STOPBITS; > + else if (STREQ (stop_bits_str, "1.5")) > + stop_bits = SERIAL_1_AND_A_HALF_STOPBITS; > + else if (STREQ (stop_bits_str, "2")) > + stop_bits = SERIAL_2_STOPBITS; > + else if (STREQ (stop_bits_str, "default")) > + stop_bits = -1; > + else > + { > + warning ("Unrecognized stopbits value: \"%s\"", stop_bits_str); > + /* change stop_bits_str to match previous value. */ > + xfree (stop_bits_str); > + switch (stop_bits) > + { > + case SERIAL_1_STOPBITS: > + stop_bits_str = xstrdup ("1"); > + break; > + case SERIAL_1_AND_A_HALF_STOPBITS: > + stop_bits_str = xstrdup ("1.5"); > + break; > + case SERIAL_2_STOPBITS: > + stop_bits_str = xstrdup ("2"); > + break; > + default: > + stop_bits = -1; > + stop_bits_str = xstrdup ("default"); > + break; > + } > + } > +} > > static void > set_debug (char *arg, int from_tty) > { > printf_unfiltered ("\"set debug\" must be followed by the name of a print subcommand.\n"); > @@ -734,10 +780,18 @@ is used, the same rules apply to its nes > var_zinteger, (char *) &baud_rate, > "Set baud rate for remote serial I/O.\n\ > This value is used to set the speed of the serial port when debugging\n\ > using remote targets.", &setlist), > &showlist); > + > + c = add_set_cmd ("remotestopbits", no_class, var_string_noescape, > + (char *) &stop_bits_str, > + "Set number of stopbits for remote serial I/O.\n\ > +Valid values are 1, 1.5, and 2.", &setlist); > + c->function.cfunc = set_stopbits_command; > + add_show_from_set (c, &showlist); > + stop_bits_str = xstrdup ("default"); > > c = add_set_cmd ("remotedebug", no_class, var_zinteger, > (char *) &remote_debug, > "Set debugging of remote protocol.\n\ > When enabled, each packet sent or received with the remote target\n\ -- Fernando Nasser Red Hat Canada Ltd. E-Mail: fnasser@redhat.com 2323 Yonge Street, Suite #300 Toronto, Ontario M4P 2C9