This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Windows interruptible semi-hosting
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Fri, 13 Nov 2009 17:56:15 -0500
- Subject: [commit] Windows interruptible semi-hosting
For baroque reasons, once you call the Windows read() function,
Control-C won't be processed until the next time you hit enter. We
have host-specific code that handles interrupts during select; so use
before we read from a file, call gdb_select and wait for it to be
ready.
Tested on arm-none-eabi (Windows and Linux hosts) and x86_64-linux;
checked in.
2009-11-13 Daniel Jacobowitz <dan@codesourcery.com>
* ui-file.c (stdio_file_read): Call gdb_select before read.
---
gdb/ui-file.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: gdb/ui-file.c
===================================================================
--- gdb/ui-file.c.orig 2009-08-14 00:51:55.000000000 -0700
+++ gdb/ui-file.c 2009-11-13 09:36:00.000000000 -0800
@@ -23,6 +23,7 @@
#include "defs.h"
#include "ui-file.h"
#include "gdb_string.h"
+#include "gdb_select.h"
#include <errno.h>
@@ -471,6 +472,19 @@ stdio_file_read (struct ui_file *file, c
if (stdio->magic != &stdio_file_magic)
internal_error (__FILE__, __LINE__,
_("stdio_file_read: bad magic number"));
+
+ /* For the benefit of Windows, call gdb_select before reading from
+ the file. Wait until at least one byte of data is available.
+ Control-C can interrupt gdb_select, but not read. */
+ {
+ int fd = fileno (stdio->file);
+ fd_set readfds;
+ FD_ZERO (&readfds);
+ FD_SET (fd, &readfds);
+ if (gdb_select (fd + 1, &readfds, NULL, NULL, NULL) == -1)
+ return -1;
+ }
+
return read (fileno (stdio->file), buf, length_buf);
}
--
Daniel Jacobowitz
CodeSourcery