diff options
author | Andrew Cagney <cagney@redhat.com> | 2005-01-24 22:00:59 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2005-01-24 22:00:59 +0000 |
commit | 9d799f85e0e1acb6a49a6b7428d3845d8dba9588 (patch) | |
tree | 910568d780f2321c075edcf19424ab6044cd45e2 /gdb/testsuite | |
parent | 45181ed16d3a823fbd73ee23d94833f5aa906b98 (diff) | |
download | gdb-9d799f85e0e1acb6a49a6b7428d3845d8dba9588.zip gdb-9d799f85e0e1acb6a49a6b7428d3845d8dba9588.tar.gz gdb-9d799f85e0e1acb6a49a6b7428d3845d8dba9588.tar.bz2 |
Index: ChangeLog
2005-01-24 Andrew Cagney <cagney@gnu.org>
* infrun.c (handle_inferior_event): Handle back-to-back and nested
signals where the step_resume_breakpoint may have already been
inserted.
Index: testsuite/ChangeLog
2005-01-24 Andrew Cagney <cagney@gnu.org>
* gdb.base/sigrepeat.exp, gdb.base/sigrepeat.c: New test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/sigrepeat.c | 104 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/sigrepeat.exp | 62 |
3 files changed, 170 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4f0ca7c..465dcd1 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-01-24 Andrew Cagney <cagney@gnu.org> + + * gdb.base/sigrepeat.exp, gdb.base/sigrepeat.c: New test. + 2005-01-19 Andrew Cagney <cagney@gnu.org> * gdb.stabs/Makefile.in (Makefile): Update dependencies - diff --git a/gdb/testsuite/gdb.base/sigrepeat.c b/gdb/testsuite/gdb.base/sigrepeat.c new file mode 100644 index 0000000..a21486d --- /dev/null +++ b/gdb/testsuite/gdb.base/sigrepeat.c @@ -0,0 +1,104 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004, 2005 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include <stdio.h> +#include <string.h> +#include <signal.h> +#include <sys/time.h> + +static volatile int done[2]; +static volatile int repeats[2]; +static int itimer[2] = { ITIMER_REAL, ITIMER_VIRTUAL }; +static int alarm[2] = { SIGALRM, SIGVTALRM }; + +static void +handler (int sig) +{ + int sigi; + switch (sig) + { + case SIGALRM: sigi = 0; break; + case SIGVTALRM: sigi = 1; break; + default: abort (); + } + if (repeats[sigi]++ > 3) + { + /* Hit with enough signals, cancel everything and get out. */ + { + struct itimerval itime; + memset (&itime, 0, sizeof (itime)); + setitimer (itimer[sigi], &itime, NULL); + } + { + struct sigaction action; + memset (&action, 0, sizeof (action)); + action.sa_handler = SIG_IGN; + sigaction (sig, &action, NULL); + } + done[sigi] = 1; + return; + } + /* Set up a nested virtual timer. */ + while (1) + { + /* Wait until a signal has become pending, that way when this + handler returns it will be immediatly delivered leading to + back-to-back signals. */ + sigset_t set; + sigemptyset (&set); + if (sigpending (&set) < 0) + { + perror ("sigrepeat"); + abort (); + } + if (sigismember (&set, sig)) + break; + } +} /* handler */ + +main () +{ + int i; + /* Set up the signal handler. */ + for (i = 0; i < 2; i++) + { + struct sigaction action; + memset (&action, 0, sizeof (action)); + action.sa_handler = handler; + sigaction (alarm[i], &action, NULL); + } + + /* Set up a rapidly repeating timers. A timer, rather than SIGSEGV, + is used as after a timer handler returns the interrupted code can + safely resume. The intent is for the program to swamp GDB with a + backlog of pending signals. */ + for (i = 0; i < 2; i++) + { + struct itimerval itime; + memset (&itime, 0, sizeof (itime)); + itime.it_interval.tv_usec = 1; + itime.it_value.tv_usec = 250 * 1000; + setitimer (itimer[i], &itime, NULL); + } + + /* Wait. */ + while (!done[0] && !done[1]); /* infinite loop */ + return 0; +} diff --git a/gdb/testsuite/gdb.base/sigrepeat.exp b/gdb/testsuite/gdb.base/sigrepeat.exp new file mode 100644 index 0000000..7abe68f --- /dev/null +++ b/gdb/testsuite/gdb.base/sigrepeat.exp @@ -0,0 +1,62 @@ +# Copyright 2004, 2005 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +# The program sigrepeat.c creates a repeating timer and then waits for +# it to fire multiple times. The objective is to create a backlog if +# sigalrm signals and hence cause repeated signal delivery without any +# cpu advancment. + +if [target_info exists gdb,nosignals] { + verbose "Skipping sigstep.exp because of nosignals." + continue +} + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile sigrepeat +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile ${module}.c" + return -1 +} + +# get things started +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# Advance to main +if { ![runto_main] } then { + gdb_suppress_tests; +} + +# Run to the signal handler wait loop. +set infinite_loop [gdb_get_line_number {infinite loop}] +gdb_test "advance $infinite_loop" "" "advance to infinite loop" + +# Make the first of many signals come pending +sleep 1 + +# Try to step off this line +gdb_test "next" "return 0;.*" |