diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 37577080dd8..f36732f9fde 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,17 @@
+2014-09-19  Don Breazeal  <donb@codesourcery.com>
+
+	* linux-nat.c (linux_handle_extended_wait): Call
+	linux_ptrace_get_extended_event.
+	(wait_lwp): Call linux_is_extended_waitstatus.
+	(linux_nat_filter_event): Call linux_ptrace_get_extended_event
+	and linux_is_extended_waitstatus.
+	* nat/linux-ptrace.c (linux_test_for_tracefork): Call
+	linux_ptrace_get_extended_event.
+	(linux_ptrace_get_extended_event): New function.
+	(linux_is_extended_waitstatus): New function.
+	* nat/linux-ptrace.h (linux_ptrace_get_extended_event)
+	(linux_is_extended_waitstatus): New declarations.
+
 2014-09-19  Yao Qi  <yao@codesourcery.com>
 
 	* dwarf2read.c (dwarf_decode_lines): Update declaration.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index ec32f7160ac..240554ef882 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2014-09-19  Don Breazeal  <donb@codesourcery.com>
+
+	* linux-low.c (handle_extended_wait): Call
+	linux_ptrace_get_extended_event.
+	(get_stop_pc, get_detach_signal, linux_low_filter_event): Call
+	linux_is_extended_waitstatus.
+
 2014-09-16  Joel Brobecker  <brobecker@adacore.com>
 
 	* Makefile.in (CPPFLAGS): Define.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 705edde4407..8f0985a1394 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -370,7 +370,7 @@ linux_add_process (int pid, int attached)
 static void
 handle_extended_wait (struct lwp_info *event_child, int wstat)
 {
-  int event = wstat >> 16;
+  int event = linux_ptrace_get_extended_event (wstat);
   struct thread_info *event_thr = get_lwp_thread (event_child);
   struct lwp_info *new_lwp;
 
@@ -512,7 +512,7 @@ get_stop_pc (struct lwp_info *lwp)
   if (WSTOPSIG (lwp->last_status) == SIGTRAP
       && !lwp->stepping
       && !lwp->stopped_by_watchpoint
-      && lwp->last_status >> 16 == 0)
+      && !linux_is_extended_waitstatus (lwp->last_status))
     stop_pc -= the_low_target.decr_pc_after_break;
 
   if (debug_threads)
@@ -1056,7 +1056,7 @@ get_detach_signal (struct thread_info *thread)
     }
 
   /* Extended wait statuses aren't real SIGTRAPs.  */
-  if (WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
+  if (WSTOPSIG (status) == SIGTRAP && linux_is_extended_waitstatus (status))
     {
       if (debug_threads)
 	debug_printf ("GPS: lwp %s had stopped with extended "
@@ -1869,7 +1869,7 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat)
     }
 
   if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SIGTRAP
-      && wstat >> 16 != 0)
+      && linux_is_extended_waitstatus (wstat))
     {
       handle_extended_wait (child, wstat);
       return NULL;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 5a82d2332df..0fe4b0bc352 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1996,7 +1996,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
 {
   int pid = ptid_get_lwp (lp->ptid);
   struct target_waitstatus *ourstatus = &lp->waitstatus;
-  int event = status >> 16;
+  int event = linux_ptrace_get_extended_event (status);
 
   if (event == PTRACE_EVENT_FORK || event == PTRACE_EVENT_VFORK
       || event == PTRACE_EVENT_CLONE)
@@ -2362,7 +2362,8 @@ wait_lwp (struct lwp_info *lp)
     }
 
   /* Handle GNU/Linux's extended waitstatus for trace events.  */
-  if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
+  if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP
+      && linux_is_extended_waitstatus (status))
     {
       if (debug_linux_nat)
 	fprintf_unfiltered (gdb_stdlog,
@@ -2921,6 +2922,7 @@ static struct lwp_info *
 linux_nat_filter_event (int lwpid, int status, int *new_pending_p)
 {
   struct lwp_info *lp;
+  int event = linux_ptrace_get_extended_event (status);
 
   *new_pending_p = 0;
 
@@ -2940,7 +2942,7 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p)
      thread changes its tid to the tgid.  */
 
   if (WIFSTOPPED (status) && lp == NULL
-      && (WSTOPSIG (status) == SIGTRAP && status >> 16 == PTRACE_EVENT_EXEC))
+      && (WSTOPSIG (status) == SIGTRAP && event == PTRACE_EVENT_EXEC))
     {
       /* A multi-thread exec after we had seen the leader exiting.  */
       if (debug_linux_nat)
@@ -2984,7 +2986,8 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p)
     }
 
   /* Handle GNU/Linux's extended waitstatus for trace events.  */
-  if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
+  if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP
+      && linux_is_extended_waitstatus (status))
     {
       if (debug_linux_nat)
 	fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 627551646ab..8bc3f1667ac 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -416,7 +416,7 @@ linux_test_for_tracefork (int child_pid)
 
   /* Check if we received a fork event notification.  */
   if (ret == child_pid && WIFSTOPPED (status)
-      && status >> 16 == PTRACE_EVENT_FORK)
+      && linux_ptrace_get_extended_event (status) == PTRACE_EVENT_FORK)
     {
       /* We did receive a fork event notification.  Make sure its PID
 	 is reported.  */
@@ -550,3 +550,19 @@ linux_ptrace_set_additional_flags (int flags)
 {
   additional_flags = flags;
 }
+
+/* Extract extended ptrace event from wait status.  */
+
+int
+linux_ptrace_get_extended_event (int wstat)
+{
+  return (wstat >> 16);
+}
+
+/* Determine whether wait status denotes an extended event.  */
+
+int
+linux_is_extended_waitstatus (int wstat)
+{
+  return (linux_ptrace_get_extended_event (wstat) != 0);
+}
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 41b31988839..31a77cd9587 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -92,5 +92,7 @@ extern int linux_supports_traceclone (void);
 extern int linux_supports_tracevforkdone (void);
 extern int linux_supports_tracesysgood (void);
 extern void linux_ptrace_set_additional_flags (int);
+extern int linux_ptrace_get_extended_event (int wstat);
+extern int linux_is_extended_waitstatus (int wstat);
 
 #endif /* COMMON_LINUX_PTRACE_H */