linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* gdbserver not working with pthreads
@ 2008-09-18  8:22 Matteo Fortini
  2008-09-19 12:26 ` Matteo Fortini
  0 siblings, 1 reply; 3+ messages in thread
From: Matteo Fortini @ 2008-09-18  8:22 UTC (permalink / raw)
  To: linuxppc-embedded

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

I'm using gdbserver & gdb-cross built on OpenEmbedded, both versions 6.6 
and 6.8 on FSL kernel 2.6.24.6 with an MPC5121 cpu, glibc 2.6.1

Gdb on the target is working properly, and can debug threads the usual way.

When debugging with gdbserver/gdb the debugger loses control of the 
threads. I did set the sysroot variable right, and I don't get the ld 
not found error message.
 Basically, I cannot step into pthread_create, without losing control, 
with the software not running and gdb going timeout. Sometimes the 
gdbserver shell prints out "ptrace(): pid not found", or I get E01 reply 
on the gdb-cross. Putting breakpoints into threads works sometimes.
My ultimate goal would be to make it work with Eclipse, but it's a long 
way from having it working with such a system.

I attach the simple software I'm using to test it.

I also tried setting the target architecture to values other than 
powerpc:common, but it didn't help.

Thank you for any clue,
Matteo

[-- Attachment #2: test1.c --]
[-- Type: text/plain, Size: 1411 bytes --]

/*
 *  * p_hello.c -- a hello program (in pthread)
 *   */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <pthread.h>

#define MAX_THREAD 5

typedef struct {
	int id;
} parm;

void *hello(void *arg)
{
	int i;

	parm *p=(parm *)arg;

	for(i=0;i<100;i++) {
		printf("Hello from node %d iteration %d\n", p->id, i);
	
		sleep (1);
	}

	return (NULL);
}

void *hello2(void *arg)
{
	int i;

	parm *p=(parm *)arg;

	for(i=0;i<100;i++) {
		printf("Hello2 from node %d iteration %d\n", p->id, i);

		sleep (1);
	}

	return (NULL);
}


int main(int argc, char* argv[]) {
	int n,i;
	pthread_t *threads;
	pthread_attr_t pthread_custom_attr;
	parm *p;

	if (argc != 2)
	{
		printf ("Usage: %s n\n  where n is no. of threads\n",argv[0]);
		exit(1);
	}

	n=atoi(argv[1]);

	if ((n < 1) || (n > MAX_THREAD))
	{
		printf ("The no of thread should between 1 and %d.\n",MAX_THREAD);
		exit(1);
	}

	threads=(pthread_t *)malloc(n*sizeof(*threads));
	pthread_attr_init(&pthread_custom_attr);

	p=(parm *)malloc(sizeof(parm)*n);
	/* Start up thread */

	for (i=0; i<n; i++)
	{
		p[i].id=i;
		if(i % 2)
			pthread_create(&threads[i], &pthread_custom_attr, hello, (void *)(p+i));
		else 	pthread_create(&threads[i], &pthread_custom_attr, hello2, (void *)(p+i));

	}

	/* Synchronize the completion of each thread. */

	for (i=0; i<n; i++)
	{
		pthread_join(threads[i],NULL);
	}
	free(p);
}


^ permalink raw reply	[flat|nested] 3+ messages in thread
* RE: gdbserver not working with pthreads
@ 2008-09-18 16:37 Sugathan, Rupesh
  0 siblings, 0 replies; 3+ messages in thread
From: Sugathan, Rupesh @ 2008-09-18 16:37 UTC (permalink / raw)
  To: Matteo Fortini, linuxppc-embedded


> When debugging with gdbserver/gdb the debugger loses control=20
> of the threads. I did set the sysroot variable right, and I=20
> don't get the ld not found error message.
>  Basically, I cannot step into pthread_create, without losing=20
> control, with the software not running and gdb going timeout.=20
> Sometimes the gdbserver shell prints out "ptrace(): pid not=20
> found", or I get E01 reply on the gdb-cross. Putting=20
> breakpoints into threads works sometimes.
> My ultimate goal would be to make it work with Eclipse, but=20
> it's a long way from having it working with such a system.

Try to change the way GDB handle some of the signals, I don't recall
which signal in this respect though. You can do this using the 'handle'
command.

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

end of thread, other threads:[~2008-09-19 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18  8:22 gdbserver not working with pthreads Matteo Fortini
2008-09-19 12:26 ` Matteo Fortini
  -- strict thread matches above, loose matches on Subject: below --
2008-09-18 16:37 Sugathan, Rupesh

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 NNTP newsgroup(s).