This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

debugging multithreaded applications


Hello,

I'm trying to debug multithreaded applications. But I
think I am doing something wrong. I'm using RedHat
Fedora Core 2, gcc 3.3.3, gdb 6.3 (built from source).
I created a simple program spawning a thread which
prints to cout, while the "main" thread just calls
pthread_join on the working one. 

#include <iostream>
#include <pthread.h>
#include <time.h>

using namespace std;

bool g_shouldrun = true;

void* work(void*){
    while (g_shouldrun) 
    {
        timespec t = {1,0};
        timespec remaining = t;
        //while ((remaining.tv_sec +
remaining.tv_nsec) != 0) 
        {
            nanosleep(&t,&remaining);
        }
        std::cout << "hello world" << std::endl;
//line 18
    }
	std::cout << "ok, enough of it" << std::endl;
}

int main (int argc, char *argv[])
{
    cout << "hello main" << endl;
    pthread_t thread;
    int a = pthread_create(&thread,0,&work,0);
    pthread_join(thread,0);
    return(0);
}



If I enter breakpoints into work (line 18), the
program is stopped if I use gdb (version 6.3). If
using gdbserver, after starting the process I get
"Cannot find new threads: capability not available",
and later the child process is terminated with "signal
= 5", SIGTRAP
Since I did not find anything in the manual that said
whether or not gdbserver can be used with
multithreaded programs, I hope someone on this mailing
list can help.
Is it possible to debug multithreaded programs using
gdbserver and if so, how?

Regards,
Thomas Fenzl


		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]