Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* SIG32/SIGTRAP issues
@ 2002-12-03 14:52 Paul Mundt
  2002-12-03 15:24 ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Mundt @ 2002-12-03 14:52 UTC (permalink / raw)
  To: gdb

[-- 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 --]

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

end of thread, other threads:[~2002-12-04 18:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-03 14:52 SIG32/SIGTRAP issues Paul Mundt
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

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