From: Paul Mundt <paul.mundt@timesys.com>
To: gdb@sources.redhat.com
Subject: SIG32/SIGTRAP issues
Date: Tue, 03 Dec 2002 14:52:00 -0000 [thread overview]
Message-ID: <1038959780.11721.54.camel@Origin> (raw)
[-- Attachment #1: Type: text/plain, Size: 4040 bytes --]
Hi,
I seem to be running into a bit of an odd problem. When I have a
threaded application thats shared, everything works fine .. in the event
that the application is statically linked however, gdb gets a SIG32 at
pthread_create() time and doesn't track the threads properly.
Using the following code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#define MAX_NUM_THREADS 1024
void *thread_func( void * not_used )
{
printf("Starting real thread %d\n", *(int *)not_used);
sleep(2);
printf("Ending thread\n");
}
main()
{
int i,j,k;
int num_of_threads;
pthread_t thread[MAX_NUM_THREADS];
printf("Enter the number of threads reqd(<=1024): ");
scanf("%d", &num_of_threads);
for ( i=0; i<num_of_threads; i++ ) {
printf("Starting thread %d\n", i);
if ( pthread_create( &(thread[i]), NULL, thread_func, &i ) != 0 )
perror("");
printf("created thread %d\n", i);
}
for ( i=0; i<num_of_threads; i++ ) {
pthread_join( thread[i], NULL );
}
}
Running shared, everything looks okay:
[root@lemur gdb-build]# gdb/gdb
GNU gdb 5.2.90_2002-12-03-cvs
Copyright 2002 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".
(gdb) file /mnt/test-shared
Reading symbols from /mnt/test-shared...done.
(gdb) break thread_func
Breakpoint 1 at 0x80485c6
(gdb) run
Starting program: /mnt/test-shared
[New Thread 1024 (LWP 24053)]
Enter the number of threads reqd(<=1024): 2
Starting thread 0
[New Thread 2049 (LWP 24054)]
[New Thread 1026 (LWP 24055)]
created thread 0
Starting thread 1
[Switching to Thread 1026 (LWP 24055)]
Breakpoint 1, 0x080485c6 in thread_func ()
(gdb) c
Continuing.
Starting real thread 1
[New Thread 2051 (LWP 24056)]
Ending thread
created thread 1
[Switching to Thread 2051 (LWP 24056)]
Breakpoint 1, 0x080485c6 in thread_func ()
(gdb) c
Continuing.
Starting real thread 1
Ending thread
Program exited with code 02.
(gdb)
But when I run it statically, I get the following:
[root@lemur gdb-build]# gdb/gdb
GNU gdb 5.2.90_2002-12-03-cvs
Copyright 2002 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".
(gdb) file /mnt/test-static
Reading symbols from /mnt/test-static...done.
(gdb) break thread_func
Breakpoint 1 at 0x80481e6
(gdb) run
Starting program: /mnt/test-static
Enter the number of threads reqd(<=1024): 2
Starting thread 0
Program received signal SIG32, Real-time event 32.
0x0804e6c6 in __sigsuspend (set=0xbfffe970) at
../sysdeps/unix/sysv/linux/sigsuspend.c:45
45 ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or
directory.
in ../sysdeps/unix/sysv/linux/sigsuspend.c
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
pthread_handle_sigrestart (sig=-1073747600) at pthread.c:825
825 pthread.c: No such file or directory.
in pthread.c
(gdb) c
Continuing.
created thread 0
Starting thread 1
and at that point it just sits there and hangs indefinitely.
If I omit the break, I don't get the SIGTRAP (obviously) and it runs
through fine, though I'm not able to track any kind of thread
information while its running.
Looking through the PRs and gdb/PROBLEMS, I don't see this mentioned
anywhere. Is this a known problem?
This same behavior is also observed under 5.2/5.2.1 on both x86/ppc.
Regards,
--
Paul Mundt <paul.mundt@timesys.com>
TimeSys Corporation
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]
next reply other threads:[~2002-12-03 22:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-03 14:52 Paul Mundt [this message]
2002-12-03 15:24 ` Daniel Jacobowitz
2002-12-03 15:30 ` H. J. Lu
2002-12-03 15:43 ` Daniel Jacobowitz
2002-12-03 15:58 ` H. J. Lu
2002-12-03 15:52 ` Andrew Cagney
2002-12-03 15:58 ` Daniel Jacobowitz
2002-12-03 16:09 ` H. J. Lu
2002-12-04 10:30 ` Paul Mundt
2002-12-04 10:44 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1038959780.11721.54.camel@Origin \
--to=paul.mundt@timesys.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox