From 89a5711c561ad1e9a435221bc056ecd86a1aa628 Mon Sep 17 00:00:00 2001 From: Don Breazeal Date: Fri, 19 Sep 2014 10:54:34 -0700 Subject: Refactor ptrace extended event status. This commit implements functions for identifying and extracting extended ptrace event information from a Linux wait status. These are just convenience functions intended to hide the ">> 16" used to extract the event from the wait status word, replacing the hard-coded shift with a more descriptive function call. This is preparatory work for implementation of follow-fork and detach-on-fork for extended-remote linux targets. gdb/ChangeLog: * 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. gdb/gdbserver/ChangeLog: * 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. --- --- gdb/gdbserver/ChangeLog | 7 +++++++ gdb/gdbserver/linux-low.c | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'gdb/gdbserver') diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index ec32f71..240554e 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2014-09-19 Don Breazeal + + * 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 * Makefile.in (CPPFLAGS): Define. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 705edde..8f0985a 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; -- cgit v1.1