/* Serial interface for local (hardwired) serial ports on Windows systems
- Copyright (C) 2006-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "command.h"
-void _initialize_ser_windows (void);
-
struct ser_windows_state
{
int in_progress;
state.fAbortOnError = FALSE;
state.ByteSize = 8;
- scb->current_timeout = 0;
-
if (SetCommState (h, &state) == 0)
warning (_("SetCommState failed"));
}
{
struct ser_windows_state *state;
OVERLAPPED ov;
- DWORD bytes_read, bytes_read_tmp;
+ DWORD bytes_read;
HANDLE h;
- gdb_byte *p;
state = (struct ser_windows_state *) scb->state;
if (state->in_progress)
static int
ser_windows_write_prim (struct serial *scb, const void *buf, size_t len)
{
- struct ser_windows_state *state;
OVERLAPPED ov;
DWORD bytes_written;
HANDLE h;
{
struct serial *scb = (struct serial *) arg;
struct ser_console_state *state;
- int event_index;
HANDLE h;
state = (struct ser_console_state *) scb->state;
{
struct serial *scb = (struct serial *) arg;
struct ser_console_state *state;
- int event_index;
HANDLE h;
state = (struct ser_console_state *) scb->state;
errno = saved_errno;
}
-static void
-cleanup_pipe_state (void *untyped)
+struct pipe_state_destroyer
{
- struct pipe_state *ps = (struct pipe_state *) untyped;
+ void operator() (pipe_state *ps) const
+ {
+ free_pipe_state (ps);
+ }
+};
- free_pipe_state (ps);
-}
+typedef std::unique_ptr<pipe_state, pipe_state_destroyer> pipe_state_up;
static int
pipe_windows_open (struct serial *scb, const char *name)
{
- struct pipe_state *ps;
FILE *pex_stderr;
- char **argv;
- struct cleanup *back_to;
if (name == NULL)
error_no_arg (_("child command"));
- argv = gdb_buildargv (name);
- back_to = make_cleanup_freeargv (argv);
+ gdb_argv argv (name);
if (! argv[0] || argv[0][0] == '\0')
error (_("missing child command"));
- ps = make_pipe_state ();
- make_cleanup (cleanup_pipe_state, ps);
+ pipe_state_up ps (make_pipe_state ());
ps->pex = pex_init (PEX_USE_PIPES, "target remote pipe", NULL);
if (! ps->pex)
- goto fail;
+ return -1;
ps->input = pex_input_pipe (ps->pex, 1);
if (! ps->input)
- goto fail;
+ return -1;
{
int err;
const char *err_msg
= pex_run (ps->pex, PEX_SEARCH | PEX_BINARY_INPUT | PEX_BINARY_OUTPUT
| PEX_STDERR_TO_PIPE,
- argv[0], argv, NULL, NULL,
+ argv[0], argv.get (), NULL, NULL,
&err);
if (err_msg)
ps->output = pex_read_output (ps->pex, 1);
if (! ps->output)
- goto fail;
+ return -1;
scb->fd = fileno (ps->output);
pex_stderr = pex_read_err (ps->pex, 1);
if (! pex_stderr)
- goto fail;
+ return -1;
scb->error_fd = fileno (pex_stderr);
- scb->state = (void *) ps;
+ scb->state = ps.release ();
- discard_cleanups (back_to);
return 0;
-
- fail:
- do_cleanups (back_to);
- return -1;
}
static int
{
struct net_windows_state *state;
int ret;
- DWORD threadId;
ret = net_open (scb, name);
if (ret != 0)
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_windows_setbaudrate,
ser_windows_setstopbits,
ser_windows_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
NULL,
NULL,
NULL,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
ser_base_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
ser_base_setparity,
_initialize_ser_windows (void)
{
WSADATA wsa_data;
- struct serial_ops *ops;
HMODULE hm = NULL;