Subject: gdb seems to ignore threads
To: None <current-users@netbsd.org>
From: felix zaslavskiy <felix@students.poly.edu>
List: current-users
Date: 05/31/2003 19:06:08
I wrote a simple hello world program for threads:

#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

void* thread_execution(void * p)
{
        int i;
        for(i = 0; i < 10; i++){
                printf("Thread counter:%d sleeping\n", i);
                sleep(1);
        }
        return; 
}

int main ()
{
        pthread_t thread;

        pthread_create (&thread, NULL, thread_execution, NULL);
        pthread_join (thread, NULL);
        printf("thead has finished");
        return 0;
}

compiled as : 
gcc -g program.c -lpthread

also my libpthread is compiled with -g also.

So i set a breakpoint at main and at thread_execution.
I expectded that when i run the program after the first break the
program will stop at thread_execution in a different thread.

Well it seems to just run to finish oblivious to the breakpoints.

The only way i could stop the program in the middle of execution was to
Control-C which stoped execution in sa_yeild code.
Interupting gives something like:
3 Thread 21 ..(thread_execution)
2 LWP 0 ...    
1 Thread 0 .. (main thread)

It seems the program can continue fine after an interupt

My question is , is this the normal behavior or is gdb totaly useless at
debuging threads the way it supposed to at this time ?