Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb Stopped in pthread_create
@ 2007-07-23  9:52 Oleg V. Zhylin
  2007-07-23 19:22 ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Oleg V. Zhylin @ 2007-07-23  9:52 UTC (permalink / raw)
  To: gdb

Hi All, 

  I've tried to debug my multithreaded application with gdb 6.6 (GNU
gdb Red Hat Linux (6.6-15.fc7rh) ), but inside pthread_create call I
get 

[1]+  Stopped                 gdb ./a.out

  If I use ddd on the same machine pthread_create works just fine. 

I get this error on all Linux boxes and GUI is not available on all of
them. Is there a way to configure gdb so that it could tolerate
pthread_create?



WBR Oleg V. Zhylin   ovz@yahoo.com


       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 


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

* Re: gdb Stopped in pthread_create
  2007-07-23  9:52 gdb Stopped in pthread_create Oleg V. Zhylin
@ 2007-07-23 19:22 ` Jim Blandy
  2007-07-24  9:11   ` breaking at thread exit Mayuresh Kulkarni
  2007-07-24 15:50   ` gdb Stopped in pthread_create Oleg V. Zhylin
  0 siblings, 2 replies; 5+ messages in thread
From: Jim Blandy @ 2007-07-23 19:22 UTC (permalink / raw)
  To: Oleg V. Zhylin; +Cc: gdb


"Oleg V. Zhylin" <ovz@yahoo.com> writes:
>   I've tried to debug my multithreaded application with gdb 6.6 (GNU
> gdb Red Hat Linux (6.6-15.fc7rh) ), but inside pthread_create call I
> get 
>
> [1]+  Stopped                 gdb ./a.out
>
>   If I use ddd on the same machine pthread_create works just fine. 

That's very surprising.  Doesn't DDD just run GDB internally?

> I get this error on all Linux boxes and GUI is not available on all of
> them. Is there a way to configure gdb so that it could tolerate
> pthread_create?

This is a bug; GDB should be able to step over calls to
pthread_create.

If you haven't already, please try downloading the latest GDB sources
from CVS (see http://sourceware.org/gdb/current/) and see if the
problem still occurs.  If it does, then if you can post instructions
here that allow us to reproduce the problem on our own machines, then
I will try to fix it.


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

* breaking at thread exit
  2007-07-23 19:22 ` Jim Blandy
@ 2007-07-24  9:11   ` Mayuresh Kulkarni
  2007-07-24 15:50   ` gdb Stopped in pthread_create Oleg V. Zhylin
  1 sibling, 0 replies; 5+ messages in thread
From: Mayuresh Kulkarni @ 2007-07-24  9:11 UTC (permalink / raw)
  To: gdb

Hello,

I just tried out gdb 6.6 on linux (2.4 kernel).

It looks like catch thread_exit is not yet implemented. Is there some 
other trick I can use to break on a thread exit? I tried breaking on 
pthread_exit but that doesnt work.

Thanks in advance,
Mayuresh.


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

* Re: gdb Stopped in pthread_create
  2007-07-23 19:22 ` Jim Blandy
  2007-07-24  9:11   ` breaking at thread exit Mayuresh Kulkarni
@ 2007-07-24 15:50   ` Oleg V. Zhylin
  2007-07-28  1:40     ` Jim Blandy
  1 sibling, 1 reply; 5+ messages in thread
From: Oleg V. Zhylin @ 2007-07-24 15:50 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 2333 bytes --]

Hi Jim,

  pthread_test.cpp demonstrates the problematic behavior. It is built
using

 g++ -g pthread_test.cpp -lpthread

 The version numbers are

$ cat /proc/version
Linux version 2.6.21-1.3228.fc7
(kojibuilder@xenbuilder2.fedora.redhat.com) (gcc version 4.1.2 20070502
(Red Hat 4.1.2-12)) #1 SMP Tue Jun 12 15:37:31 EDT 2007

and gdb snapshot for July 24th

$ gdb --version
GNU gdb 6.6.50.20070724

Below is the log of gdb session

$ gdb a.out
GNU gdb 6.6.50.20070724
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/cartcs/Work/gdb/pthread_create/a.out
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f336d0 (LWP 22251)]

[3]+  Stopped                 gdb a.out


--- Jim Blandy <jimb@codesourcery.com> wrote:

> 
> "Oleg V. Zhylin" <ovz@yahoo.com> writes:
> >   I've tried to debug my multithreaded application with gdb 6.6
> (GNU
> > gdb Red Hat Linux (6.6-15.fc7rh) ), but inside pthread_create call
> I
> > get 
> >
> > [1]+  Stopped                 gdb ./a.out
> >
> >   If I use ddd on the same machine pthread_create works just fine. 
> 
> That's very surprising.  Doesn't DDD just run GDB internally?
> 
> > I get this error on all Linux boxes and GUI is not available on all
> of
> > them. Is there a way to configure gdb so that it could tolerate
> > pthread_create?
> 
> This is a bug; GDB should be able to step over calls to
> pthread_create.
> 
> If you haven't already, please try downloading the latest GDB sources
> from CVS (see http://sourceware.org/gdb/current/) and see if the
> problem still occurs.  If it does, then if you can post instructions
> here that allow us to reproduce the problem on our own machines, then
> I will try to fix it.
> 


WBR Oleg V. Zhylin   ovz@yahoo.com


       
____________________________________________________________________________________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/

[-- Attachment #2: 120145053-pthread_test.cpp --]
[-- Type: application/octet-stream, Size: 721 bytes --]

#include <pthread.h>
#include <sys/time.h>

void Sleep(unsigned long ulMilliseconds)
{
    struct timeval timeout;
    timeout.tv_sec = 0;
    timeout.tv_usec = ulMilliseconds * 1000;
    select(1, NULL, NULL, NULL, &timeout);
} 

static void* threadFunc( void* lpParam ) 
{
   Sleep(3000);
}

int main()
{
  pthread_attr_t attr;

  int		n;
  bool res = false;

  if ( (n = ::pthread_attr_init(&attr)) != 0)
  {
    return -1;
  }
  pthread_t tid;

  if ( (n = ::pthread_create(&tid, &attr, threadFunc, 0)) == 0)
  {

    res = true;
  }

  if ( (n = ::pthread_attr_destroy(&attr)) != 0)
  {
    return -2;
  }
  if (!res)
  {
    return -3;
  }
  Sleep(5000);

  return 0;
}

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

* Re: gdb Stopped in pthread_create
  2007-07-24 15:50   ` gdb Stopped in pthread_create Oleg V. Zhylin
@ 2007-07-28  1:40     ` Jim Blandy
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Blandy @ 2007-07-28  1:40 UTC (permalink / raw)
  To: Oleg V. Zhylin; +Cc: gdb


"Oleg V. Zhylin" <ovz@yahoo.com> writes:
>   pthread_test.cpp demonstrates the problematic behavior. It is built
> using
>
>  g++ -g pthread_test.cpp -lpthread
>
>  The version numbers are
>
> $ cat /proc/version
> Linux version 2.6.21-1.3228.fc7
> (kojibuilder@xenbuilder2.fedora.redhat.com) (gcc version 4.1.2 20070502
> (Red Hat 4.1.2-12)) #1 SMP Tue Jun 12 15:37:31 EDT 2007
>
> and gdb snapshot for July 24th
>
> $ gdb --version
> GNU gdb 6.6.50.20070724
>
> Below is the log of gdb session
>
> $ gdb a.out
> GNU gdb 6.6.50.20070724
> Copyright (C) 2007 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and
> you are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> This GDB was configured as "i686-pc-linux-gnu"...
> Using host libthread_db library "/lib/libthread_db.so.1".
> (gdb) run
> Starting program: /home/cartcs/Work/gdb/pthread_create/a.out
> [Thread debugging using libthread_db enabled]
> [New Thread 0xb7f336d0 (LWP 22251)]
>
> [3]+  Stopped                 gdb a.out

Hi, Oleg.  Thanks for the test case.  I was unable to reproduce this
problem using the current GDB sources on my Fedora Core 6 system.
I'll be upgrading my machine to Fedora Core 7 soon; I'll give it a try
then.

$ cat pthread_test.cpp
#include <pthread.h>
#include <sys/time.h>

void Sleep(unsigned long ulMilliseconds)
{
    struct timeval timeout;
    timeout.tv_sec = 0;
    timeout.tv_usec = ulMilliseconds * 1000;
    select(1, NULL, NULL, NULL, &timeout);
} 

static void* threadFunc( void* lpParam ) 
{
   Sleep(3000);
}

int main()
{
  pthread_attr_t attr;

  int           n;
  bool res = false;

  if ( (n = ::pthread_attr_init(&attr)) != 0)
  {
    return -1;
  }
  pthread_t tid;

  if ( (n = ::pthread_create(&tid, &attr, threadFunc, 0)) == 0)
  {

    res = true;
  }

  if ( (n = ::pthread_attr_destroy(&attr)) != 0)
  {
    return -2;
  }
  if (!res)
  {
    return -3;
  }
  Sleep(5000);

  return 0;
}
$ g++ -g pthread_test.cpp -lpthread -o pthread_test
$ ../pub/bin/gdb pthread_test
GNU gdb 6.6.50.20070727-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/jimb/gdb/bug/pthread_test 
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f9a6d0 (LWP 15004)]
[New Thread 0xb7f99b90 (LWP 15007)]
[Thread 0xb7f99b90 (LWP 15007) exited]

Program exited normally.
(gdb) 


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

end of thread, other threads:[~2007-07-28  0:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-23  9:52 gdb Stopped in pthread_create Oleg V. Zhylin
2007-07-23 19:22 ` Jim Blandy
2007-07-24  9:11   ` breaking at thread exit Mayuresh Kulkarni
2007-07-24 15:50   ` gdb Stopped in pthread_create Oleg V. Zhylin
2007-07-28  1:40     ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox