linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Matteo Fortini <m.fortini@selcomgroup.com>
To: linuxppc-embedded@ozlabs.org
Subject: gdbserver not working with pthreads
Date: Thu, 18 Sep 2008 10:22:36 +0200	[thread overview]
Message-ID: <48D20FCC.6070602@selcomgroup.com> (raw)

[-- 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);
}


             reply	other threads:[~2008-09-18  8:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-18  8:22 Matteo Fortini [this message]
2008-09-19 12:26 ` gdbserver not working with pthreads Matteo Fortini
  -- strict thread matches above, loose matches on Subject: below --
2008-09-18 16:37 Sugathan, Rupesh

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=48D20FCC.6070602@selcomgroup.com \
    --to=m.fortini@selcomgroup.com \
    --cc=linuxppc-embedded@ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).