aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2017-09-01 06:13:40 +0200
committerJan Kratochvil <jan.kratochvil@redhat.com>2017-09-01 06:14:43 +0200
commit5c811d30d12b6f7c6c6f4ce6d03408d987154548 (patch)
tree3e3bd715cfdbe30721b66cb2c7c76e95fd5a7613
parent1f0c13579f6833edc85b5399486edf95b4b9630e (diff)
downloadgdb-5c811d30d12b6f7c6c6f4ce6d03408d987154548.zip
gdb-5c811d30d12b6f7c6c6f4ce6d03408d987154548.tar.gz
gdb-5c811d30d12b6f7c6c6f4ce6d03408d987154548.tar.bz2
PR gdb/22046: Fix T-stopped detach regression on old Linux kernels
On <=RHEL6 hosts Fedora/RHEL GDB started to 'kill -STOP' all processes it detached. Even those not originally T-stopped. This is a Fedora-specific patch which is based on upstream GDB's PROC_STATE_STOPPED state. I believe (I did not verify) this patch did regress it: commit d617208bb06bd461b52ce041d89f7127e3044762 Author: Pedro Alves <palves@redhat.com> Date: Mon Jul 25 12:42:17 2016 +0100 linux-procfs: Introduce enum proc_state As originally there was strstr() but now there is strcmp() and so the missing trailing '\n' no longer matches. The Bug was found by Michal Kolar. Reproducibility: $ gdb -p $PID (gdb) quit $ ... Actual results: === RHEL6.9 x86_64 # scl enable devtoolset-7 bash RHEL6.9 x86_64 # which gdb /opt/rh/devtoolset-7/root/usr/bin/gdb RHEL6.9 x86_64 # ./testcase.sh 24737 pts/0 S+ 0:00 /bin/sleep 4 24737 pts/0 T+ 0:00 /bin/sleep 4 RHEL6.9 x86_64 # === Expected results: === RHEL6.9 x86_64 # which gdb /usr/bin/gdb RHEL6.9 x86_64 # ./testcase.sh 24708 pts/0 S+ 0:00 /bin/sleep 4 24708 pts/0 S+ 0:00 /bin/sleep 4 ./testcase.sh: line 20: kill: (24708) - No such process RHEL6.9 x86_64 # === gdb/ChangeLog 2017-09-01 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/22046 * nat/linux-procfs.c (parse_proc_status_state): Fix PROC_STATE_STOPPED detection.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/nat/linux-procfs.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9d153fa..44dfe5b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-01 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR gdb/22046
+ * nat/linux-procfs.c (parse_proc_status_state): Fix PROC_STATE_STOPPED
+ detection.
+
2017-08-31 Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0): Add entry mentioning new support
diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
index a12f622..cca35cb 100644
--- a/gdb/nat/linux-procfs.c
+++ b/gdb/nat/linux-procfs.c
@@ -104,10 +104,10 @@ parse_proc_status_state (const char *state)
return PROC_STATE_TRACING_STOP;
case 'T':
/* Before Linux 2.6.33, tracing stop used uppercase T. */
- if (strcmp (state, "T (tracing stop)") == 0)
- return PROC_STATE_TRACING_STOP;
- else
+ if (strcmp (state, "T (stopped)\n") == 0)
return PROC_STATE_STOPPED;
+ else /* "T (tracing stop)\n" */
+ return PROC_STATE_TRACING_STOP;
case 'X':
return PROC_STATE_DEAD;
case 'Z':