* linux-low.c (linux_wait): Unblock async I/O.
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-low.c
index 501bb581956697a9a51c1c740350bb1f79ad4c08..ea155160e366ab7a5e4e33730f35a4988c227016 100644 (file)
@@ -597,7 +597,7 @@ linux_wait_for_event (struct thread_info *child)
 
       /* If we were single-stepping, we definitely want to report the
         SIGTRAP.  The single-step operation has completed, so also
-         clear the stepping flag; in general this does not matter, 
+         clear the stepping flag; in general this does not matter,
         because the SIGTRAP will be reported to the client, which
         will give us a new action for this thread, but clear it for
         consistency anyway.  It's safe to clear the stepping flag
@@ -662,6 +662,7 @@ retry:
     }
 
   enable_async_io ();
+  unblock_async_io ();
   w = linux_wait_for_event (child);
   stop_all_processes ();
   disable_async_io ();
@@ -841,7 +842,7 @@ linux_resume_one_process (struct inferior_list_entry *entry,
 
   check_removed_breakpoint (process);
 
-  if (debug_threads && the_low_target.get_pc != NULL) 
+  if (debug_threads && the_low_target.get_pc != NULL)
     {
       fprintf (stderr, "  ");
       (long) (*the_low_target.get_pc) ();
@@ -1017,7 +1018,11 @@ linux_resume (struct thread_resume *resume_info)
   if (pending_flag)
     for_each_inferior (&all_threads, linux_queue_one_thread);
   else
-    for_each_inferior (&all_threads, linux_continue_one_thread);
+    {
+      block_async_io ();
+      enable_async_io ();
+      for_each_inferior (&all_threads, linux_continue_one_thread);
+    }
 }
 
 #ifdef HAVE_LINUX_USRREGS
@@ -1283,11 +1288,11 @@ linux_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
   /* Round starting address down to longword boundary.  */
   register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
   /* Round ending address up; get number of longwords that makes.  */
-  register int count 
-    = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) 
+  register int count
+    = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
       / sizeof (PTRACE_XFER_TYPE);
   /* Allocate buffer of that many longwords.  */
-  register PTRACE_XFER_TYPE *buffer 
+  register PTRACE_XFER_TYPE *buffer
     = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
 
   /* Read all the longwords */
@@ -1381,6 +1386,32 @@ linux_send_signal (int signum)
     kill (signal_pid, signum);
 }
 
+/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
+   to debugger memory starting at MYADDR.  */
+
+static int
+linux_read_auxv (CORE_ADDR offset, char *myaddr, unsigned int len)
+{
+  char filename[PATH_MAX];
+  int fd, n;
+
+  snprintf (filename, sizeof filename, "/proc/%d/auxv", inferior_pid);
+
+  fd = open (filename, O_RDONLY);
+  if (fd < 0)
+    return -1;
+
+  if (offset != (CORE_ADDR) 0
+      && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
+    n = -1;
+  else
+    n = read (fd, myaddr, len);
+
+  close (fd);
+
+  return n;
+}
+
 \f
 static struct target_ops linux_target_ops = {
   linux_create_inferior,
@@ -1396,6 +1427,7 @@ static struct target_ops linux_target_ops = {
   linux_write_memory,
   linux_look_up_symbols,
   linux_send_signal,
+  linux_read_auxv,
 };
 
 static void
This page took 0.038959 seconds and 4 git commands to generate.