aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorDon Breazeal <donb@codesourcery.com>2014-09-19 10:54:34 -0700
committerDon Breazeal <donb@codesourcery.com>2014-09-19 10:54:34 -0700
commit89a5711c561ad1e9a435221bc056ecd86a1aa628 (patch)
tree182adf2870d0e927e79e685205ea36c8bf40783e /gdb/linux-nat.c
parente00d879a2e9169759518dd419d19f1b3dcb6f709 (diff)
downloadgdb-89a5711c561ad1e9a435221bc056ecd86a1aa628.zip
gdb-89a5711c561ad1e9a435221bc056ecd86a1aa628.tar.gz
gdb-89a5711c561ad1e9a435221bc056ecd86a1aa628.tar.bz2
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. ---
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 5a82d23..0fe4b0b 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,