/* Serial interface for local (hardwired) serial ports on Windows systems
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 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;
/* CancelIo is not available for Windows 95 OS, so we need to use
LoadLibrary/GetProcAddress to avoid a startup failure. */
#define CancelIo dyn_CancelIo
-static BOOL WINAPI (*CancelIo) (HANDLE);
+typedef BOOL WINAPI (CancelIo_ftype) (HANDLE);
+static CancelIo_ftype *CancelIo;
/* Open up a real live device for serial I/O. */
state.fAbortOnError = FALSE;
state.ByteSize = 8;
- scb->current_timeout = 0;
-
if (SetCommState (h, &state) == 0)
warning (_("SetCommState failed"));
}
by calling close (scb->fd) below. */
if (CancelIo)
CancelIo ((HANDLE) _get_osfhandle (scb->fd));
- state = scb->state;
+ state = (struct ser_windows_state *) scb->state;
CloseHandle (state->ov.hEvent);
CloseHandle (state->except_event);
DWORD errors;
HANDLE h = (HANDLE) _get_osfhandle (scb->fd);
- state = scb->state;
+ state = (struct ser_windows_state *) scb->state;
*except = state->except_event;
*read = state->ov.hEvent;
HANDLE h;
gdb_byte *p;
- state = scb->state;
+ state = (struct ser_windows_state *) scb->state;
if (state->in_progress)
{
WaitForSingleObject (state->ov.hEvent, INFINITE);
static DWORD WINAPI
console_select_thread (void *arg)
{
- struct serial *scb = arg;
+ struct serial *scb = (struct serial *) arg;
struct ser_console_state *state;
int event_index;
HANDLE h;
- state = scb->state;
+ state = (struct ser_console_state *) scb->state;
h = (HANDLE) _get_osfhandle (scb->fd);
while (1)
static DWORD WINAPI
pipe_select_thread (void *arg)
{
- struct serial *scb = arg;
+ struct serial *scb = (struct serial *) arg;
struct ser_console_state *state;
int event_index;
HANDLE h;
- state = scb->state;
+ state = (struct ser_console_state *) scb->state;
h = (HANDLE) _get_osfhandle (scb->fd);
while (1)
static DWORD WINAPI
file_select_thread (void *arg)
{
- struct serial *scb = arg;
+ struct serial *scb = (struct serial *) arg;
struct ser_console_state *state;
int event_index;
HANDLE h;
- state = scb->state;
+ state = (struct ser_console_state *) scb->state;
h = (HANDLE) _get_osfhandle (scb->fd);
while (1)
static void
ser_console_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except)
{
- struct ser_console_state *state = scb->state;
+ struct ser_console_state *state = (struct ser_console_state *) scb->state;
if (state == NULL)
{
static void
ser_console_done_wait_handle (struct serial *scb)
{
- struct ser_console_state *state = scb->state;
+ struct ser_console_state *state = (struct ser_console_state *) scb->state;
if (state == NULL)
return;
static void
ser_console_close (struct serial *scb)
{
- struct ser_console_state *state = scb->state;
+ struct ser_console_state *state = (struct ser_console_state *) scb->state;
if (scb->state)
{
static void
cleanup_pipe_state (void *untyped)
{
- struct pipe_state *ps = untyped;
+ struct pipe_state *ps = (struct pipe_state *) untyped;
free_pipe_state (ps);
}
{
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);
+ back_to = make_cleanup (cleanup_pipe_state, ps);
ps->pex = pex_init (PEX_USE_PIPES, "target remote pipe", NULL);
if (! ps->pex)
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)
scb->state = (void *) ps;
+ argv.release ();
discard_cleanups (back_to);
return 0;
static void
pipe_windows_close (struct serial *scb)
{
- struct pipe_state *ps = scb->state;
+ struct pipe_state *ps = (struct pipe_state *) scb->state;
/* In theory, we should try to kill the subprocess here, but the pex
interface doesn't give us enough information to do that. Usually
static int
pipe_windows_write (struct serial *scb, const void *buf, size_t count)
{
- struct pipe_state *ps = scb->state;
+ struct pipe_state *ps = (struct pipe_state *) scb->state;
HANDLE pipeline_in;
DWORD written;
static void
pipe_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except)
{
- struct pipe_state *ps = scb->state;
+ struct pipe_state *ps = (struct pipe_state *) scb->state;
/* Have we allocated our events yet? */
if (ps->wait.read_event == INVALID_HANDLE_VALUE)
static void
pipe_done_wait_handle (struct serial *scb)
{
- struct pipe_state *ps = scb->state;
+ struct pipe_state *ps = (struct pipe_state *) scb->state;
/* Have we allocated our events yet? */
if (ps->wait.read_event == INVALID_HANDLE_VALUE)
static int
net_windows_socket_check_pending (struct serial *scb)
{
- struct net_windows_state *state = scb->state;
+ struct net_windows_state *state = (struct net_windows_state *) scb->state;
unsigned long available;
if (ioctlsocket (scb->fd, FIONREAD, &available) != 0)
static DWORD WINAPI
net_windows_select_thread (void *arg)
{
- struct serial *scb = arg;
+ struct serial *scb = (struct serial *) arg;
struct net_windows_state *state;
int event_index;
- state = scb->state;
+ state = (struct net_windows_state *) scb->state;
while (1)
{
static void
net_windows_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except)
{
- struct net_windows_state *state = scb->state;
+ struct net_windows_state *state = (struct net_windows_state *) scb->state;
/* Start from a clean slate. */
ResetEvent (state->base.read_event);
static void
net_windows_done_wait_handle (struct serial *scb)
{
- struct net_windows_state *state = scb->state;
+ struct net_windows_state *state = (struct net_windows_state *) scb->state;
stop_select_thread (&state->base);
}
static void
net_windows_close (struct serial *scb)
{
- struct net_windows_state *state = scb->state;
+ struct net_windows_state *state = (struct net_windows_state *) scb->state;
destroy_select_thread (&state->base);
CloseHandle (state->sock_event);
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,
hm = LoadLibrary ("kernel32.dll");
if (hm)
{
- CancelIo = (void *) GetProcAddress (hm, "CancelIo");
+ CancelIo = (CancelIo_ftype *) GetProcAddress (hm, "CancelIo");
FreeLibrary (hm);
}
else