aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/gdbserver/ChangeLog15
-rw-r--r--gdb/gdbserver/linux-low.c9
-rw-r--r--gdb/gdbserver/remote-utils.c26
-rw-r--r--gdb/gdbserver/server.c35
-rw-r--r--gdb/gdbserver/server.h3
-rw-r--r--gdb/gdbserver/spu-low.c8
6 files changed, 48 insertions, 48 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 0fbf9fd..5f331b7 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,18 @@
+2007-12-06 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * linux-low.c (linux_wait, linux_resume): Do not handle async I/O.
+ * remote-utils.c (remote_open): Do not call disable_async_io.
+ (block_async_io): Delete.
+ (unblock_async_io): Make static.
+ (initialize_async_io): New.
+ * server.c (handle_v_cont): Handle async I/O here.
+ (myresume): Likewise. Move other common resume tasks here...
+ (main): ... from here. Call initialize_async_io. Disable async
+ I/O before the main loop.
+ * server.h (initialize_async_io): Declare.
+ (block_async_io, unblock_async_io): Delete prototypes.
+ * spu-low.c (spu_resume, spu_wait): Do not handle async I/O here.
+
2007-12-06 Mick Davis <mickd@goanna.iinet.net.au>
* remote-utils.c (readchar): Allow binary data in received messages.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c88c0c3..b5a0567 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -897,11 +897,8 @@ retry:
}
}
- enable_async_io ();
- unblock_async_io ();
w = linux_wait_for_event (child);
stop_all_processes ();
- disable_async_io ();
if (must_set_ptrace_flags)
{
@@ -1313,11 +1310,7 @@ linux_resume (struct thread_resume *resume_info)
if (pending_flag)
for_each_inferior (&all_threads, linux_queue_one_thread);
else
- {
- block_async_io ();
- enable_async_io ();
- for_each_inferior (&all_threads, linux_continue_one_thread);
- }
+ for_each_inferior (&all_threads, linux_continue_one_thread);
}
#ifdef HAVE_LINUX_USRREGS
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 593c7af..e82c967 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -275,7 +275,6 @@ remote_open (char *name)
fcntl (remote_desc, F_SETOWN, getpid ());
#endif
#endif
- disable_async_io ();
}
void
@@ -645,22 +644,12 @@ check_remote_input_interrupt_request (void)
accept Control-C from the client, and must be disabled when talking to
the client. */
-void
-block_async_io (void)
-{
-#ifndef USE_WIN32API
- sigset_t sigio_set;
- sigemptyset (&sigio_set);
- sigaddset (&sigio_set, SIGIO);
- sigprocmask (SIG_BLOCK, &sigio_set, NULL);
-#endif
-}
-
-void
+static void
unblock_async_io (void)
{
#ifndef USE_WIN32API
sigset_t sigio_set;
+
sigemptyset (&sigio_set);
sigaddset (&sigio_set, SIGIO);
sigprocmask (SIG_UNBLOCK, &sigio_set, NULL);
@@ -696,6 +685,17 @@ disable_async_io (void)
async_io_enabled = 0;
}
+void
+initialize_async_io (void)
+{
+ /* Make sure that async I/O starts disabled. */
+ async_io_enabled = 1;
+ disable_async_io ();
+
+ /* Make sure the signal is unblocked. */
+ unblock_async_io ();
+}
+
/* Returns next char from remote GDB. -1 if error. */
static int
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 3905e9a..a47d1d3 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -756,12 +756,14 @@ handle_v_cont (char *own_buf, char *status, int *signal)
cont_thread = -1;
set_desired_inferior (0);
+ enable_async_io ();
(*the_target->resume) (resume_info);
free (resume_info);
*signal = mywait (status, 1);
prepare_resume_reply (own_buf, *status, *signal);
+ disable_async_io ();
return;
err:
@@ -798,10 +800,13 @@ handle_v_requests (char *own_buf, char *status, int *signal,
}
void
-myresume (int step, int sig)
+myresume (int step, int *signalp, char *statusp)
{
struct thread_resume resume_info[2];
int n = 0;
+ int sig = *signalp;
+
+ set_desired_inferior (0);
if (step || sig || (cont_thread != 0 && cont_thread != -1))
{
@@ -817,7 +822,11 @@ myresume (int step, int sig)
resume_info[n].sig = 0;
resume_info[n].leave_stopped = (cont_thread != 0 && cont_thread != -1);
+ enable_async_io ();
(*the_target->resume) (resume_info);
+ *signalp = mywait (statusp, 1);
+ prepare_resume_reply (own_buf, *statusp, *signalp);
+ disable_async_io ();
}
static int attached;
@@ -895,6 +904,7 @@ main (int argc, char *argv[])
exit (1);
}
+ initialize_async_io ();
initialize_low ();
own_buf = malloc (PBUFSIZ + 1);
@@ -946,6 +956,7 @@ main (int argc, char *argv[])
restart:
setjmp (toplevel);
+ disable_async_io ();
while (1)
{
unsigned char sig;
@@ -1073,10 +1084,7 @@ main (int argc, char *argv[])
signal = target_signal_to_host (sig);
else
signal = 0;
- set_desired_inferior (0);
- myresume (0, signal);
- signal = mywait (&status, 1);
- prepare_resume_reply (own_buf, status, signal);
+ myresume (0, &signal, &status);
break;
case 'S':
convert_ascii_to_int (own_buf + 1, &sig, 1);
@@ -1084,22 +1092,15 @@ main (int argc, char *argv[])
signal = target_signal_to_host (sig);
else
signal = 0;
- set_desired_inferior (0);
- myresume (1, signal);
- signal = mywait (&status, 1);
- prepare_resume_reply (own_buf, status, signal);
+ myresume (1, &signal, &status);
break;
case 'c':
- set_desired_inferior (0);
- myresume (0, 0);
- signal = mywait (&status, 1);
- prepare_resume_reply (own_buf, status, signal);
+ signal = 0;
+ myresume (0, &signal, &status);
break;
case 's':
- set_desired_inferior (0);
- myresume (1, 0);
- signal = mywait (&status, 1);
- prepare_resume_reply (own_buf, status, signal);
+ signal = 0;
+ myresume (1, &signal, &status);
break;
case 'Z':
{
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 54ba614..8d7a1a8 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -171,10 +171,9 @@ void remote_open (char *name);
void remote_close (void);
void write_ok (char *buf);
void write_enn (char *buf);
+void initialize_async_io (void);
void enable_async_io (void);
void disable_async_io (void);
-void unblock_async_io (void);
-void block_async_io (void);
void check_remote_input_interrupt_request (void);
void convert_ascii_to_int (char *from, unsigned char *to, int n);
void convert_int_to_ascii (unsigned char *from, char *to, int n);
diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c
index a8f7df3..f5f1d20 100644
--- a/gdb/gdbserver/spu-low.c
+++ b/gdb/gdbserver/spu-low.c
@@ -348,9 +348,6 @@ spu_resume (struct thread_resume *resume_info)
&& resume_info->thread != current_tid)
resume_info++;
- block_async_io ();
- enable_async_io ();
-
if (resume_info->leave_stopped)
return;
@@ -375,9 +372,6 @@ spu_wait (char *status)
int w;
int ret;
- enable_async_io ();
- unblock_async_io ();
-
while (1)
{
ret = waitpid (tid, &w, WNOHANG | __WALL | __WNOTHREAD);
@@ -407,8 +401,6 @@ spu_wait (char *status)
}
}
- disable_async_io ();
-
if (WIFEXITED (w))
{
fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));