aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-03-28 19:10:24 +0000
committerMark Mitchell <mark@codesourcery.com>2005-03-28 19:10:24 +0000
commit55e254b4a206ddad3fe1dda316e8a510f03bc30b (patch)
treebc69c7e19608e9bc6282bf4e0af9180a6e433e74
parentd48c28c32168325ae42b799a67a6b325110b2905 (diff)
downloadgdb-55e254b4a206ddad3fe1dda316e8a510f03bc30b.zip
gdb-55e254b4a206ddad3fe1dda316e8a510f03bc30b.tar.gz
gdb-55e254b4a206ddad3fe1dda316e8a510f03bc30b.tar.bz2
* gdb/configure.ac: No tgetent on MinGW.
* gdb/event-loop.c (struct gdb_notifier): Add "handles" for Windows. (create_file_handler): On Windows, update handles, rather than check_masks and ready_masks. (delete_file_handler): Likewise. (gdb_wait_for_event): Use WaitForMultipleObjects, not select, on Windows. * gdb/event-top.c (gdb_setup_readline): Put console into character-at-a-time mode under Windows.
-rw-r--r--ChangeLog.csl12
-rwxr-xr-xgdb/configure2
-rw-r--r--gdb/configure.ac2
-rw-r--r--gdb/event-loop.c57
-rw-r--r--gdb/event-top.c19
5 files changed, 89 insertions, 3 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 2199856..cc0d3ef 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,15 @@
+2005-03-28 Mark Mitchell <mark@codesourcery.com>
+
+ * gdb/configure.ac: No tgetent on MinGW.
+ * gdb/event-loop.c (struct gdb_notifier): Add "handles" for Windows.
+ (create_file_handler): On Windows, update handles, rather than
+ check_masks and ready_masks.
+ (delete_file_handler): Likewise.
+ (gdb_wait_for_event): Use WaitForMultipleObjects, not select, on
+ Windows.
+ * gdb/event-top.c (gdb_setup_readline): Put console into
+ character-at-a-time mode under Windows.
+
2005-03-25 Mark Mitchell <mark@codesourcery.com>
* gdb/configure.ac: Link with -lws2_32 on mingw.
diff --git a/gdb/configure b/gdb/configure
index fa00f77..e8e3700 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -8189,7 +8189,7 @@ case $host_os in
LIBS="../libtermcap/libtermcap.a $LIBS"
ac_cv_search_tgetent="../libtermcap/libtermcap.a"
fi ;;
- go32* | *djgpp*)
+ go32* | *djgpp* | *mingw32* )
ac_cv_search_tgetent="none required"
;;
esac
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 146f0e8..7b2883f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -329,7 +329,7 @@ case $host_os in
LIBS="../libtermcap/libtermcap.a $LIBS"
ac_cv_search_tgetent="../libtermcap/libtermcap.a"
fi ;;
- go32* | *djgpp*)
+ go32* | *djgpp* | *mingw32* )
ac_cv_search_tgetent="none required"
;;
esac
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index e4b09f4..46112f6 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -133,6 +133,11 @@ event_queue;
static unsigned char use_poll = USE_POLL;
+#ifdef WINAPI
+#include <windows.h>
+#include <io.h>
+#endif
+
static struct
{
/* Ptr to head of file handler list. */
@@ -146,15 +151,19 @@ static struct
int poll_timeout;
#endif
+#ifdef WINAPI
+ HANDLE handles[MAXIMUM_WAIT_OBJECTS];
+#else
/* Masks to be used in the next call to select.
Bits are set in response to calls to create_file_handler. */
fd_set check_masks[3];
/* What file descriptors were found ready by select. */
fd_set ready_masks[3];
-
+#endif
/* Number of file descriptors to monitor. (for poll) */
/* Number of valid bits (highest fd value + 1). (for select) */
+ /* Number of handles (for Windows). */
int num_fds;
/* Time structure for calls to select(). */
@@ -524,6 +533,10 @@ create_file_handler (int fd, int mask, handler_func * proc, gdb_client_data clie
}
else
{
+#ifdef WINAPI
+ gdb_notifier.handles[gdb_notifier.num_fds++]
+ = (HANDLE) _get_osfhandle (fd);
+#else
if (mask & GDB_READABLE)
FD_SET (fd, &gdb_notifier.check_masks[0]);
else
@@ -541,6 +554,7 @@ create_file_handler (int fd, int mask, handler_func * proc, gdb_client_data clie
if (gdb_notifier.num_fds <= fd)
gdb_notifier.num_fds = fd + 1;
+#endif
}
}
@@ -602,6 +616,16 @@ delete_file_handler (int fd)
}
else
{
+#ifdef WINAPI
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ for (i = 0; i < gdb_notifier.num_fds; ++i)
+ if (gdb_notifier.handles[i] == h)
+ {
+ gdb_notifier.handles[i] =
+ gdb_notifier.handles[gdb_notifier.num_fds--];
+ break;
+ }
+#else
if (file_ptr->mask & GDB_READABLE)
FD_CLR (fd, &gdb_notifier.check_masks[0]);
if (file_ptr->mask & GDB_WRITABLE)
@@ -623,6 +647,7 @@ delete_file_handler (int fd)
}
gdb_notifier.num_fds = i;
}
+#endif
}
/* Deactivate the file descriptor, by clearing its mask,
@@ -737,7 +762,11 @@ gdb_wait_for_event (void)
{
file_handler *file_ptr;
gdb_event *file_event_ptr;
+#ifdef WINAPI
+ DWORD event = 0;
+#else
int num_found = 0;
+#endif
int i;
/* Make sure all output is done before getting another event. */
@@ -766,6 +795,16 @@ gdb_wait_for_event (void)
}
else
{
+#ifdef WINAPI
+ event
+ = WaitForMultipleObjects(gdb_notifier.num_fds,
+ gdb_notifier.handles,
+ FALSE,
+ gdb_notifier.timeout_valid
+ ? (gdb_notifier.select_timeout.tv_sec * 1000
+ + gdb_notifier.select_timeout.tv_usec)
+ : INFINITE);
+#else
gdb_notifier.ready_masks[0] = gdb_notifier.check_masks[0];
gdb_notifier.ready_masks[1] = gdb_notifier.check_masks[1];
gdb_notifier.ready_masks[2] = gdb_notifier.check_masks[2];
@@ -786,6 +825,7 @@ gdb_wait_for_event (void)
if (errno != EINTR)
perror_with_name (("select"));
}
+#endif
}
/* Enqueue all detected file events. */
@@ -828,6 +868,20 @@ gdb_wait_for_event (void)
}
else
{
+#ifdef WINAPI
+ HANDLE h;
+
+ h = gdb_notifier.handles[event - WAIT_OBJECT_0];
+ file_ptr = gdb_notifier.first_file_handler;
+ while ((HANDLE) _get_osfhandle (file_ptr->fd) != h)
+ file_ptr = file_ptr->next_file;
+ if (file_ptr->ready_mask == 0)
+ {
+ file_event_ptr = create_file_event (file_ptr->fd);
+ async_queue_event (file_event_ptr, TAIL);
+ }
+ file_ptr->ready_mask = GDB_READABLE;
+#else
for (file_ptr = gdb_notifier.first_file_handler;
(file_ptr != NULL) && (num_found > 0);
file_ptr = file_ptr->next_file)
@@ -856,6 +910,7 @@ gdb_wait_for_event (void)
}
file_ptr->ready_mask = mask;
}
+#endif
}
return 0;
}
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 4614d4d..f65c98b 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -40,6 +40,11 @@
#include "readline/readline.h"
#include "readline/history.h"
+#ifdef __MINGW32__
+#include <windows.h>
+#include <io.h>
+#endif
+
/* readline defines this. */
#undef savestring
@@ -1128,6 +1133,20 @@ gdb_setup_readline (void)
/* When a character is detected on instream by select or poll,
readline will be invoked via this callback function. */
call_readline = rl_callback_read_char_wrapper;
+#ifdef WINAPI
+ /* Set the console to character-at-a-time (as opposed to
+ line-at-a-time) mode. Otherwise, we will get only a single
+ keyboard event for the entire line, and readline will not
+ see each character as it arrives. */
+ {
+ DWORD mode;
+ HANDLE console_handle;
+ console_handle = (HANDLE) _get_osfhandle (fileno (instream));
+ GetConsoleMode(console_handle, &mode);
+ mode &= ~ENABLE_LINE_INPUT;
+ SetConsoleMode(console_handle, mode);
+ }
+#endif
}
else
{