gdb/ChangeLog 2016-06-04 Jan Kratochvil * nat/linux-procfs.c (linux_proc_pid_has_state): Add parameter state2. (linux_proc_pid_is_stopped): Update caller. (linux_proc_pid_is_trace_stopped_nowarn): Add 't (tracing stop)'. (linux_proc_pid_is_zombie_maybe_warn): Update caller. --- a/gdb/nat/linux-procfs.c +++ b/gdb/nat/linux-procfs.c @@ -129,17 +129,20 @@ linux_proc_pid_is_gone (pid_t pid) } } -/* Return non-zero if 'State' of /proc/PID/status contains STATE. If - WARN, warn on failure to open the /proc file. */ +/* Return non-zero if 'State' of /proc/PID/status contains STATE or STATE2. + STATE2 can be NULL. If WARN, warn on failure to open the /proc file. */ static int -linux_proc_pid_has_state (pid_t pid, const char *state, int warn) +linux_proc_pid_has_state (pid_t pid, const char *state, const char *state2, + int warn) { char buffer[100]; int have_state; have_state = linux_proc_pid_get_state (pid, buffer, sizeof buffer, warn); - return (have_state > 0 && strstr (buffer, state) != NULL); + return (have_state > 0 + && (strstr (buffer, state) != NULL + || (state2 != NULL && strstr (buffer, state2) != NULL))); } /* Detect `T (stopped)' in `/proc/PID/status'. @@ -148,16 +151,18 @@ linux_proc_pid_has_state (pid_t pid, const char *state, int warn) int linux_proc_pid_is_stopped (pid_t pid) { - return linux_proc_pid_has_state (pid, "T (stopped)", 1); + return linux_proc_pid_has_state (pid, "T (stopped)", NULL, 1); } -/* Detect `T (tracing stop)' in `/proc/PID/status'. - Other states including `T (stopped)' are reported as false. */ +/* Detect `t (tracing stop)' or `T (tracing stop)' (present in older + kernels) in `/proc/PID/status'. Other states including `T (stopped)' + are reported as false. */ int linux_proc_pid_is_trace_stopped_nowarn (pid_t pid) { - return linux_proc_pid_has_state (pid, "T (tracing stop)", 1); + return linux_proc_pid_has_state (pid, "t (tracing stop)", "T (tracing stop)", + 1); } /* Return non-zero if PID is a zombie. If WARN, warn on failure to @@ -166,7 +171,7 @@ linux_proc_pid_is_trace_stopped_nowarn (pid_t pid) static int linux_proc_pid_is_zombie_maybe_warn (pid_t pid, int warn) { - return linux_proc_pid_has_state (pid, "Z (zombie)", warn); + return linux_proc_pid_has_state (pid, "Z (zombie)", NULL, warn); } /* See linux-procfs.h declaration. */