Restore original GDB prompt in define.exp
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-low.c
index 4b1a211ab7a08e10e901c8c4a930de9f06c98b5a..3113017ae67837aa7a5de3097b4f7224d1dee82a 100644 (file)
 #include "server.h"
 #include "linux-low.h"
 #include "nat/linux-osdata.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "tdesc.h"
-#include "common/rsp-low.h"
-#include "common/signals-state-save-restore.h"
+#include "gdbsupport/rsp-low.h"
+#include "gdbsupport/signals-state-save-restore.h"
 #include "nat/linux-nat.h"
 #include "nat/linux-waitpid.h"
-#include "common/gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #include "nat/gdb_ptrace.h"
 #include "nat/linux-ptrace.h"
 #include "nat/linux-procfs.h"
 #include <sys/stat.h>
 #include <sys/vfs.h>
 #include <sys/uio.h>
-#include "common/filestuff.h"
+#include "gdbsupport/filestuff.h"
 #include "tracepoint.h"
 #include "hostio.h"
 #include <inttypes.h>
-#include "common/common-inferior.h"
+#include "gdbsupport/common-inferior.h"
 #include "nat/fork-inferior.h"
-#include "common/environ.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/environ.h"
+#include "gdbsupport/scoped_restore.h"
 #ifndef ELFMAG0
 /* Don't include <linux/elf.h> here.  If it got included by gdb_proc_service.h
    then ELFMAG0 will have been defined.  If it didn't get included by
 
 #ifdef HAVE_LINUX_BTRACE
 # include "nat/linux-btrace.h"
-# include "common/btrace-common.h"
+# include "gdbsupport/btrace-common.h"
 #endif
 
 #ifndef HAVE_ELF32_AUXV_T
@@ -1543,7 +1543,7 @@ linux_detach_one_lwp (struct lwp_info *lwp)
   catch (const gdb_exception_error &ex)
     {
       if (!check_ptrace_stopped_lwp_gone (lwp))
-       throw_exception (ex);
+       throw;
     }
 
   lwpid = lwpid_of (thread);
@@ -2828,7 +2828,6 @@ linux_wait_for_event (ptid_t ptid, int *wstatp, int options)
 static void
 select_event_lwp (struct lwp_info **orig_lp)
 {
-  int random_selector;
   struct thread_info *event_thread = NULL;
 
   /* In all-stop, give preference to the LWP that is being
@@ -2862,39 +2861,13 @@ select_event_lwp (struct lwp_info **orig_lp)
       /* No single-stepping LWP.  Select one at random, out of those
          which have had events.  */
 
-      /* First see how many events we have.  */
-      int num_events = 0;
-      for_each_thread ([&] (thread_info *thread)
-       {
-         lwp_info *lp = get_thread_lwp (thread);
-
-         /* Count only resumed LWPs that have an event pending. */
-         if (thread->last_status.kind == TARGET_WAITKIND_IGNORE
-             && lp->status_pending_p)
-           num_events++;
-       });
-      gdb_assert (num_events > 0);
-
-      /* Now randomly pick a LWP out of those that have had
-        events.  */
-      random_selector = (int)
-       ((num_events * (double) rand ()) / (RAND_MAX + 1.0));
-
-      if (debug_threads && num_events > 1)
-       debug_printf ("SEL: Found %d SIGTRAP events, selecting #%d\n",
-                     num_events, random_selector);
-
-      event_thread = find_thread ([&] (thread_info *thread)
+      event_thread = find_thread_in_random ([&] (thread_info *thread)
        {
          lwp_info *lp = get_thread_lwp (thread);
 
-         /* Select only resumed LWPs that have an event pending.  */
-         if (thread->last_status.kind == TARGET_WAITKIND_IGNORE
-             && lp->status_pending_p)
-           if (random_selector-- == 0)
-             return true;
-
-         return false;
+         /* Only resumed LWPs that have an event pending. */
+         return (thread->last_status.kind == TARGET_WAITKIND_IGNORE
+                 && lp->status_pending_p);
        });
     }
 
@@ -4514,7 +4487,7 @@ linux_resume_one_lwp (struct lwp_info *lwp,
   catch (const gdb_exception_error &ex)
     {
       if (!check_ptrace_stopped_lwp_gone (lwp))
-       throw_exception (ex);
+       throw;
     }
 }
 
@@ -6212,10 +6185,9 @@ sigchld_handler (int signo)
     {
       do
        {
-         /* fprintf is not async-signal-safe, so call write
-            directly.  */
-         if (write (2, "sigchld_handler\n",
-                    sizeof ("sigchld_handler\n") - 1) < 0)
+         /* Use the async signal safe debug function.  */
+         if (debug_write ("sigchld_handler\n",
+                          sizeof ("sigchld_handler\n") - 1) < 0)
            break; /* just ignore */
        } while (0);
     }
@@ -7217,7 +7189,7 @@ linux_low_encode_raw (struct buffer *buffer, const gdb_byte *data,
   if (size == 0)
     return;
 
-  /* We use hex encoding - see common/rsp-low.h.  */
+  /* We use hex encoding - see gdbsupport/rsp-low.h.  */
   buffer_grow_str (buffer, "<raw>\n");
 
   while (size-- > 0)
This page took 0.025978 seconds and 4 git commands to generate.