GNU Binutils with patches for OS216
Revision | 55e254b4a206ddad3fe1dda316e8a510f03bc30b (tree) |
---|---|
Zeit | 2005-03-29 04:10:24 |
Autor | Mark Mitchell <mark@code...> |
Commiter | Mark Mitchell |
* 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.
@@ -1,3 +1,15 @@ | ||
1 | +2005-03-28 Mark Mitchell <mark@codesourcery.com> | |
2 | + | |
3 | + * gdb/configure.ac: No tgetent on MinGW. | |
4 | + * gdb/event-loop.c (struct gdb_notifier): Add "handles" for Windows. | |
5 | + (create_file_handler): On Windows, update handles, rather than | |
6 | + check_masks and ready_masks. | |
7 | + (delete_file_handler): Likewise. | |
8 | + (gdb_wait_for_event): Use WaitForMultipleObjects, not select, on | |
9 | + Windows. | |
10 | + * gdb/event-top.c (gdb_setup_readline): Put console into | |
11 | + character-at-a-time mode under Windows. | |
12 | + | |
1 | 13 | 2005-03-25 Mark Mitchell <mark@codesourcery.com> |
2 | 14 | |
3 | 15 | * gdb/configure.ac: Link with -lws2_32 on mingw. |
@@ -8189,7 +8189,7 @@ case $host_os in | ||
8189 | 8189 | LIBS="../libtermcap/libtermcap.a $LIBS" |
8190 | 8190 | ac_cv_search_tgetent="../libtermcap/libtermcap.a" |
8191 | 8191 | fi ;; |
8192 | - go32* | *djgpp*) | |
8192 | + go32* | *djgpp* | *mingw32* ) | |
8193 | 8193 | ac_cv_search_tgetent="none required" |
8194 | 8194 | ;; |
8195 | 8195 | esac |
@@ -329,7 +329,7 @@ case $host_os in | ||
329 | 329 | LIBS="../libtermcap/libtermcap.a $LIBS" |
330 | 330 | ac_cv_search_tgetent="../libtermcap/libtermcap.a" |
331 | 331 | fi ;; |
332 | - go32* | *djgpp*) | |
332 | + go32* | *djgpp* | *mingw32* ) | |
333 | 333 | ac_cv_search_tgetent="none required" |
334 | 334 | ;; |
335 | 335 | esac |
@@ -133,6 +133,11 @@ event_queue; | ||
133 | 133 | |
134 | 134 | static unsigned char use_poll = USE_POLL; |
135 | 135 | |
136 | +#ifdef WINAPI | |
137 | +#include <windows.h> | |
138 | +#include <io.h> | |
139 | +#endif | |
140 | + | |
136 | 141 | static struct |
137 | 142 | { |
138 | 143 | /* Ptr to head of file handler list. */ |
@@ -146,15 +151,19 @@ static struct | ||
146 | 151 | int poll_timeout; |
147 | 152 | #endif |
148 | 153 | |
154 | +#ifdef WINAPI | |
155 | + HANDLE handles[MAXIMUM_WAIT_OBJECTS]; | |
156 | +#else | |
149 | 157 | /* Masks to be used in the next call to select. |
150 | 158 | Bits are set in response to calls to create_file_handler. */ |
151 | 159 | fd_set check_masks[3]; |
152 | 160 | |
153 | 161 | /* What file descriptors were found ready by select. */ |
154 | 162 | fd_set ready_masks[3]; |
155 | - | |
163 | +#endif | |
156 | 164 | /* Number of file descriptors to monitor. (for poll) */ |
157 | 165 | /* Number of valid bits (highest fd value + 1). (for select) */ |
166 | + /* Number of handles (for Windows). */ | |
158 | 167 | int num_fds; |
159 | 168 | |
160 | 169 | /* Time structure for calls to select(). */ |
@@ -524,6 +533,10 @@ create_file_handler (int fd, int mask, handler_func * proc, gdb_client_data clie | ||
524 | 533 | } |
525 | 534 | else |
526 | 535 | { |
536 | +#ifdef WINAPI | |
537 | + gdb_notifier.handles[gdb_notifier.num_fds++] | |
538 | + = (HANDLE) _get_osfhandle (fd); | |
539 | +#else | |
527 | 540 | if (mask & GDB_READABLE) |
528 | 541 | FD_SET (fd, &gdb_notifier.check_masks[0]); |
529 | 542 | else |
@@ -541,6 +554,7 @@ create_file_handler (int fd, int mask, handler_func * proc, gdb_client_data clie | ||
541 | 554 | |
542 | 555 | if (gdb_notifier.num_fds <= fd) |
543 | 556 | gdb_notifier.num_fds = fd + 1; |
557 | +#endif | |
544 | 558 | } |
545 | 559 | } |
546 | 560 |
@@ -602,6 +616,16 @@ delete_file_handler (int fd) | ||
602 | 616 | } |
603 | 617 | else |
604 | 618 | { |
619 | +#ifdef WINAPI | |
620 | + HANDLE h = (HANDLE) _get_osfhandle (fd); | |
621 | + for (i = 0; i < gdb_notifier.num_fds; ++i) | |
622 | + if (gdb_notifier.handles[i] == h) | |
623 | + { | |
624 | + gdb_notifier.handles[i] = | |
625 | + gdb_notifier.handles[gdb_notifier.num_fds--]; | |
626 | + break; | |
627 | + } | |
628 | +#else | |
605 | 629 | if (file_ptr->mask & GDB_READABLE) |
606 | 630 | FD_CLR (fd, &gdb_notifier.check_masks[0]); |
607 | 631 | if (file_ptr->mask & GDB_WRITABLE) |
@@ -623,6 +647,7 @@ delete_file_handler (int fd) | ||
623 | 647 | } |
624 | 648 | gdb_notifier.num_fds = i; |
625 | 649 | } |
650 | +#endif | |
626 | 651 | } |
627 | 652 | |
628 | 653 | /* Deactivate the file descriptor, by clearing its mask, |
@@ -737,7 +762,11 @@ gdb_wait_for_event (void) | ||
737 | 762 | { |
738 | 763 | file_handler *file_ptr; |
739 | 764 | gdb_event *file_event_ptr; |
765 | +#ifdef WINAPI | |
766 | + DWORD event = 0; | |
767 | +#else | |
740 | 768 | int num_found = 0; |
769 | +#endif | |
741 | 770 | int i; |
742 | 771 | |
743 | 772 | /* Make sure all output is done before getting another event. */ |
@@ -766,6 +795,16 @@ gdb_wait_for_event (void) | ||
766 | 795 | } |
767 | 796 | else |
768 | 797 | { |
798 | +#ifdef WINAPI | |
799 | + event | |
800 | + = WaitForMultipleObjects(gdb_notifier.num_fds, | |
801 | + gdb_notifier.handles, | |
802 | + FALSE, | |
803 | + gdb_notifier.timeout_valid | |
804 | + ? (gdb_notifier.select_timeout.tv_sec * 1000 | |
805 | + + gdb_notifier.select_timeout.tv_usec) | |
806 | + : INFINITE); | |
807 | +#else | |
769 | 808 | gdb_notifier.ready_masks[0] = gdb_notifier.check_masks[0]; |
770 | 809 | gdb_notifier.ready_masks[1] = gdb_notifier.check_masks[1]; |
771 | 810 | gdb_notifier.ready_masks[2] = gdb_notifier.check_masks[2]; |
@@ -786,6 +825,7 @@ gdb_wait_for_event (void) | ||
786 | 825 | if (errno != EINTR) |
787 | 826 | perror_with_name (("select")); |
788 | 827 | } |
828 | +#endif | |
789 | 829 | } |
790 | 830 | |
791 | 831 | /* Enqueue all detected file events. */ |
@@ -828,6 +868,20 @@ gdb_wait_for_event (void) | ||
828 | 868 | } |
829 | 869 | else |
830 | 870 | { |
871 | +#ifdef WINAPI | |
872 | + HANDLE h; | |
873 | + | |
874 | + h = gdb_notifier.handles[event - WAIT_OBJECT_0]; | |
875 | + file_ptr = gdb_notifier.first_file_handler; | |
876 | + while ((HANDLE) _get_osfhandle (file_ptr->fd) != h) | |
877 | + file_ptr = file_ptr->next_file; | |
878 | + if (file_ptr->ready_mask == 0) | |
879 | + { | |
880 | + file_event_ptr = create_file_event (file_ptr->fd); | |
881 | + async_queue_event (file_event_ptr, TAIL); | |
882 | + } | |
883 | + file_ptr->ready_mask = GDB_READABLE; | |
884 | +#else | |
831 | 885 | for (file_ptr = gdb_notifier.first_file_handler; |
832 | 886 | (file_ptr != NULL) && (num_found > 0); |
833 | 887 | file_ptr = file_ptr->next_file) |
@@ -856,6 +910,7 @@ gdb_wait_for_event (void) | ||
856 | 910 | } |
857 | 911 | file_ptr->ready_mask = mask; |
858 | 912 | } |
913 | +#endif | |
859 | 914 | } |
860 | 915 | return 0; |
861 | 916 | } |
@@ -40,6 +40,11 @@ | ||
40 | 40 | #include "readline/readline.h" |
41 | 41 | #include "readline/history.h" |
42 | 42 | |
43 | +#ifdef __MINGW32__ | |
44 | +#include <windows.h> | |
45 | +#include <io.h> | |
46 | +#endif | |
47 | + | |
43 | 48 | /* readline defines this. */ |
44 | 49 | #undef savestring |
45 | 50 |
@@ -1128,6 +1133,20 @@ gdb_setup_readline (void) | ||
1128 | 1133 | /* When a character is detected on instream by select or poll, |
1129 | 1134 | readline will be invoked via this callback function. */ |
1130 | 1135 | call_readline = rl_callback_read_char_wrapper; |
1136 | +#ifdef WINAPI | |
1137 | + /* Set the console to character-at-a-time (as opposed to | |
1138 | + line-at-a-time) mode. Otherwise, we will get only a single | |
1139 | + keyboard event for the entire line, and readline will not | |
1140 | + see each character as it arrives. */ | |
1141 | + { | |
1142 | + DWORD mode; | |
1143 | + HANDLE console_handle; | |
1144 | + console_handle = (HANDLE) _get_osfhandle (fileno (instream)); | |
1145 | + GetConsoleMode(console_handle, &mode); | |
1146 | + mode &= ~ENABLE_LINE_INPUT; | |
1147 | + SetConsoleMode(console_handle, mode); | |
1148 | + } | |
1149 | +#endif | |
1131 | 1150 | } |
1132 | 1151 | else |
1133 | 1152 | { |