[RFC] Check setitimer return value in testsuite/gdb.base/sigstep.c
Pierre Muller
muller@ics.u-strasbg.fr
Tue Oct 9 15:09:00 GMT 2007
Cygwin implements setitimer,
but returns -1 unless the first arg is ITIMER_REAL.
This problems leads to a huge lot of timeouts
when doing a "make check" for cygwin.
The proposed patch checks the return value of
setitimer, and if it returns -1 for
ITIMER_VIRTUAL, a second call to
setitimer with itime = ITIMER_REAL
is made.
I also did not clearly find
specifications about the return values for setitimer function.
I assumed that -1 meant failure and zero
meant success, but was unable to find a
definitive reference for this.
This reduces the duration of that single test from approximately
8000 seconds to around 500 seconds.
Can be checked individually with
"make check 'RUNTESTFLAGS=--dir=gdb.base sigstep.exp'"
Pierre Muller
Chargé de recherches
Institut Charles Sadron
6, rue Boussingault
F 67083 Strasbourg Cedex
Tél. : +(33)3-88-41-40-07
Email : pierre.muller@ics.u-strasbg.fr
2007/10/09 Pierre Muller <muller@ics.u-strasbg.fr>
* gdb.base/sigstep.c (main): Add checks for
return values for setitimer call.
Call setitimer again with itime = ITIMER_REAL
if first call to setitimer fails.
$ cvs diff -up sigstep.c
Index: sigstep.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sigstep.c,v
retrieving revision 1.5
diff -u -p -r1.5 sigstep.c
--- sigstep.c 23 Aug 2007 18:08:49 -0000 1.5
+++ sigstep.c 9 Oct 2007 15:03:03 -0000
@@ -21,6 +21,7 @@
#include <string.h>
#include <signal.h>
#include <sys/time.h>
+#include <errno.h>
static volatile int done;
@@ -39,9 +40,11 @@ enum {
itimer_virtual = ITIMER_VIRTUAL
} itimer = ITIMER_VIRTUAL;
+int
main ()
{
+ int res;
/* Set up the signal handler. */
memset (&action, 0, sizeof (action));
action.sa_handler = handler;
@@ -59,9 +62,21 @@ main ()
/* Set up a one-off timer. A timer, rather than SIGSEGV, is
used as after a timer handler finishes the interrupted code
can safely resume. */
- setitimer (itimer, &itime, NULL);
+ res = setitimer (itimer, &itime, NULL);
+ if (res == -1)
+ {
+ printf ("First call to setitimer failed, errno = %d\r\n",errno);
+ itimer = ITIMER_REAL;
+ res = setitimer (itimer, &itime, NULL);
+ if (res == -1)
+ {
+ printf ("Second call to setitimer failed, errno =
%d\r\n",errno);
+ return 1;
+ }
+ }
/* Wait. */
while (!done);
done = 0;
}
+ return 0;
}
More information about the Gdb-patches
mailing list