* breakpoints and pthreads
@ 2004-05-20 1:37 Nick NoSpam
2004-05-24 9:22 ` Nick NoSpam
0 siblings, 1 reply; 4+ messages in thread
From: Nick NoSpam @ 2004-05-20 1:37 UTC (permalink / raw)
To: gdb
Hi,
I started using gdb a few months ago on RedHat (originally installed as
version 7.2). While doing so, my little test program--which spawns a
thread--would stop execution in all threads (the main process and the
spawned thread) when a breakpoint was hit. I read the documentation and
this is appropriate behavior:
Section 5.4 Stopping and starting multi-threaded programs
...
Whenever your program stops under GDB for any reason, *all* threads
of execution stop, not just the current thread.
I recently switched to Gentoo which uses newer versions of practically
all libraries than my RH 7.2. When I compile and run the same program
now, the spawned thread does not stop when a breakpoint is hit.
Here is the simple program:
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
static void *wait_thread(void *arg);
int main(int argc, char *argv[])
{
printf("[ main ] Program enter.\n");
pthread_t t;
int res = pthread_create(&t, NULL, wait_thread, NULL);
if(res != 0)
{
printf("[ main ] Error creating wait thread!\n");
}
printf("[ main ] Going to sleep...\n");
sleep(3);
printf("[ main ] Exitting...\n");
return(0);
}
static void *wait_thread(void *arg)
{
while(1)
{
printf("[ wait_thread ] Waiting in thread\n");
sleep(1);
}
}
Compiled with:
gcc -g threadtest.c -o threadtest -lpthread
Here is a snippet of the debug session:
nick@nimble gdbtest $ gdb threadtest
GNU gdb 6.1
Copyright 2004 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) break main
Breakpoint 1 at 0x8048444: file threadtest.c, line 9.
(gdb) break 18
Breakpoint 2 at 0x8048488: file threadtest.c, line 18.
(gdb) run
Starting program: /home/nick/gdbtest/threadtest
Breakpoint 1, main (argc=1, argv=0xbffff6c4) at threadtest.c:9
9 printf("[ main ] Program enter.\n");
(gdb) n
[ main ] Program enter.
12 int res = pthread_create(&t, NULL, wait_thread, NULL);
(gdb) n
[ wait_thread ] Waiting in thread
Program received signal SIG32, Real-time event 32.
0x4002ba34 in pthread_getconcurrency () from /lib/libpthread.so.0
(gdb) [ wait_thread ] Waiting in thread
[ wait_thread ] Waiting in thread
[ wait_thread ] Waiting in thread
[ wait_thread ] Waiting in thread
[ wait_thread ] Waiting in thread
[ wait_thread ] Waiting in thread
[ wait_thread ] Waiting in thread
The thread's output "[ wait_thread ] Waiting in thread" continues to
print despite the debugger stopped (in main).
Version Info:
gdb: 6.1 (configured as "i686-pc-linux-gnu")
gcc: 3.3.2 (Thread model: posix, configured with --enable-threads=posix)
glibc: 2.3.2
kernel: 2.6.5 (vanilla)
Regards,
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: breakpoints and pthreads
2004-05-20 1:37 breakpoints and pthreads Nick NoSpam
@ 2004-05-24 9:22 ` Nick NoSpam
2004-06-01 5:05 ` Nick NoSpam
0 siblings, 1 reply; 4+ messages in thread
From: Nick NoSpam @ 2004-05-24 9:22 UTC (permalink / raw)
To: gdb
Any ideas on this issue? Should I file a bug?
I fiddled w/ this a little more and found that setting a breakpoint in
the thread callback ('wait_thread' in the example below) causes
problems.
This is the output I get when the thread gets created:
Program received signal SIG32, Real-time event 32.
Cannot remove breakpoints because program is no longer writable.
It might be running in another process.
Further execution is probably impossible.
0x4002ba34 in pthread_getconcurrency () from /lib/libpthread.so.0
Regards,
Nick
On Wed, 2004-05-19 at 21:33, Nick NoSpam wrote:
> Hi,
>
> I started using gdb a few months ago on RedHat (originally installed as
> version 7.2). While doing so, my little test program--which spawns a
> thread--would stop execution in all threads (the main process and the
> spawned thread) when a breakpoint was hit. I read the documentation and
> this is appropriate behavior:
> Section 5.4 Stopping and starting multi-threaded programs
> ...
> Whenever your program stops under GDB for any reason, *all* threads
> of execution stop, not just the current thread.
>
> I recently switched to Gentoo which uses newer versions of practically
> all libraries than my RH 7.2. When I compile and run the same program
> now, the spawned thread does not stop when a breakpoint is hit.
>
> Here is the simple program:
> #include <stdio.h>
> #include <pthread.h>
> #include <unistd.h>
>
> static void *wait_thread(void *arg);
>
> int main(int argc, char *argv[])
> {
> printf("[ main ] Program enter.\n");
>
> pthread_t t;
> int res = pthread_create(&t, NULL, wait_thread, NULL);
> if(res != 0)
> {
> printf("[ main ] Error creating wait thread!\n");
> }
>
> printf("[ main ] Going to sleep...\n");
> sleep(3);
> printf("[ main ] Exitting...\n");
>
> return(0);
> }
>
> static void *wait_thread(void *arg)
> {
> while(1)
> {
> printf("[ wait_thread ] Waiting in thread\n");
> sleep(1);
> }
> }
>
>
> Compiled with:
> gcc -g threadtest.c -o threadtest -lpthread
>
> Here is a snippet of the debug session:
> nick@nimble gdbtest $ gdb threadtest
> GNU gdb 6.1
> Copyright 2004 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) break main
> Breakpoint 1 at 0x8048444: file threadtest.c, line 9.
> (gdb) break 18
> Breakpoint 2 at 0x8048488: file threadtest.c, line 18.
> (gdb) run
> Starting program: /home/nick/gdbtest/threadtest
>
> Breakpoint 1, main (argc=1, argv=0xbffff6c4) at threadtest.c:9
> 9 printf("[ main ] Program enter.\n");
> (gdb) n
> [ main ] Program enter.
> 12 int res = pthread_create(&t, NULL, wait_thread, NULL);
> (gdb) n
> [ wait_thread ] Waiting in thread
>
> Program received signal SIG32, Real-time event 32.
> 0x4002ba34 in pthread_getconcurrency () from /lib/libpthread.so.0
> (gdb) [ wait_thread ] Waiting in thread
> [ wait_thread ] Waiting in thread
> [ wait_thread ] Waiting in thread
> [ wait_thread ] Waiting in thread
> [ wait_thread ] Waiting in thread
> [ wait_thread ] Waiting in thread
> [ wait_thread ] Waiting in thread
>
>
> The thread's output "[ wait_thread ] Waiting in thread" continues to
> print despite the debugger stopped (in main).
>
>
> Version Info:
> gdb: 6.1 (configured as "i686-pc-linux-gnu")
> gcc: 3.3.2 (Thread model: posix, configured with --enable-threads=posix)
> glibc: 2.3.2
> kernel: 2.6.5 (vanilla)
>
>
> Regards,
> Nick
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: breakpoints and pthreads
2004-05-24 9:22 ` Nick NoSpam
@ 2004-06-01 5:05 ` Nick NoSpam
2004-06-01 11:46 ` pthread type 1x1 or MxN MuthuKumar-15
0 siblings, 1 reply; 4+ messages in thread
From: Nick NoSpam @ 2004-06-01 5:05 UTC (permalink / raw)
To: gdb
I finally found the cause of this problem--a stripped libpthread.
Gentoo strips it when emerging glibc. To avoid this in Gentoo, add
nostrip to FEATURES. ie:
$> FEATURES=nostrip emerge glibc
Regards,
Nick
On Mon, 2004-05-24 at 04:28, Nick NoSpam wrote:
> Any ideas on this issue? Should I file a bug?
>
> I fiddled w/ this a little more and found that setting a breakpoint in
> the thread callback ('wait_thread' in the example below) causes
> problems.
> This is the output I get when the thread gets created:
>
> Program received signal SIG32, Real-time event 32.
> Cannot remove breakpoints because program is no longer writable.
> It might be running in another process.
> Further execution is probably impossible.
> 0x4002ba34 in pthread_getconcurrency () from /lib/libpthread.so.0
>
> Regards,
> Nick
>
>
> On Wed, 2004-05-19 at 21:33, Nick NoSpam wrote:
> > Hi,
> >
> > I started using gdb a few months ago on RedHat (originally installed as
> > version 7.2). While doing so, my little test program--which spawns a
> > thread--would stop execution in all threads (the main process and the
> > spawned thread) when a breakpoint was hit. I read the documentation and
> > this is appropriate behavior:
> > Section 5.4 Stopping and starting multi-threaded programs
> > ...
> > Whenever your program stops under GDB for any reason, *all* threads
> > of execution stop, not just the current thread.
> >
> > I recently switched to Gentoo which uses newer versions of practically
> > all libraries than my RH 7.2. When I compile and run the same program
> > now, the spawned thread does not stop when a breakpoint is hit.
> >
> > Here is the simple program:
> > #include <stdio.h>
> > #include <pthread.h>
> > #include <unistd.h>
> >
> > static void *wait_thread(void *arg);
> >
> > int main(int argc, char *argv[])
> > {
> > printf("[ main ] Program enter.\n");
> >
> > pthread_t t;
> > int res = pthread_create(&t, NULL, wait_thread, NULL);
> > if(res != 0)
> > {
> > printf("[ main ] Error creating wait thread!\n");
> > }
> >
> > printf("[ main ] Going to sleep...\n");
> > sleep(3);
> > printf("[ main ] Exitting...\n");
> >
> > return(0);
> > }
> >
> > static void *wait_thread(void *arg)
> > {
> > while(1)
> > {
> > printf("[ wait_thread ] Waiting in thread\n");
> > sleep(1);
> > }
> > }
> >
> >
> > Compiled with:
> > gcc -g threadtest.c -o threadtest -lpthread
> >
> > Here is a snippet of the debug session:
> > nick@nimble gdbtest $ gdb threadtest
> > GNU gdb 6.1
> > Copyright 2004 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) break main
> > Breakpoint 1 at 0x8048444: file threadtest.c, line 9.
> > (gdb) break 18
> > Breakpoint 2 at 0x8048488: file threadtest.c, line 18.
> > (gdb) run
> > Starting program: /home/nick/gdbtest/threadtest
> >
> > Breakpoint 1, main (argc=1, argv=0xbffff6c4) at threadtest.c:9
> > 9 printf("[ main ] Program enter.\n");
> > (gdb) n
> > [ main ] Program enter.
> > 12 int res = pthread_create(&t, NULL, wait_thread, NULL);
> > (gdb) n
> > [ wait_thread ] Waiting in thread
> >
> > Program received signal SIG32, Real-time event 32.
> > 0x4002ba34 in pthread_getconcurrency () from /lib/libpthread.so.0
> > (gdb) [ wait_thread ] Waiting in thread
> > [ wait_thread ] Waiting in thread
> > [ wait_thread ] Waiting in thread
> > [ wait_thread ] Waiting in thread
> > [ wait_thread ] Waiting in thread
> > [ wait_thread ] Waiting in thread
> > [ wait_thread ] Waiting in thread
> >
> >
> > The thread's output "[ wait_thread ] Waiting in thread" continues to
> > print despite the debugger stopped (in main).
> >
> >
> > Version Info:
> > gdb: 6.1 (configured as "i686-pc-linux-gnu")
> > gcc: 3.3.2 (Thread model: posix, configured with --enable-threads=posix)
> > glibc: 2.3.2
> > kernel: 2.6.5 (vanilla)
> >
> >
> > Regards,
> > Nick
> >
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* pthread type 1x1 or MxN
2004-06-01 5:05 ` Nick NoSpam
@ 2004-06-01 11:46 ` MuthuKumar-15
0 siblings, 0 replies; 4+ messages in thread
From: MuthuKumar-15 @ 2004-06-01 11:46 UTC (permalink / raw)
To: gdb
Hello All
I have a need as How to check at run time, whether a running application uses 1X1 or MXN thread model on HP-UNIX platform?
Is there any symbols to identify the type of threads ,the application uses ?
Regards,
Muthukumar.
---
=============== It is a "Virus Free Mail" ===============
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 5/28/2004
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-01 11:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-20 1:37 breakpoints and pthreads Nick NoSpam
2004-05-24 9:22 ` Nick NoSpam
2004-06-01 5:05 ` Nick NoSpam
2004-06-01 11:46 ` pthread type 1x1 or MxN MuthuKumar-15
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox