public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* debugging multithreaded applications
@ 2005-08-16 15:24 my Name
  2005-08-30  2:12 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: my Name @ 2005-08-16 15:24 UTC (permalink / raw)
  To: gdb

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 
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-08-30  2:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-16 15:24 debugging multithreaded applications my Name
2005-08-30  2:12 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).