tracing pthreads program on 2.2 kernels...

Marty Leisner mleisner at eng.mc.xerox.com
Tue Apr 3 16:31:41 UTC 2001


I just downloaded and built strace 4.3 on redhat 6.2.

When I tried to build it, I got:
/usr/local/src/strace-4.3/file.c: In function `sys_getdents64':
/usr/local/src/strace-4.3/file.c:1925: dereferencing pointer to incomplete type
/usr/local/src/strace-4.3/file.c:1925: dereferencing pointer to incomplete type
/usr/local/src/strace-4.3/file.c:1927: dereferencing pointer to incomplete type
/usr/local/src/strace-4.3/file.c:1927: dereferencing pointer to incomplete type
/usr/local/src/strace-4.3/file.c:1947: dereferencing pointer to incomplete type

I did some poking around, don't fully understand the problem, but ended up:
bash4 :4 leisner at thingy; rcsdiff -u file.c
===================================================================
RCS file: file.c,v
retrieving revision 1.42
diff -u -r1.42 file.c
- --- file.c	2001/03/27 12:17:17	1.42
+++ file.c	2001/04/02 18:02:47
@@ -36,7 +36,9 @@
 #include <dirent.h>
 #ifdef linux
 #define dirent kernel_dirent
+#if 0
 #define dirent64 kernel_dirent64
+#endif
 #include <linux/types.h>
 #include <linux/dirent.h>
 #undef dirent


since kernel_direct64 didn't seem to be defined where it was used (I don't
really understand this), I commented it out...I'm running redhat 6.2.

Anyway, I want to use strace to understand some pthreads programs...

This is the program:
* FILE: hello.c
* DESCRIPTION:
*   A "hello world" Pthreads program.  Demonstrates thread creation and
*   termination.
*
* SOURCE: 
* LAST REVISED: 9/20/98 Blaise Barney
******************************************************************************/

#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS     5

void *PrintHello(void *threadid)
{
   printf("\n%d: Hello World!\n", threadid);
   pthread_exit(NULL);
}

int main()
{
   pthread_t threads[NUM_THREADS];
   int rc, t;
   for(t=0;t<NUM_THREADS;t++){
      printf("Creating thread %d\n", t);
      rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
      if (rc){
         printf("ERROR; return code from pthread_create() is %d\n", rc);
         exit(-1);
      }
   }
   sleep(5);
   pthread_exit(NULL);
}

And strace -F -f shows:
rt_sigaction(SIGRT_0, {0x4001cd84, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x4001c454, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGRT_2, {0x4001ce0c, [], 0x4000000}, NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [32], NULL, 8) = 0
fstat64(1, 0xbfffeda0)                  = -1 ENOSYS (Function not implemented)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4011d000
ioctl(1, 0x5401, {B9600 opost isig icanon echo ...}) = 0
write(1, "Creating thread 0\n", 18Creating thread 0
)     = 18
brk(0)                                  = 0x8049804
brk(0x8049834)                          = 0x8049834
brk(0x804a000)                          = 0x804a000
brk(0x804c000)                          = 0x804c000
pipe([3, 4])                            = 0
clone(child_stack=0x804b808, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND) = 3594
[pid  3593] write(4, "\16\233\3@\5\0\0\0\346\201\0@\325\232\3@\325\232\3 at h8\1"..., 148) = 148
[pid  3593] rt_sigprocmask(SIG_SETMASK, NULL, [32], 8) = 0
[pid  3593] write(4, "@I\2@\0\0\0\0\0\0\0\0000\205\4\10\0\0\0\0\0\0\0\200\0\0"..., 148) = 148
[pid  3593] rt_sigprocmask(SIG_SETMASK, NULL, [32], 8) = 0
[pid  3593] rt_sigsuspend([] <unfinished ...>
 and hangs...

marty		mleisner at eng.mc.xerox.com   
Don't  confuse education with schooling.
	Milton Friedman to Yogi Berra





More information about the Strace-devel mailing list