On Wed, 2008-12-10 at 04:54 -0800, Roland McGrath wrote: > The current patch has regressions on block-step, step-jump-cont, > step-jump-cont-strict, and step-to-breakpoint. Do your tests cover > anything new that is not already tested by one or more of those?
I looked through existing tests and none seem to simply test whether SIGLESTEP works AT ALL, not nuances "does it work in sighandler" etc. So this one might be useful as such: #include <sys/types.h> #include <sys/wait.h> #include <sys/ptrace.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <errno.h> #include <assert.h> #include <stdio.h> static pid_t child; static void cleanup (void) { if (child > 0) kill (child, SIGKILL); child = 0; while (waitpid (-1, NULL, __WALL) > 0) continue; } static void handler_fail (int signo) { cleanup (); signal (SIGABRT, SIG_DFL); assert (0); } #define NUM_SINGLESTEPS 1 int main (int argc, char **argv) { int i, status; pid_t pid; setbuf (stdout, NULL); atexit (cleanup); signal (SIGABRT, handler_fail); signal (SIGINT, handler_fail); signal (SIGALRM, handler_fail); alarm (5); child = fork (); assert (child >= 0); if (child == 0) { /* loop for singlestepping */ #define x_10000 2845218640 #define x_100000 180235552 #define x_1000000 4074525504 #define x_10000000 1483440256 #define x_100000000 1116472576 #define x_1000000000 2621190656 uint32_t x = 0; do x = x * 1664525 + 1013904223; while (x != x_1000000); /* reached after million iterations */ _exit (42); } errno = 0; ptrace (PTRACE_ATTACH, child, (void *) 0, (void *) 0); assert (!errno); pid = waitpid (child, &status, 0); assert (pid == child); assert (WIFSTOPPED (status)); assert (WSTOPSIG (status) == SIGSTOP); for (i = 0; i < NUM_SINGLESTEPS; i++) { ptrace (PTRACE_SINGLESTEP, child, (void *) 0, (void *) 0); assert (!errno); pid = waitpid (child, &status, 0); assert (pid == child); /* Known bug in 2.6.28-rc7 + utrace patch: * child was left to run freely, and exited */ if (WIFEXITED (status)) { assert (WEXITSTATUS (status) == 42); return 1; } assert (WIFSTOPPED (status)); assert (WSTOPSIG (status) == SIGTRAP); } cleanup (); return 0; }