37 VEC (serial_ops_p) *serial_ops_list = NULL;
41 static struct serial *scb_base;
46 static char *serial_logfile = NULL;
47 static struct ui_file *serial_logfp = NULL;
51 int ch_type,
int ch,
int timeout);
52 static const char logbase_hex[] =
"hex";
53 static const char logbase_octal[] =
"octal";
54 static const char logbase_ascii[] =
"ascii";
55 static const char *
const logbase_enums[] =
56 {logbase_hex, logbase_octal, logbase_ascii, NULL};
66 #define SERIAL_BREAK 1235
71 if (ch_type != serial_current_type)
74 serial_current_type = ch_type;
77 if (serial_logbase != logbase_ascii)
95 if (serial_logbase == logbase_hex)
97 else if (serial_logbase == logbase_octal)
125 isprint (ch) ?
"%c" :
"\\x%02x", ch & 0xFF);
137 serial_current_type =
'c';
154 for (i = 0;
VEC_iterate (serial_ops_p, serial_ops_list, i, ops); ++i)
155 if (strcmp (name, ops->
name) == 0)
175 for (scb = scb_base; scb; scb = scb->
next)
189 const char *open_name =
name;
191 if (strcmp (name,
"pc") == 0)
205 else if (strchr (name,
':'))
213 scb = XNEW (
struct serial);
223 if ((*scb->
ops->
open) (scb, open_name))
229 scb->
name = xstrdup (name);
230 scb->
next = scb_base;
237 if (serial_logfile != NULL)
239 serial_logfp =
gdb_fopen (serial_logfile,
"w");
240 if (serial_logfp == NULL)
265 scb = XCNEW (
struct serial);
275 scb->
next = scb_base;
282 if ((ops->
fdopen) != NULL)
304 serial_current_type = 0;
325 scb_base = scb_base->
next;
327 for (tmp_scb = scb_base; tmp_scb; tmp_scb = tmp_scb->
next)
329 if (tmp_scb->
next != scb)
354 return scb->
bufp != NULL;
380 _(
"serial_readchar: blocking read in async mode"));
383 if (serial_logfp != NULL)
405 if (serial_logfp != NULL)
407 const char *str =
buf;
410 for (c = 0; c < count; c++)
419 const char *str =
buf;
422 for (c = 0; c < count; c++)
431 return (scb->
ops->
write (scb, buf, count));
439 va_start (args, format);
469 if (serial_logfp != NULL)
552 int changed = ((scb->
async_handler == NULL) != (handler == NULL));
558 scb->
ops->
async (scb, handler != NULL);
575 serial_wait_handle (
struct serial *scb, HANDLE *read, HANDLE *except)
577 if (scb->
ops->wait_handle)
578 scb->
ops->wait_handle (scb, read, except);
581 *read = (HANDLE) _get_osfhandle (scb->
fd);
587 serial_done_wait_handle (
struct serial *scb)
589 if (scb->
ops->done_wait_handle)
590 scb->
ops->done_wait_handle (scb);
624 "by the name of a command.\n");
653 static const char parity_none[] =
"none";
654 static const char parity_odd[] =
"odd";
655 static const char parity_even[] =
"even";
656 static const char *
const parity_enums[] =
665 if (parity == parity_odd)
667 else if (parity == parity_even)
678 Connect the terminal directly up to the command monitor.\n\
679 Use <CR>~. or <CR>~^D to break out."));
683 Set default serial/parallel port configuration."),
684 &serial_set_cmdlist,
"set serial ",
689 Show default serial/parallel port configuration."),
690 &serial_show_cmdlist,
"show serial ",
697 Set baud rate for remote serial I/O."),
_(
"\
698 Show baud rate for remote serial I/O."),
_(
"\
699 This value is used to set the speed of the serial port when debugging\n\
700 using remote targets."),
703 &serial_set_cmdlist, &serial_show_cmdlist);
707 Set parity for remote serial I/O"),
_(
"\
708 Show parity for remote serial I/O"), NULL,
711 &serial_set_cmdlist, &serial_show_cmdlist);
714 Set filename for remote session recording."),
_(
"\
715 Show filename for remote session recording."),
_(
"\
716 This file is used to record the remote session for future playback\n\
723 &serial_logbase,
_(
"\
724 Set numerical base for remote session logging"),
_(
"\
725 Show numerical base for remote session logging"), NULL,
731 &global_serial_debug_p,
_(
"\
732 Set serial debugging."),
_(
"\
733 Show serial debugging."),
_(
"\
734 When non-zero, serial port debugging is enabled."),
int serial_is_async_p(struct serial *scb)
int serial_pipe(struct serial *scbs[2])
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
int serial_drain_output(struct serial *scb)
const struct serial_ops * serial_ops_p
serial_event_ftype * async_handler
int(* flush_output)(struct serial *)
static struct serial * serial_fdopen_ops(const int fd, const struct serial_ops *ops)
void add_setshow_zinteger_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void serial_debug(struct serial *scb, int debug_p)
void serial_print_tty_state(struct serial *scb, serial_ttystate ttystate, struct ui_file *stream)
void fputs_unfiltered(const char *buf, struct ui_file *file)
static const struct serial_ops * serial_interface_lookup(const char *name)
void add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct serial * serial_for_fd(int fd)
char * xstrvprintf(const char *format, va_list ap)
void(* print_tty_state)(struct serial *, serial_ttystate, struct ui_file *)
serial_ttystate(* copy_tty_state)(struct serial *, serial_ttystate)
void ui_file_delete(struct ui_file *file)
struct ui_file * gdb_stdout
struct ui_file * gdb_fopen(const char *name, const char *mode)
void internal_error(const char *file, int line, const char *fmt,...)
int(* flush_input)(struct serial *)
int serial_setstopbits(struct serial *scb, int num)
int serial_write(struct serial *scb, const void *buf, size_t count)
static const char * serial_logbase
int(* send_break)(struct serial *)
#define VEC_safe_push(T, V, O)
static const char parity_even[]
void serial_async(struct serial *scb, serial_event_ftype *handler, void *context)
int serial_debug_p(struct serial *scb)
int(* fdopen)(struct serial *, int fd)
static void serial_show_cmd(char *args, int from_tty)
int serial_set_tty_state(struct serial *scb, serial_ttystate ttystate)
static const char parity_none[]
void serial_printf(struct serial *desc, const char *format,...)
struct cmd_list_element * setlist
struct serial * serial_fdopen(const int fd)
void serial_log_command(struct target_ops *self, const char *cmd)
#define VEC_iterate(T, V, I, P)
int(* readchar)(struct serial *, int timeout)
int fputc_unfiltered(int c, struct ui_file *stream)
void serial_unref(struct serial *scb)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
const char * skip_spaces_const(const char *chp)
void serial_un_fdopen(struct serial *scb)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct cmd_list_element * showlist
int serial_setbaudrate(struct serial *scb, int rate)
int serial_flush_input(struct serial *scb)
int(* write)(struct serial *, const void *buf, size_t count)
int serial_send_break(struct serial *scb)
static void serial_set_cmd(char *args, int from_tty)
void serial_raw(struct serial *scb)
static int startswith(const char *string, const char *pattern)
int(* setstopbits)(struct serial *, int num)
unsigned char buf[BUFSIZ]
static struct cmd_list_element * serial_show_cmdlist
void _initialize_serial(void)
void printf_unfiltered(const char *format,...)
struct cmd_list_element * setdebuglist
int(* open)(struct serial *, const char *name)
struct ui_file * gdb_stdlog
void(* close)(struct serial *)
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
void serial_close(struct serial *scb)
serial_ttystate serial_get_tty_state(struct serial *scb)
struct serial * serial_open(const char *name)
int(* set_tty_state)(struct serial *, serial_ttystate)
int(* setparity)(struct serial *, int parity)
int gdb_pipe(int pdes[2])
static const char parity_odd[]
serial_ttystate(* get_tty_state)(struct serial *)
static void set_parity(char *ignore_args, int from_tty, struct cmd_list_element *c)
serial_ttystate serial_copy_tty_state(struct serial *scb, serial_ttystate ttystate)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
int serial_can_async_p(struct serial *scb)
void serial_add_interface(const struct serial_ops *optable)
static struct cmd_list_element * serial_set_cmdlist
static int serial_current_type
int serial_noflush_set_tty_state(struct serial *scb, serial_ttystate new_ttystate, serial_ttystate old_ttystate)
static void serial_baud_show_cmd(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
int serial_flush_output(struct serial *scb)
void( serial_event_ftype)(struct serial *scb, void *context)
char * safe_strerror(int)
void(* async)(struct serial *scb, int async_p)
void add_setshow_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void serial_logchar(struct ui_file *stream, int ch_type, int ch, int timeout)
int serial_setparity(struct serial *scb, int parity)
void serial_ref(struct serial *scb)
int(* noflush_set_tty_state)(struct serial *, serial_ttystate, serial_ttystate)
struct cmd_list_element * showdebuglist
int serial_readchar(struct serial *scb, int timeout)
void gdb_flush(struct ui_file *file)
int serial_is_open(struct serial *scb)
void(* go_raw)(struct serial *)
int(* setbaudrate)(struct serial *, int rate)
int(* drain_output)(struct serial *)
static unsigned int global_serial_debug_p
const struct serial_ops * ops
static void do_serial_close(struct serial *scb, int really_close)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)