X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fser-mingw.c;h=afe04102e1554ec734b7fe18c73a7b231ce224d9;hb=9cca177baec32a1ed1422a87a1f57cda2d2eb21a;hp=33e4df3b219703723f725a4a6291c15f53395023;hpb=481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9;p=binutils-gdb.git diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c index 33e4df3b219..afe04102e15 100644 --- a/gdb/ser-mingw.c +++ b/gdb/ser-mingw.c @@ -1,6 +1,6 @@ /* Serial interface for local (hardwired) serial ports on Windows systems - Copyright (C) 2006-2017 Free Software Foundation, Inc. + Copyright (C) 2006-2022 Free Software Foundation, Inc. This file is part of GDB. @@ -30,6 +30,7 @@ #include #include "command.h" +#include "gdbsupport/buildargv.h" struct ser_windows_state { @@ -321,9 +322,8 @@ ser_windows_read_prim (struct serial *scb, size_t count) { 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) @@ -351,7 +351,6 @@ ser_windows_read_prim (struct serial *scb, size_t count) 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; @@ -601,6 +600,11 @@ console_select_thread (void *arg) break; } } + else if (record.EventType == MOUSE_EVENT) + { + SetEvent (state->read_event); + break; + } /* Otherwise discard it and wait again. */ ReadConsoleInput (h, &record, 1, &n_records); @@ -634,7 +638,6 @@ pipe_select_thread (void *arg) { struct serial *scb = (struct serial *) arg; struct ser_console_state *state; - int event_index; HANDLE h; state = (struct ser_console_state *) scb->state; @@ -677,7 +680,6 @@ file_select_thread (void *arg) { struct serial *scb = (struct serial *) arg; struct ser_console_state *state; - int event_index; HANDLE h; state = (struct ser_console_state *) scb->state; @@ -848,20 +850,20 @@ free_pipe_state (struct pipe_state *ps) 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_up; static int pipe_windows_open (struct serial *scb, const char *name) { - struct pipe_state *ps; FILE *pex_stderr; - struct cleanup *back_to; if (name == NULL) error_no_arg (_("child command")); @@ -871,58 +873,51 @@ pipe_windows_open (struct serial *scb, const char *name) if (! argv[0] || argv[0][0] == '\0') error (_("missing child command")); - ps = make_pipe_state (); - back_to = 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.get (), NULL, NULL, - &err); + argv[0], argv.get (), NULL, NULL, + &err); if (err_msg) { - /* Our caller expects us to return -1, but all they'll do with - it generally is print the message based on errno. We have - all the same information here, plus err_msg provided by - pex_run, so we just raise the error here. */ - if (err) - error (_("error starting child process '%s': %s: %s"), - name, err_msg, safe_strerror (err)); - else - error (_("error starting child process '%s': %s"), - name, err_msg); + /* Our caller expects us to return -1, but all they'll do with + it generally is print the message based on errno. We have + all the same information here, plus err_msg provided by + pex_run, so we just raise the error here. */ + if (err) + error (_("error starting child process '%s': %s: %s"), + name, err_msg, safe_strerror (err)); + else + error (_("error starting child process '%s': %s"), + name, 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 (); - argv.release (); - discard_cleanups (back_to); return 0; - - fail: - do_cleanups (back_to); - return -1; } static int @@ -1195,7 +1190,6 @@ net_windows_open (struct serial *scb, const char *name) { struct net_windows_state *state; int ret; - DWORD threadId; ret = net_open (scb, name); if (ret != 0) @@ -1248,7 +1242,6 @@ static const struct serial_ops hardwire_ops = 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, @@ -1279,7 +1272,6 @@ static const struct serial_ops tty_ops = ser_base_copy_tty_state, ser_base_set_tty_state, ser_base_print_tty_state, - ser_base_noflush_set_tty_state, NULL, NULL, NULL, @@ -1310,7 +1302,6 @@ static const struct serial_ops pipe_ops = 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, @@ -1341,7 +1332,6 @@ static const struct serial_ops tcp_ops = 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, @@ -1354,11 +1344,11 @@ static const struct serial_ops tcp_ops = net_windows_done_wait_handle }; +void _initialize_ser_windows (); void -_initialize_ser_windows (void) +_initialize_ser_windows () { WSADATA wsa_data; - struct serial_ops *ops; HMODULE hm = NULL;