gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / ser-mingw.c
index 0b78ba18e0fafc29c71db997f125eeccb040242e..d204e861a7a8d6e6633544729826326846a4e81a 100644 (file)
@@ -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-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -31,8 +31,6 @@
 
 #include "command.h"
 
-void _initialize_ser_windows (void);
-
 struct ser_windows_state
 {
   int in_progress;
@@ -323,9 +321,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)
@@ -353,7 +350,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;
@@ -636,7 +632,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;
@@ -679,7 +674,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;
@@ -850,20 +844,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, pipe_state_destroyer> 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"));
@@ -873,15 +867,14 @@ 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;
@@ -908,23 +901,17 @@ pipe_windows_open (struct serial *scb, const char *name)
 
   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
@@ -1197,7 +1184,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)
@@ -1250,7 +1236,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,
@@ -1281,7 +1266,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,
@@ -1312,7 +1296,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,
@@ -1343,7 +1326,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,
@@ -1356,11 +1338,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;
 
This page took 0.038895 seconds and 4 git commands to generate.