diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2009-01-09 17:22:56 +0000 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2009-01-09 17:22:56 +0000 |
commit | 215cc2703763894faea05899642ea5dfd5fc5c95 (patch) | |
tree | 835f1557b3514d5a2c185f93296810fa10885219 /test | |
parent | ef2fbf856cf775981b52278c80ce2a74a44019f4 (diff) | |
download | strace-215cc2703763894faea05899642ea5dfd5fc5c95.tar.gz strace-215cc2703763894faea05899642ea5dfd5fc5c95.tar.bz2 strace-215cc2703763894faea05899642ea5dfd5fc5c95.tar.xz |
* defs.h: Add new struct tcb fields: wait_status, next_need_service.
make flags field wider (ints are easier to work with on many CPUs).
* strace.c (trace): Split this function into two:
collect_stopped_tcbs() and handle_stopped_tcbs().
Now we collect *all* waitable tasks, then handle them all,
then repeat.
Fixes RH#478419 "Some threads stop when strace with -f option
is executed on a multi-thread process"
* test/many_looping_threads.c: example program which cna't be straced
successfully without this fix.
Diffstat (limited to 'test')
-rw-r--r-- | test/many_looping_threads.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/many_looping_threads.c b/test/many_looping_threads.c new file mode 100644 index 0000000..d8f7f8d --- /dev/null +++ b/test/many_looping_threads.c @@ -0,0 +1,37 @@ +/* This test is not yet added to Makefile */ + +#include <stdio.h> +#include <pthread.h> +#include <unistd.h> +#include <sys/types.h> +#include <signal.h> +#include <stdlib.h> + +static int thd_no; + +static void *sub_thd(void *c) +{ + fprintf(stderr, "sub-thread %d created\n", ++thd_no); + for (;;) + getuid(); + return NULL; +} + +int main(int argc, char **argv) +{ + int i; + pthread_t *thd; + int num_threads = 1; + + if (argv[1]) + num_threads = atoi(argv[1]); + + thd = malloc(num_threads * sizeof(thd[0])); + fprintf(stderr, "test start, num_threads:%d...\n", num_threads); + for (i = 0; i < num_threads; i++) { + pthread_create(&thd[i], NULL, sub_thd, NULL); + fprintf(stderr, "after pthread_create\n"); + } + /* Exit. This kills all threads */ + return 0; +} |