Hi all, In order to make a performance comparison between ptrace and utrace we modified ptrace testsuite(http://sourceware.org/systemtap/wiki/utrace/tests) to provide information about execution time. The patch with this change can be found attached.
This experiment was ran using a x86 DELL Precision D670 Desktop. The tests have been executed 13 times for each environment(ptrace and utrace) and discounted the two lowest and the highest values of each test. After check standard deviation of remaining values, we decided to use average value in order to check the possible overhead introduced by utrace. *status* *test_name* *utrace_overhead* PASS ptrace-on-job-control-stopped +8.02% PASS attach-wait-on-stopped 0% PASS detach-can-signal 0% PASS attach-sigcont-wait +1.31% PASS sa-resethand-on-cont-signal 0% PASS ptrace-cont-sigstop-detach 0% PASS tif-syscall-trace-after-detach 0% PASS event-exit-proc-maps -2.17% PASS event-exit-proc-environ 0% PASS x86_64-ia32-gs 0% SKIP x86_64-gsbase SKIP powerpc-altivec PASS peekpokeusr +9.09% PASS watchpoint +8.72% FAIL step-jump-cont FAIL step-jump-cont-strict SKIP ppc-dabr-race PASS step-into-handler +6.96% SKIP user-area-access PASS user-regs-peekpoke +11.17% PASS user-regs-peekpoke 0% SKIP erestart-debugger SKIP step-to-breakpoint In face of results I have a question: "According to these tests, currently Utrace performance is about the same or slightly slower. We guess the reason is that the ptrace() syscall API itself is the bottleneck, not the ptrace implementation. Does that seem valid assumption? " Any comments are welcome! -- Allan Bezerra OpenBossa Labs www.openbossa.org Nokia Institute of Technology Manaus - Brazil
Index: ptrace-tests/tests/Makefile.am =================================================================== --- ptrace-tests.orig/tests/Makefile.am 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/Makefile.am 2008-03-12 09:33:15.000000000 -0400 @@ -54,7 +54,7 @@ # Build all the test programs in "make all", since they are all we build. noinst_PROGRAMS = $(SAFE) $(CRASHERS) -AM_CFLAGS = -std=gnu99 -Wall -Werror +AM_CFLAGS = -std=gnu99 -Wall -Werror -lrt x86_64_ia32_gs_LDFLAGS = -lpthread late_ptrace_may_attach_check_LDFLAGS = -lpthread Index: ptrace-tests/tests/Makefile.in =================================================================== --- ptrace-tests.orig/tests/Makefile.in 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/Makefile.in 2008-03-12 09:41:39.000000000 -0400 @@ -351,7 +351,7 @@ x86_64-cs \ block-step -AM_CFLAGS = -std=gnu99 -Wall -Werror +AM_CFLAGS = -std=gnu99 -Wall -Werror -lrt x86_64_ia32_gs_LDFLAGS = -lpthread late_ptrace_may_attach_check_LDFLAGS = -lpthread ppc_dabr_race_LDFLAGS = -lpthread Index: ptrace-tests/tests/attach-sigcont-wait.c =================================================================== --- ptrace-tests.orig/tests/attach-sigcont-wait.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/attach-sigcont-wait.c 2008-03-12 09:47:51.000000000 -0400 @@ -23,6 +23,8 @@ #include <asm/unistd.h> #include <unistd.h> +#include <time.h> + #define tkill(tid, sig) syscall (__NR_tkill, (tid), (sig)) /* Failure occurs either immediately or in about 20 runs. @@ -31,6 +33,12 @@ static pid_t child; +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + static void cleanup (void) { @@ -55,6 +63,9 @@ unsigned long loops; pid_t got_pid; int status; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -166,6 +177,9 @@ while (time (NULL) < testend); alarm (0); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (bad) { printf ("%lu bad in %lu iterations: %.2f%%\n", Index: ptrace-tests/tests/attach-wait-on-stopped.c =================================================================== --- ptrace-tests.orig/tests/attach-wait-on-stopped.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/attach-wait-on-stopped.c 2008-03-12 09:44:47.000000000 -0400 @@ -16,6 +16,7 @@ #include <sys/ptrace.h> #include <sys/types.h> #include <sys/wait.h> +#include <time.h> static void @@ -30,6 +31,12 @@ static const char *handler_state; +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + static void handler (int signo) { @@ -77,6 +84,9 @@ int main (void) { int i; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); child_pid = fork(); switch (child_pid) @@ -140,5 +150,9 @@ // puts ("OK"); kill (child_pid, SIGKILL); //return 0; + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + exit (0); } Index: ptrace-tests/tests/block-step.c =================================================================== --- ptrace-tests.orig/tests/block-step.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/block-step.c 2008-03-12 10:49:47.000000000 -0400 @@ -16,6 +16,7 @@ #include <sys/ptrace.h> #include <stddef.h> #include <errno.h> +#include <time.h> #define CHECK_VALUE 22 static volatile unsigned long int check; @@ -48,6 +49,12 @@ #ifndef PTRACE_SINGLEBLOCK +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + int main (void) { @@ -80,6 +87,9 @@ pid_t got_pid; int status; long l; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); atexit (cleanup); signal (SIGABRT, handler_fail); @@ -168,6 +178,9 @@ assert (got_pid == child); assert (WIFEXITED (status)); assert (WEXITSTATUS (status) == 0); + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); return 0; } Index: ptrace-tests/tests/clone-get-signal.c =================================================================== --- ptrace-tests.orig/tests/clone-get-signal.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/clone-get-signal.c 2008-03-12 10:59:59.000000000 -0400 @@ -22,9 +22,15 @@ #include <sys/wait.h> #include <sys/ptrace.h> #include <sys/syscall.h> +#include <time.h> /* Crashed in 8 minutes. */ #define DEFAULT_TESTTIME (15 * 60) /* seconds */ +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} static void die (const char *msg) { @@ -73,6 +79,10 @@ : DEFAULT_TESTTIME); unsigned long loops; int pid; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); + loops = 0; do { @@ -104,6 +114,8 @@ } loops++; } while (time (NULL) < testend); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); return 0; } Index: ptrace-tests/tests/detach-can-signal.c =================================================================== --- ptrace-tests.orig/tests/detach-can-signal.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/detach-can-signal.c 2008-03-12 09:46:25.000000000 -0400 @@ -19,14 +19,24 @@ #include <sys/ptrace.h> #include <unistd.h> #include <linux/unistd.h> +#include <time.h> #define NR_CHILDREN 3 +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + int main (int ac, char * av[]) { int i; pid_t dpids[NR_CHILDREN]; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); for (i = 0; i < NR_CHILDREN; i++) { pid_t pid = fork (); @@ -71,6 +81,10 @@ int nr_resps; for (nr_resps = 0; 0 < waitpid (-1, NULL, WNOHANG); nr_resps++) {} + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + exit ((0 == nr_resps) ? 1 : 0); } } Index: ptrace-tests/tests/erestart-debugger.c =================================================================== --- ptrace-tests.orig/tests/erestart-debugger.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/erestart-debugger.c 2008-03-12 11:02:59.000000000 -0400 @@ -40,6 +40,14 @@ # define REGISTER_IP .rip #endif +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + #ifndef REGISTER_IP int @@ -101,6 +109,9 @@ unsigned int child_data_size; child_address_t func_p, func_data_p, child_retval_p, child_errno_p; child_data_t func_data, child_retval, child_errno; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -290,6 +301,9 @@ child_errno = l; assert (child_errno == l); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + /* kernel-2.6.23.15-137.fc8.x86_64 -m64. */ /* kernel.org 2.6.22-rc4-git7 x86_64 -m64. */ /* kernel-2.6.23.15-137.fc8.i686 (-m32). */ Index: ptrace-tests/tests/erestartsys.c =================================================================== --- ptrace-tests.orig/tests/erestartsys.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/erestartsys.c 2008-03-12 11:01:58.000000000 -0400 @@ -43,6 +43,14 @@ /* FIXME: # define REGISTER_IP [PT_CR_IIP / 8] */ #endif +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + #ifndef REGISTER_IP int @@ -103,6 +111,10 @@ int amaster; const char intr_c = 003; struct termios termios; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); + #ifdef PTRACE_PEEKUSR_AREA ptrace_area parea; #endif @@ -271,6 +283,9 @@ assert (errno == 0); child_errno = l; + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + /* kernel-2.6.23.15-137.fc8.x86_64 -m64. */ /* kernel.org 2.6.22-rc4-git7 x86_64 -m64. */ /* kernel-2.6.23.15-137.fc8.i686 (-m32). */ Index: ptrace-tests/tests/event-exit-proc-environ.c =================================================================== --- ptrace-tests.orig/tests/event-exit-proc-environ.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/event-exit-proc-environ.c 2008-03-12 10:25:56.000000000 -0400 @@ -30,6 +30,7 @@ #include <string.h> #include <assert.h> #include <sys/stat.h> +#include <time.h> #define PTRACE_EVENT(status) ((status) >> 16) @@ -45,11 +46,20 @@ #define PTRACE_EVENT_EXIT 6 #endif +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + int main(int argc, char **argv) { pid_t pid; int result = 0; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); /* We would pass even on the buggy kernels if we are root. */ if (geteuid () == 0) { @@ -155,5 +165,8 @@ } while (!exited); } + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return result; } Index: ptrace-tests/tests/event-exit-proc-maps.c =================================================================== --- ptrace-tests.orig/tests/event-exit-proc-maps.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/event-exit-proc-maps.c 2008-03-12 10:25:01.000000000 -0400 @@ -30,6 +30,7 @@ #include <string.h> #include <assert.h> #include <sys/stat.h> +#include <time.h> #define PTRACE_EVENT(status) ((status) >> 16) @@ -45,11 +46,20 @@ #define PTRACE_EVENT_EXIT 6 #endif +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + int main(int argc, char **argv) { pid_t pid; int result = 0; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); /* We would pass even on the buggy kernels if we are root. */ if (geteuid () == 0) { @@ -151,5 +161,8 @@ } while (!exited); } + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return result; } Index: ptrace-tests/tests/late-ptrace-may-attach-check.c =================================================================== --- ptrace-tests.orig/tests/late-ptrace-may-attach-check.c 2008-03-12 09:32:32.000000000 -0400 +++ ptrace-tests/tests/late-ptrace-may-attach-check.c 2008-03-12 11:07:20.000000000 -0400 @@ -13,6 +13,13 @@ #include <signal.h> #include <stdlib.h> #include <string.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} /* WARNING: The real testing count is probably unbound. */ #define DEFAULT_TESTTIME 10 /* seconds */ @@ -49,11 +56,16 @@ : DEFAULT_TESTTIME); unsigned long loops; pthread_t thread; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); + atexit (cleanup); signal (SIGABRT, handler_fail); signal (SIGINT, handler_fail); + if ((argc != 2 || strcmp (argv[1], "child") != 0) && (pid = fork())) { loops = 0; do { @@ -61,12 +73,21 @@ ptrace(PTRACE_DETACH, pid, NULL, 0); loops++; } while (time (NULL) < testend); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return 0; } - + +/* clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); +*/ if (pthread_create(&thread, NULL, thread_func, (void *) argv[0])) perror("pthread_create"); - + +/* clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); +*/ while (1) pause(); /* NOTREACHED */ Index: ptrace-tests/tests/peekpokeusr.c =================================================================== --- ptrace-tests.orig/tests/peekpokeusr.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/peekpokeusr.c 2008-03-12 10:31:44.000000000 -0400 @@ -19,6 +19,7 @@ #include <string.h> #include <errno.h> #include <error.h> +#include <time.h> #if defined __x86_64__ || defined __i386__ # define CANPOKE(a) (a < sizeof (struct user_regs_struct) \ @@ -51,6 +52,12 @@ static pid_t child; +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + static void cleanup (void) { @@ -73,6 +80,9 @@ pid_t got_pid; int status; long l, addr, val; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); atexit (cleanup); signal (SIGABRT, handler_fail); @@ -124,5 +134,8 @@ } } + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return status; } Index: ptrace-tests/tests/ppc-dabr-race.c =================================================================== --- ptrace-tests.orig/tests/ppc-dabr-race.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/ppc-dabr-race.c 2008-03-12 10:53:47.000000000 -0400 @@ -25,6 +25,13 @@ #include <dirent.h> #include <string.h> #include <limits.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} /* Number of threads to race; it should be probably about number-of-CPUs + 1. */ #define THREADS 64 @@ -176,6 +183,9 @@ int thread_count, threadi; DIR *dir; struct dirent *dirent; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -320,6 +330,9 @@ puts ("The kernel bug did not get reproduced - possibly increase THREADS."); #endif + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return 0; } Index: ptrace-tests/tests/ppc-ptrace-exec-full-regs.c =================================================================== --- ptrace-tests.orig/tests/ppc-ptrace-exec-full-regs.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/ppc-ptrace-exec-full-regs.c 2008-03-12 11:02:02.000000000 -0400 @@ -38,6 +38,7 @@ #include <sys/wait.h> #include <sys/mman.h> #include <sys/types.h> +#include <time.h> /* On RHEL-4 it is present only in <linux/ptrace.h> in /lib/modules/`uname -r`/{build,source}. */ @@ -51,10 +52,20 @@ #define PTRACE_EVENT_EXEC 4 #endif +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + int main (void) { pid_t child = fork (); + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); + if (child == 0) { ptrace (PTRACE_TRACEME); @@ -90,5 +101,9 @@ if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) error (2, 0, "third status %x", status); } + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return 0; } Index: ptrace-tests/tests/ptrace-cont-sigstop-detach.c =================================================================== --- ptrace-tests.orig/tests/ptrace-cont-sigstop-detach.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/ptrace-cont-sigstop-detach.c 2008-03-12 09:52:14.000000000 -0400 @@ -20,6 +20,12 @@ #define DELAY() sleep (1) +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + static void loop (void) { for (;;) @@ -75,6 +81,9 @@ void (*handler_orig) (int signo); pid_t got_pid; int status; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); @@ -130,6 +139,10 @@ errno = 0; ptrace (PTRACE_DETACH, child, (void *) 1UL, (void *) 0UL); + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (errno == ESRCH) { #if 0 Index: ptrace-tests/tests/ptrace-on-job-control-stopped.c =================================================================== --- ptrace-tests.orig/tests/ptrace-on-job-control-stopped.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/ptrace-on-job-control-stopped.c 2008-03-12 09:40:53.000000000 -0400 @@ -21,7 +21,13 @@ #include <sys/wait.h> #include <limits.h> #include <string.h> +#include <time.h> +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} static void child_f (void) @@ -78,7 +84,9 @@ { int i; void (*handler_orig) (int signo); + struct timespec start, stop; + clock_gettime(CLOCK_REALTIME, &start); child_pid = fork(); switch (child_pid) { @@ -125,5 +133,7 @@ // puts ("OK"); //return 0; + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); exit (0); } Index: ptrace-tests/tests/sa-resethand-on-cont-signal.c =================================================================== --- ptrace-tests.orig/tests/sa-resethand-on-cont-signal.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/sa-resethand-on-cont-signal.c 2008-03-12 09:49:27.000000000 -0400 @@ -20,6 +20,13 @@ #include <sys/types.h> #include <sys/wait.h> #include <string.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} static void handler_usr1 (int signo) { @@ -58,6 +65,9 @@ struct sigaction act; int i; int status; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); atexit (cleanup); signal (SIGINT, handler_fail); @@ -98,6 +108,10 @@ assert (i == 0); i = waitpid (child_pid, &status, 0); assert (i == child_pid); + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (WIFEXITED (status) && WEXITSTATUS (status) == 42) { #if 0 Index: ptrace-tests/tests/step-into-handler.c =================================================================== --- ptrace-tests.orig/tests/step-into-handler.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/step-into-handler.c 2008-03-12 11:14:43.000000000 -0400 @@ -20,6 +20,13 @@ #include <sys/time.h> #include <string.h> #include <stddef.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} #if defined __x86_64__ #define REGISTER_IP regs.rip @@ -116,6 +123,9 @@ pid_t pid; sighandler_t handler_orig; void *ip, *ip_in_raise, *ip_expected; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -164,6 +174,9 @@ ip = ip_get (); ip_expected = handler_alrm_get (); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (ip == ip_expected) return 0; Index: ptrace-tests/tests/step-jump-cont.c =================================================================== --- ptrace-tests.orig/tests/step-jump-cont.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/step-jump-cont.c 2008-03-12 10:48:30.000000000 -0400 @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <sys/wait.h> +#include <time.h> /* If the RT bit never comes set from PTRACE_GETREGS this bug may be never reproducible on such kernel as the debugger should never arbitrarily set the @@ -37,6 +38,12 @@ /* Set in `jump-step-cont-strict.c'! */ //#define STRICT +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + #if !defined __i386__ && !defined __x86_64__ && !defined __powerpc__ int @@ -147,6 +154,9 @@ unsigned long was_pc; pid_t pid; REGS_TYPE (regs); + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -276,6 +286,10 @@ pid = waitpid (child, &status, 0); assert (pid == child); assert (WIFSTOPPED (status)); + + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (WSTOPSIG (status) == SIGUSR2) return 0; else if (WSTOPSIG (status) == SIGTRAP) Index: ptrace-tests/tests/step-to-breakpoint.c =================================================================== --- ptrace-tests.orig/tests/step-to-breakpoint.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/step-to-breakpoint.c 2008-03-12 11:04:09.000000000 -0400 @@ -27,6 +27,13 @@ #include <stdlib.h> #include <stdio.h> #include <sys/wait.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} /* #define DEBUG */ @@ -95,6 +102,9 @@ #ifdef PTRACE_GETSIGINFO siginfo_t siginfo; #endif + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -187,6 +197,9 @@ printf ("rip=0x%lx\n", regs.rip); #endif + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + /* Fedora 8 GOLD kernel-2.6.23.1-42.fc8.x86_64 */ if (regs.rip == (unsigned long) func3addr) return 1; Index: ptrace-tests/tests/tif-syscall-trace-after-detach.c =================================================================== --- ptrace-tests.orig/tests/tif-syscall-trace-after-detach.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/tif-syscall-trace-after-detach.c 2008-03-12 10:03:41.000000000 -0400 @@ -30,6 +30,12 @@ #define DELAY_USEC (1000000 / 10) +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + static void loop (void) { /* Loop with any immediately returning syscall. */ @@ -79,6 +85,9 @@ int status; int ptraces; unsigned long bad = 0; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); void (*handler_orig) (int signo); @@ -151,6 +160,9 @@ while (time (NULL) < testend); alarm (0); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (bad) { printf ("%lu bad in %lu iterations - may occur in 1 of 2 runs: %.2f%% * 2 = %.2f%%\n", Index: ptrace-tests/tests/tracer-lockup-on-sighandler-kill.c =================================================================== --- ptrace-tests.orig/tests/tracer-lockup-on-sighandler-kill.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/tracer-lockup-on-sighandler-kill.c 2008-03-12 10:55:39.000000000 -0400 @@ -34,6 +34,12 @@ int hit_do_nothing = 0; +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + void do_nothing(int signum) { hit_do_nothing = 1; @@ -196,6 +202,10 @@ time_t testend = time (NULL) + (testtime != NULL ? atoi (testtime) : DEFAULT_TESTTIME); unsigned long loops; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); + // We don't want any nasy signals when children exit or pipes // close abnormally. @@ -324,6 +334,9 @@ loops++; } while (time (NULL) < testend); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + if (bad) { printf ("%lu bad in %lu iterations: %.2f%%\n", Index: ptrace-tests/tests/user-area-access.c =================================================================== --- ptrace-tests.orig/tests/user-area-access.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/user-area-access.c 2008-03-12 10:56:40.000000000 -0400 @@ -24,6 +24,13 @@ /* <asm/ptrace.h> is required on s390 to get PTRACE_POKEUSR_AREA. */ #include <sys/ptrace.h> #include <asm/ptrace.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} #ifndef PTRACE_POKEUSR_AREA @@ -70,6 +77,9 @@ } u, u2; ptrace_area parea; int start, end; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); setbuf (stdout, NULL); atexit (cleanup); @@ -210,6 +220,8 @@ return 1; } + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); return 0; } Index: ptrace-tests/tests/user-regs-peekpoke.c =================================================================== --- ptrace-tests.orig/tests/user-regs-peekpoke.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/user-regs-peekpoke.c 2008-03-12 10:59:30.000000000 -0400 @@ -26,6 +26,13 @@ /* <asm/ptrace.h> is required on x86_64 to get PTRACE_SETREGS. */ #include <sys/ptrace.h> #include <asm/ptrace.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} #ifndef PTRACE_SETREGS @@ -70,6 +77,9 @@ unsigned char byte[sizeof (struct user_regs_struct)]; } u, u2; int start; + struct timespec time_start, time_stop; + + clock_gettime(CLOCK_REALTIME, &time_start); setbuf (stdout, NULL); atexit (cleanup); @@ -244,6 +254,8 @@ return 1; } + clock_gettime(CLOCK_REALTIME, &time_stop); + show_time(time_start, time_stop); return 0; } Index: ptrace-tests/tests/watchpoint.c =================================================================== --- ptrace-tests.orig/tests/watchpoint.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/watchpoint.c 2008-03-12 10:45:10.000000000 -0400 @@ -20,6 +20,13 @@ #include <sys/ptrace.h> #include <stddef.h> #include <errno.h> +#include <time.h> + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} #ifdef __powerpc__ @@ -126,6 +133,9 @@ pid_t got_pid; int i, status; long l; + struct timespec start, stop; + + clock_gettime(CLOCK_REALTIME, &start); atexit (cleanup); signal (SIGABRT, handler_fail); @@ -168,6 +178,9 @@ assert (WIFSTOPPED (status)); assert (WSTOPSIG (status) == SIGTRAP); + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); + return 0; } Index: ptrace-tests/tests/x86_64-cs.c =================================================================== --- ptrace-tests.orig/tests/x86_64-cs.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/x86_64-cs.c 2008-03-12 11:04:02.000000000 -0400 @@ -18,6 +18,7 @@ #include <stdio.h> #include <sys/wait.h> #include <stddef.h> +#include <time.h> #if !defined __i386__ && !defined __x86_64__ @@ -38,6 +39,12 @@ static pid_t child; +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + static void cleanup (void) { @@ -60,7 +67,10 @@ int status, i; pid_t pid; long cs; + struct timespec start, stop; + clock_gettime(CLOCK_REALTIME, &start); + setbuf (stdout, NULL); atexit (cleanup); signal (SIGABRT, handler_fail); @@ -121,6 +131,8 @@ /* The %cs value is actually ignored on 64-bit, so it should be happy. */ assert (WSTOPSIG (status) == SIGUSR2); # endif + clock_gettime(CLOCK_REALTIME, &stop); + show_time(start, stop); exit (0); } Index: ptrace-tests/tests/x86_64-ia32-gs.c =================================================================== --- ptrace-tests.orig/tests/x86_64-ia32-gs.c 2008-03-12 09:32:33.000000000 -0400 +++ ptrace-tests/tests/x86_64-ia32-gs.c 2008-03-12 11:26:06.000000000 -0400 @@ -15,9 +15,18 @@ #include <sys/ptrace.h> #include <stddef.h> #include <errno.h> +#include <time.h> /* #define DEBUG 1 */ +struct timespec time_start, time_stop; + +void show_time (struct timespec start, struct timespec stop) { + printf("time: %ld.%.9ld seg\n", (stop.tv_sec - start.tv_sec), + ((stop.tv_nsec >= start.tv_nsec)? (stop.tv_nsec - start.tv_nsec) : + (start.tv_nsec - stop.tv_nsec))); +} + #ifndef __i386__ int main (void) @@ -101,6 +110,8 @@ unsigned thread_area_orig; unsigned thread_area_new; + clock_gettime(CLOCK_REALTIME, &time_start); + atexit (cleanup); signal (SIGABRT, handler_fail); signal (SIGINT, handler_fail); @@ -196,6 +207,8 @@ #ifdef DEBUG puts ("PASS"); #endif + clock_gettime(CLOCK_REALTIME, &time_stop); + show_time(time_start, time_stop); return 0; }