# HG changeset patch # Parent ba9899dff4a02b0de8cd73acc977a524b3921581 Interrupt not functional in Eclipse/CDT on Solaris (PR gdb/8527) diff --git a/gdb/procfs.c b/gdb/procfs.c --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -909,7 +909,12 @@ proc_wait_for_stop (procinfo *pi) procfs_ctl_t cmd = PCWSTOP; + set_sigint_trap (); + win = (write (pi->ctl_fd, (char *) &cmd, sizeof (cmd)) == sizeof (cmd)); + + clear_sigint_trap (); + /* We been runnin' and we stopped -- need to update status. */ pi->status_valid = 0; diff --git a/gdb/testsuite/gdb.base/signal-no-ctty.c b/gdb/testsuite/gdb.base/signal-no-ctty.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/signal-no-ctty.c @@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2018 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 . */ + +#include + +int main() +{ + /* Detach from controlling terminal. */ + if (setpgrp () == (pid_t) -1) + return 1; + + /* Don't let the test case run forever. */ + alarm (60); + + for (;;) + ; +} diff --git a/gdb/testsuite/gdb.base/signal-no-ctty.exp b/gdb/testsuite/gdb.base/signal-no-ctty.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/signal-no-ctty.exp @@ -0,0 +1,71 @@ +# Copyright 2013-2018 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 . + +if [target_info exists gdb,nosignals] { + verbose "Skipping signal-no-ctty.exp because of nosignals." + continue +} + +# This test requires sending ^C to interrupt the running target. +if [target_info exists gdb,nointerrupts] { + verbose "Skipping signal-no-ctty.exp because of nointerrupts." + return +} + +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +# Wait a bit and stop the target with ctrl-c. +proc do_test {} { + global binfile + + # For this to work we must be sure to consume the "Continuing." + # message first, or GDB's signal handler may not be in place. + after 500 {send_gdb "\003"} + gdb_test "" "(Program|Thread .*) received signal SIGINT.*" "stop with control-c" +} + +# With native debugging and "run" (with job control), the ctrl-c always +# reaches the inferior, not gdb. With remote debugging, the ctrl-c reaches +# GDB first. +with_test_prefix "run" { + clean_restart $binfile + + gdb_run_cmd + + do_test +} + +# With "attach" however, even with native debugging, the ctrl-c always +# reaches GDB first. Test that as well. +with_test_prefix "attach" { + if {[can_spawn_for_attach]} { + clean_restart $binfile + + set test_spawn_id [spawn_wait_for_attach $binfile] + set testpid [spawn_id_get_pid $test_spawn_id] + + gdb_test "attach $testpid" "Attaching to.*process $testpid.*libc.*" "attach" + + send_gdb "continue\n" + + do_test + + kill_wait_spawned_process $test_spawn_id + } +}