aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-05-18 18:03:30 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-05-18 18:03:30 +0000
commited7319594583dffb825a9602afb95198207b9a0d (patch)
tree58affc9216f86e5ac6dae14b6dec1eaf716a1388 /gdb
parent967cff168cc01f56912a7ef9b4755c1502ad761c (diff)
downloadgdb-ed7319594583dffb825a9602afb95198207b9a0d.zip
gdb-ed7319594583dffb825a9602afb95198207b9a0d.tar.gz
gdb-ed7319594583dffb825a9602afb95198207b9a0d.tar.bz2
gdb/
* linux-nat.c (kill_callback): Use SIGKILL first. gdb/testsuite/ * gdb.base/kill-after-signal.c: New file. * gdb.base/kill-after-signal.exp: New file.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/linux-nat.c12
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/kill-after-signal.c37
-rw-r--r--gdb/testsuite/gdb.base/kill-after-signal.exp29
5 files changed, 87 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0538dd7..27c9271 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-18 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * linux-nat.c (kill_callback): Use SIGKILL first.
+
2011-05-18 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (print_it_exception): Avoid use of sprintf.
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 4c4db3b..7668e60 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3780,6 +3780,18 @@ linux_nat_wait (struct target_ops *ops,
static int
kill_callback (struct lwp_info *lp, void *data)
{
+ /* PTRACE_KILL may resume the inferior. Send SIGKILL first. */
+
+ errno = 0;
+ kill (GET_LWP (lp->ptid), SIGKILL);
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "KC: kill (SIGKILL) %s, 0, 0 (%s)\n",
+ target_pid_to_str (lp->ptid),
+ errno ? safe_strerror (errno) : "OK");
+
+ /* Some kernels ignore even SIGKILL for processes under ptrace. */
+
errno = 0;
ptrace (PTRACE_KILL, GET_LWP (lp->ptid), 0, 0);
if (debug_linux_nat)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 22f0fd4..974b302 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-18 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.base/kill-after-signal.c: New file.
+ * gdb.base/kill-after-signal.exp: New file.
+
2011-05-16 Pedro Alves <pedro@codesourcery.com>
* gdb.ada/start.exp: Call untested with the correct test filename.
diff --git a/gdb/testsuite/gdb.base/kill-after-signal.c b/gdb/testsuite/gdb.base/kill-after-signal.c
new file mode 100644
index 0000000..a1f0018
--- /dev/null
+++ b/gdb/testsuite/gdb.base/kill-after-signal.c
@@ -0,0 +1,37 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+
+void
+handler (int signo)
+{
+ sleep (600);
+ assert (0);
+}
+
+int
+main (void)
+{
+ signal (SIGUSR1, handler);
+ raise (SIGUSR1);
+ assert (0);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp
new file mode 100644
index 0000000..eecad2e
--- /dev/null
+++ b/gdb/testsuite/gdb.base/kill-after-signal.exp
@@ -0,0 +1,29 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set testfile "kill-after-signal"
+if [prepare_for_testing ${testfile}.exp ${testfile}] {
+ return -1
+}
+
+gdb_test "handle SIGUSR1 stop print pass" "SIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+.*"
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_test "continue" "Program received signal SIGUSR1, .*"
+gdb_test "stepi" "\r\nhandler .*"
+gdb_test "kill" "^y" "kill" "Kill the program being debugged\\? \\(y or n\\) $" "y"