aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/remote-utils.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2007-05-10 22:04:50 +0000
committerPedro Alves <palves@redhat.com>2007-05-10 22:04:50 +0000
commit7390519ea0a40c10c7f3d740cb29a6881446cc18 (patch)
tree9361f68ea7230c94d47489f0c0f830344b268f49 /gdb/gdbserver/remote-utils.c
parent34b34921087ce04e7a45cbb38a3b8af17b0c630a (diff)
downloadgdb-7390519ea0a40c10c7f3d740cb29a6881446cc18.zip
gdb-7390519ea0a40c10c7f3d740cb29a6881446cc18.tar.gz
gdb-7390519ea0a40c10c7f3d740cb29a6881446cc18.tar.bz2
* server.h (check_remote_input_interrupt_request): New function.
* remote_utils.c (INVALID_DESCRIPTOR): New define. (remote_desc): Initialize with INVALID_DESCRIPTOR. (input_interrupt): Expose on USE_WIN32API too. Fix whitespace. (check_remote_input_interrupt_request): New function. * server.h (check_remote_input_interrupt_request): Declare. * win32-low.(winapi_DebugBreakProcess, winapi_GenerateConsoleCtrlEvent): New typedefs. (get_child_debug_event): Lower Win32 debug event polling from 1 sec to 250 ms. (win32_wait): Check for remote interrupt request with check_remote_input_interrupt_request. (win32_request_interrupt): New function. (win32_target_op): Set request_interrupt to win32_request_interrupt.
Diffstat (limited to 'gdb/gdbserver/remote-utils.c')
-rw-r--r--gdb/gdbserver/remote-utils.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 3c0e5e4..505e37c 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -70,6 +70,12 @@
typedef int socklen_t;
#endif
+#if USE_WIN32API
+# define INVALID_DESCRIPTOR INVALID_SOCKET
+#else
+# define INVALID_DESCRIPTOR -1
+#endif
+
/* A cache entry for a successfully looked-up symbol. */
struct sym_cache
{
@@ -88,7 +94,7 @@ int all_symbols_looked_up;
int remote_debug = 0;
struct ui_file *gdb_stdlog;
-static int remote_desc;
+static int remote_desc = INVALID_DESCRIPTOR;
/* FIXME headerize? */
extern int using_threads;
@@ -588,8 +594,6 @@ putpkt (char *buf)
return putpkt_binary (buf, strlen (buf));
}
-#ifndef USE_WIN32API
-
/* Come here when we get an input interrupt from the remote side. This
interrupt should only be active while we are waiting for the child to do
something. About the only thing that should come through is a ^C, which
@@ -610,7 +614,7 @@ input_interrupt (int unused)
{
int cc;
char c = 0;
-
+
cc = read (remote_desc, &c, 1);
if (cc != 1 || c != '\003')
@@ -619,11 +623,23 @@ input_interrupt (int unused)
cc, c, c);
return;
}
-
+
(*the_target->request_interrupt) ();
}
}
-#endif
+
+/* Check if the remote side sent us an interrupt request (^C). */
+void
+check_remote_input_interrupt_request (void)
+{
+ /* This function may be called before establishing communications,
+ therefore we need to validate the remote descriptor. */
+
+ if (remote_desc == INVALID_DESCRIPTOR)
+ return;
+
+ input_interrupt (0);
+}
/* Asynchronous I/O support. SIGIO must be enabled when waiting, in order to
accept Control-C from the client, and must be disabled when talking to