46 int ch_type,
int ch,
int timeout);
61#define SERIAL_BREAK 1235
78 gdb_printf (stream,
"<Timeout: %d seconds>", timeout);
81 gdb_printf (stream,
"<Error: %s>", safe_strerror (errno));
120 isprint (ch) ?
"%c" :
"\\x%02x", ch & 0xFF);
147 if (strcmp (
name, ops->name) == 0)
181 scb = XCNEW (
struct serial);
193 const char *open_name);
201 const char *open_name =
name;
203 if (startswith (
name,
"|"))
208 else if (strchr (
name,
':'))
216 if (stat (
name, &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFSOCK)
239 if ((*scb->
ops->
open) (scb, open_name))
245 scb->
name = open_name != NULL ? xstrdup (open_name) : NULL;
338 for (tmp_scb =
scb_base; tmp_scb; tmp_scb = tmp_scb->
next)
340 if (tmp_scb->
next != scb)
365 return scb->
bufp != NULL;
390 internal_error (_(
"serial_readchar: blocking read in async mode"));
417 const char *str = (
const char *)
buf;
420 for (c = 0; c < count; c++)
429 const char *str = (
const char *)
buf;
432 for (c = 0; c < count; c++)
448 va_start (args, format);
450 std::string
buf = string_vprintf (format, args);
552 int changed = ((scb->
async_handler == NULL) != (handler == NULL));
558 scb->
ops->
async (scb, handler != NULL);
575serial_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);
587serial_done_wait_handle (
struct serial *scb)
589 if (scb->
ops->done_wait_handle)
590 scb->
ops->done_wait_handle (scb);
628 gdb_printf (file, _(
"Baud rate for remote serial I/O is %s.\n"),
662Connect the terminal directly up to the command monitor.\n\
663Use <CR>~. or <CR>~^D to break out."));
667 _(
"Set default serial/parallel port configuration."),
668 _(
"Show default serial/parallel port configuration."),
675Set baud rate for remote serial I/O."), _(
"\
676Show baud rate for remote serial I/O."), _(
"\
677This value is used to set the speed of the serial port when debugging\n\
678using remote targets."),
685Set parity for remote serial I/O."), _(
"\
686Show parity for remote serial I/O."), NULL,
692Set filename for remote session recording."), _(
"\
693Show filename for remote session recording."), _(
"\
694This file is used to record the remote session for future playback\n\
702Set numerical base for remote session logging."), _(
"\
703Show numerical base for remote session logging."), NULL,
710Set serial debugging."), _(
"\
711Show serial debugging."), _(
"\
712When non-zero, serial port debugging is enabled."),
struct cmd_list_element * showlist
struct cmd_list_element * setlist
struct cmd_list_element * showdebuglist
struct cmd_list_element * setdebuglist
set_show_commands add_setshow_filename_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
set_show_commands 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_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
ssize_t read(int fd, void *buf, size_t count)
int gdb_pipe(int pdes[2])
int serial_send_break(struct serial *scb)
void serial_un_fdopen(struct serial *scb)
void serial_printf(struct serial *desc, const char *format,...)
static struct serial * serial_fdopen_ops(const int fd, const struct serial_ops *ops)
int serial_drain_output(struct serial *scb)
void serial_print_tty_state(struct serial *scb, serial_ttystate ttystate, struct ui_file *stream)
static const char logbase_hex[]
static const char logbase_ascii[]
int serial_pipe(struct serial *scbs[2])
int serial_is_open(struct serial *scb)
int serial_setparity(struct serial *scb, int parity)
void serial_ref(struct serial *scb)
struct serial * serial_for_fd(int fd)
static const char parity_odd[]
static const char *const logbase_enums[]
static struct cmd_list_element * serial_show_cmdlist
static void serial_baud_show_cmd(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static struct serial * serial_open_ops_1(const struct serial_ops *ops, const char *open_name)
static void do_serial_close(struct serial *scb, int really_close)
int serial_write(struct serial *scb, const void *buf, size_t count)
struct serial * serial_open_ops(const struct serial_ops *ops)
int serial_set_tty_state(struct serial *scb, serial_ttystate ttystate)
void serial_unref(struct serial *scb)
static const struct serial_ops * serial_interface_lookup(const char *)
serial_ttystate serial_copy_tty_state(struct serial *scb, serial_ttystate ttystate)
void serial_raw(struct serial *scb)
static const char parity_even[]
static const char * parity
static void serial_logchar(struct ui_file *stream, int ch_type, int ch, int timeout)
static const char *const parity_enums[]
int serial_can_async_p(struct serial *scb)
static struct serial * new_serial(const struct serial_ops *ops)
serial_ttystate serial_get_tty_state(struct serial *scb)
int serial_flush_output(struct serial *scb)
static const char parity_none[]
void serial_log_command(struct target_ops *self, const char *cmd)
static unsigned int global_serial_debug_p
static int serial_current_type
static void set_parity(const char *ignore_args, int from_tty, struct cmd_list_element *c)
static const char * serial_logbase
static struct cmd_list_element * serial_set_cmdlist
int serial_readchar(struct serial *scb, int timeout)
void serial_debug(struct serial *scb, int debug_p)
void serial_async(struct serial *scb, serial_event_ftype *handler, void *context)
static struct ui_file * serial_logfp
int serial_setstopbits(struct serial *scb, int num)
static const char logbase_octal[]
struct serial * serial_open(const char *name)
void _initialize_serial()
int serial_flush_input(struct serial *scb)
static std::string serial_logfile
void serial_add_interface(const struct serial_ops *optable)
int serial_setbaudrate(struct serial *scb, int rate)
static struct serial * scb_base
static std::vector< const struct serial_ops * > serial_ops_list
int serial_is_async_p(struct serial *scb)
void serial_close(struct serial *scb)
struct serial * serial_fdopen(const int fd)
int serial_debug_p(struct serial *scb)
void serial_event_ftype(struct serial *scb, void *context)
int(* flush_output)(struct serial *)
void(* async)(struct serial *scb, int async_p)
int(* fdopen)(struct serial *, int fd)
void(* go_raw)(struct serial *)
int(* write)(struct serial *, const void *buf, size_t count)
serial_ttystate(* copy_tty_state)(struct serial *, serial_ttystate)
int(* drain_output)(struct serial *)
serial_ttystate(* get_tty_state)(struct serial *)
int(* flush_input)(struct serial *)
int(* set_tty_state)(struct serial *, serial_ttystate)
int(* setparity)(struct serial *, int parity)
int(* send_break)(struct serial *)
void(* print_tty_state)(struct serial *, serial_ttystate, struct ui_file *)
int(* open)(struct serial *, const char *name)
int(* setbaudrate)(struct serial *, int rate)
int(* readchar)(struct serial *, int timeout)
void(* close)(struct serial *)
int(* setstopbits)(struct serial *, int num)
serial_event_ftype * async_handler
unsigned char buf[BUFSIZ]
const struct serial_ops * ops
std::unique_ptr< stdio_file > stdio_file_up
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_flush(struct ui_file *stream)
void gdb_puts(const char *linebuffer, struct ui_file *stream)