Re: [coldfire-gnu-discuss] m5272, gdb/gdbserver and uClinux/pthreads... again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coldfire-gnu-discuss] m5272, gdb/gdbserver and uClinux/pthreads... again
- To: Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
- Subject: Re: [coldfire-gnu-discuss] m5272, gdb/gdbserver and uClinux/pthreads... again
- From: Harry Gunnarsson <mrharryg@xxxxxxxxx>
- Date: Tue, 18 May 2010 08:37:35 -0700
Thanks for the reply,
I haven't been able to find a uClinux distro on freescale website. Would you
by any chance have a link to that LTIB?
Example:
I attached a very simple app that uses pthreads. I compile this with
'-mcpu=5272 -g3 -pthread' and link this to 'jth'
I pick up 'gdbserver' from
freescale-coldfire-4.4//m68k-uclinux/libc/m5206e/usr/lib. And I copy them to
jffs2 file system on the board.
Now I simply run it like:
> ./gdbserver :5555 ./jth
And from host I connect with (with gdb from same compiler as used above
compiling the source)
$ m68k-uclinux-gdb jth.gdb
..
target remote IP:5555
Now the instance I connect, the gdbserver bails out saying that it couldn't
find 'inferior'. I believe this is a thread thing.
I can however:
- debug a non thread program with the above scheme
- without the debugger, run 'jth' correctly
Let me know if I can provide further details about the test case
Harry
On Tue, May 18, 2010 at 7:44 AM, Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>wrote:
> On 5/18/10 8:53 AM, Harry Gunnarsson wrote:
>
>> Hi,
>> Back in march 8th I inquired about pthread debugging under uClinux using
>> gdbserver and Maxim and I had a brief discussion on the topic(you could
>> look up the thread on codesourcery website). I believe his stance was
>> that it should work. I tested again using the brand new 4.4-216, but I
>> am still unsuccessful debugging pthread apps under uclinux.
>> Recap; this used to work using uclinux 2007 and CodeSourcery 4.2. Now
>> with newer kernel/distro and newer toolchain, it doesn't work; once
>> doing 'target remote' from host, gdbserver bails out. Also, debugging
>> non-threaded apps works perfectly.
>>
>> BTW, I am using the uClinux distro from uclinux.org <http://uclinux.org>.
>>
>
> FWIW, we test our toolchains against LTIB rootfs.
>
>
>
>> Some other postings on the mailing lists got me wondered;
>> - Is there anything in the kernel configuration that is required for
>> debugging pthreads?
>>
>> Does anyone had any success doing this kind of debugging?
>>
>
> Can you provide a simple testcase that uses pthreads and debugging which
> does not work?
>
> Thank you,
>
> --
> Maxim Kuvyrkov
> CodeSourcery
> maxim@xxxxxxxxxxxxxxxx
> (650) 331-3385 x724
>
#include <stdio.h>
#include <pthread.h>
#define NTHREADS 10
void *thread_function(void *);
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int counter = 0;
main()
{
pthread_t thread_id[NTHREADS];
int i, j;
for(i=0; i < NTHREADS; i++)
{
pthread_create( &thread_id[i], NULL, thread_function, NULL );
}
for(j=0; j < NTHREADS; j++)
{
pthread_join( thread_id[j], NULL);
}
/* Now that all threads are complete I can print the final result. */
/* Without the join I could be printing a value before all the threads */
/* have been completed. */
printf("Final counter value: %d\n", counter);
}
void *thread_function(void *dummyPtr)
{
printf("Thread number %ld\n", pthread_self());
pthread_mutex_lock( &mutex1 );
counter++;
pthread_mutex_unlock( &mutex1 );
}