aboutsummaryrefslogtreecommitdiff
path: root/gdb/ser-mingw.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-09-06 08:33:46 -0600
committerTom Tromey <tromey@adacore.com>2023-11-27 12:55:14 -0700
commitd69939bded50d76179f97284df35879a385cf8c0 (patch)
tree965bb45900e7a4442d3ce67e551d5cafe73e8691 /gdb/ser-mingw.c
parenta2e0acea420cca881296c6fcf58920f3d7c05a45 (diff)
downloadgdb-d69939bded50d76179f97284df35879a385cf8c0.zip
gdb-d69939bded50d76179f97284df35879a385cf8c0.tar.gz
gdb-d69939bded50d76179f97284df35879a385cf8c0.tar.bz2
Change serial_send_break and serial_write to throw
This changes serial_send_break and serial_write to throw exceptions rather than attempt to set errno and return an error indicator. This lets us correctly report failures on Windows. Both functions had to be converted in a single patch because one implementation of send_break works via write. This also introduces remote_serial_send_break to handle error checking when attempting to send a break. This was previously ignored. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770
Diffstat (limited to 'gdb/ser-mingw.c')
-rw-r--r--gdb/ser-mingw.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c
index 30d9085..4607a10 100644
--- a/gdb/ser-mingw.c
+++ b/gdb/ser-mingw.c
@@ -118,21 +118,21 @@ ser_windows_flush_input (struct serial *scb)
return (PurgeComm (h, PURGE_RXCLEAR) != 0) ? 0 : -1;
}
-static int
+static void
ser_windows_send_break (struct serial *scb)
{
HANDLE h = (HANDLE) _get_osfhandle (scb->fd);
if (SetCommBreak (h) == 0)
- return -1;
+ throw_winerror_with_name ("error calling SetCommBreak",
+ GetLastError ());
/* Delay for 250 milliseconds. */
Sleep (250);
if (ClearCommBreak (h) == 0)
- return -1;
-
- return 0;
+ throw_winerror_with_name ("error calling ClearCommBreak",
+ GetLastError ());
}
static void
@@ -354,7 +354,7 @@ ser_windows_write_prim (struct serial *scb, const void *buf, size_t len)
{
if (GetLastError () != ERROR_IO_PENDING
|| !GetOverlappedResult (h, &ov, &bytes_written, TRUE))
- bytes_written = -1;
+ throw_winerror_with_name ("error while writing", GetLastError ());
}
CloseHandle (ov.hEvent);
@@ -986,14 +986,14 @@ pipe_windows_write (struct serial *scb, const void *buf, size_t count)
int pipeline_in_fd = fileno (ps->input);
if (pipeline_in_fd < 0)
- return -1;
+ error (_("could not find file number for pipe"));
pipeline_in = (HANDLE) _get_osfhandle (pipeline_in_fd);
if (pipeline_in == INVALID_HANDLE_VALUE)
- return -1;
+ error (_("could not find handle for pipe"));
if (! WriteFile (pipeline_in, buf, count, &written, NULL))
- return -1;
+ throw_winerror_with_name (_("could not write to pipe"), GetLastError ());
return written;
}