39 static struct serial *scb_base;
44 static char *serial_logfile = NULL;
45 static struct ui_file *serial_logfp = NULL;
49 int ch_type,
int ch,
int timeout);
50 static const char logbase_hex[] =
"hex";
51 static const char logbase_octal[] =
"octal";
52 static const char logbase_ascii[] =
"ascii";
53 static const char *
const logbase_enums[] =
54 {logbase_hex, logbase_octal, logbase_ascii, NULL};
64 #define SERIAL_BREAK 1235 123 isprint (ch) ?
"%c" :
"\\x%02x", ch & 0xFF);
173 for (scb = scb_base; scb; scb = scb->
next)
199 const char *open_name);
207 const char *open_name =
name;
219 else if (strchr (
name,
':'))
240 if ((*scb->
ops->
open) (scb, open_name))
246 scb->
next = scb_base;
249 if (serial_logfile != NULL)
253 if (!file->open (serial_logfile,
"w"))
256 serial_logfp = file.release ();
290 scb->
next = scb_base;
333 scb_base = scb_base->
next;
335 for (tmp_scb = scb_base; tmp_scb; tmp_scb = tmp_scb->
next)
337 if (tmp_scb->
next != scb)
362 return scb->
bufp != NULL;
388 _(
"serial_readchar: blocking read in async mode"));
391 if (serial_logfp != NULL)
413 if (serial_logfp != NULL)
415 const char *str = (
const char *)
buf;
418 for (c = 0; c < count; c++)
427 const char *str = (
const char *)
buf;
430 for (c = 0; c < count; c++)
447 va_start (args, format);
477 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");
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."),
689 Show default serial/parallel port configuration."),
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."),
707 Set parity for remote serial I/O"),
_(
"\ 708 Show parity for remote serial I/O"), NULL,
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\ 724 Set numerical base for remote session logging"),
_(
"\ 725 Show numerical base for remote session logging"), NULL,
732 Set serial debugging."),
_(
"\ 733 Show serial debugging."),
_(
"\ 734 When non-zero, serial port debugging is enabled."),
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_const_sfunc_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 serial_is_async_p(struct serial *scb)
int serial_pipe(struct serial *scbs[2])
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 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 struct serial * serial_open_ops_1(const struct serial_ops *ops, const char *open_name)
static const struct serial_ops * serial_interface_lookup(const char *name)
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 internal_error(const char *file, int line, const char *fmt,...)
int(* flush_input)(struct serial *)
int serial_setstopbits(struct serial *scb, int num)
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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
char * skip_spaces(char *chp)
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)
int serial_set_tty_state(struct serial *scb, serial_ttystate ttystate)
static const char parity_none[]
static void serial_show_cmd(const char *args, int from_tty)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static void serial_set_cmd(const char *args, int from_tty)
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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
struct serial * serial_open_ops(const struct serial_ops *ops)
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,...)
void serial_un_fdopen(struct serial *scb)
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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
static void set_parity(const char *ignore_args, int from_tty, struct cmd_list_element *c)
std::unique_ptr< stdio_file > stdio_file_up
int serial_send_break(struct serial *scb)
static const char * parity
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)
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 *)
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
static struct serial * new_serial(const struct serial_ops *ops)
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
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)
char * safe_strerror(int)
void(* async)(struct serial *scb, int async_p)
void() serial_event_ftype(struct serial *scb, void *context)
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)
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 *)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
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)
static const char *const parity_enums[]