Don't run personality syscall at configure time; don't check it at all
[deliverable/binutils-gdb.git] / gdbserver / linux-low.cc
index db3620e0f6e989bbd08030f770dfc335fcb85a73..9debe894eeb2b95dbf5b7f86b4f9188920a68a01 100644 (file)
@@ -1,5 +1,5 @@
 /* Low level interface to ptrace, for the remote server for GDB.
-   Copyright (C) 1995-2020 Free Software Foundation, Inc.
+   Copyright (C) 1995-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #endif
 #include "nat/linux-namespaces.h"
 
-#ifdef HAVE_PERSONALITY
-# include <sys/personality.h>
-# if !HAVE_DECL_ADDR_NO_RANDOMIZE
-#  define ADDR_NO_RANDOMIZE 0x0040000
-# endif
-#endif
-
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
 #endif
@@ -253,7 +246,7 @@ enum stopping_threads_kind
   };
 
 /* This is set while stop_all_lwps is in effect.  */
-enum stopping_threads_kind stopping_threads = NOT_STOPPING_THREADS;
+static stopping_threads_kind stopping_threads = NOT_STOPPING_THREADS;
 
 /* FIXME make into a target method?  */
 int using_threads = 1;
@@ -272,7 +265,7 @@ static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
 
 /* When the event-loop is doing a step-over, this points at the thread
    being stepped.  */
-ptid_t step_over_bkpt;
+static ptid_t step_over_bkpt;
 
 bool
 linux_process_target::low_supports_breakpoints ()
@@ -2243,7 +2236,7 @@ linux_low_ptrace_options (int attached)
   return options;
 }
 
-lwp_info *
+void
 linux_process_target::filter_event (int lwpid, int wstat)
 {
   client_state &cs = get_client_state ();
@@ -2292,10 +2285,10 @@ linux_process_target::filter_event (int lwpid, int wstat)
   if (child == NULL && WIFSTOPPED (wstat))
     {
       add_to_pid_list (&stopped_pids, lwpid, wstat);
-      return NULL;
+      return;
     }
   else if (child == NULL)
-    return NULL;
+    return;
 
   thread = get_lwp_thread (child);
 
@@ -2325,12 +2318,12 @@ linux_process_target::filter_event (int lwpid, int wstat)
             report this one right now.  Leave the status pending for
             the next time we're able to report it.  */
          mark_lwp_dead (child, wstat);
-         return child;
+         return;
        }
       else
        {
          delete_lwp (child);
-         return NULL;
+         return;
        }
     }
 
@@ -2358,7 +2351,7 @@ linux_process_target::filter_event (int lwpid, int wstat)
                 the first instruction.  */
              child->status_pending_p = 1;
              child->status_pending = wstat;
-             return child;
+             return;
            }
        }
     }
@@ -2397,7 +2390,7 @@ linux_process_target::filter_event (int lwpid, int wstat)
        {
          /* The event has been handled, so just return without
             reporting it.  */
-         return NULL;
+         return;
        }
     }
 
@@ -2433,7 +2426,7 @@ linux_process_target::filter_event (int lwpid, int wstat)
            debug_printf ("LLW: SIGSTOP caught for %s "
                          "while stopping threads.\n",
                          target_pid_to_str (ptid_of (thread)));
-         return NULL;
+         return;
        }
       else
        {
@@ -2444,13 +2437,13 @@ linux_process_target::filter_event (int lwpid, int wstat)
                          target_pid_to_str (ptid_of (thread)));
 
          resume_one_lwp (child, child->stepping, 0, NULL);
-         return NULL;
+         return;
        }
     }
 
   child->status_pending_p = 1;
   child->status_pending = wstat;
-  return child;
+  return;
 }
 
 bool
@@ -4695,7 +4688,34 @@ linux_process_target::complete_ongoing_step_over ()
 
       lwp = find_lwp_pid (step_over_bkpt);
       if (lwp != NULL)
-       finish_step_over (lwp);
+       {
+         finish_step_over (lwp);
+
+         /* If we got our step SIGTRAP, don't leave it pending,
+            otherwise we would report it to GDB as a spurious
+            SIGTRAP.  */
+         gdb_assert (lwp->status_pending_p);
+         if (WIFSTOPPED (lwp->status_pending)
+             && WSTOPSIG (lwp->status_pending) == SIGTRAP)
+           {
+             thread_info *thread = get_lwp_thread (lwp);
+             if (thread->last_resume_kind != resume_step)
+               {
+                 if (debug_threads)
+                   debug_printf ("detach: discard step-over SIGTRAP\n");
+
+                 lwp->status_pending_p = 0;
+                 lwp->status_pending = 0;
+                 resume_one_lwp (lwp, lwp->stepping, 0, NULL);
+               }
+             else
+               {
+                 if (debug_threads)
+                   debug_printf ("detach: resume_step, "
+                                 "not discarding step-over SIGTRAP\n");
+               }
+           }
+       }
       step_over_bkpt = null_ptid;
       unsuspend_all_lwps (lwp);
     }
@@ -6204,11 +6224,7 @@ linux_process_target::core_of_thread (ptid_t ptid)
 bool
 linux_process_target::supports_disable_randomization ()
 {
-#ifdef HAVE_PERSONALITY
   return true;
-#else
-  return false;
-#endif
 }
 
 bool
@@ -6238,7 +6254,7 @@ linux_process_target::supports_pid_to_exec_file ()
   return true;
 }
 
-char *
+const char *
 linux_process_target::pid_to_exec_file (int pid)
 {
   return linux_proc_pid_to_exec_file (pid);
This page took 0.043149 seconds and 4 git commands to generate.