gdb 5 and threads

Ali Ijaz Sheikh asheik4@cs.mcgill.ca
Wed Jul 26 11:01:00 GMT 2000


Hi!

I was trying to debug a multithreaded program with GDB 5. Apparently there
are some problems. To test my hypothesis, I wrote a little program and tried
it out with gdb (source code at the end):

This is what happens with gdb:


------------snip------------

(gdb) b start
Breakpoint 1 at 0x80484ea: file test.c, line 8.

(gdb) r
Starting program: /home/ali/tmp/./test 
[New Thread 1024 (runnable)]
[New Thread 2049 (runnable)]

Error: rw_common (): read: Input/output error.
Ack!  Thread Exited event.  What do I do now???

(gdb) 

-----------snip-------------

While, if run directly, the program proceeds normally without any problems:

[/home/ali/tmp]$ ./test
Creating Threads..
Inside thread 1
Inside thread 2
Collapsing Threads..

The platform I am running this on is:
Linux hodgepodge 2.4.0-test3 #2 SMP Wed Jul 12 12:50:21 EST 2000 i686 unknown

gcc version is 2.95.2

glibc is libc-2.1.3


Any ideas what this is about?


Ali

--------- source code --------
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

typedef void *(*pthread_start_t) (void *);

void start(int i) {
  printf("Inside thread %d\n", i);
}

int main() {
  pthread_t t1;
  pthread_t t2;
  void *ret;

  printf("Creating Threads..\n");
  pthread_create(&t1, NULL, (pthread_start_t) start, (void *)1);
  pthread_create(&t2, NULL, (pthread_start_t) start, (void *)2);
        
  sleep(10);

  printf("Collapsing Threads..\n");
  pthread_join(t1, NULL);
  pthread_join(t2, NULL);
}
 
----- end source code ------

-- 
The Fifth Rule:
        You have taken yourself too seriously.


More information about the Gdb mailing list