This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Q: GDB - Threads


I'm here again...

Tried all suggestions... but still not working. 

I guess I'm missing something but ..... What?
Some ideas or hints, or some places ..where to find more info ?
I've been digging in the GDB-manual and mailing list for some time
now... :-( :-( 


I'll try to give a small resume of what I'm trying to do.

*HOST : PC (ubuntu 9.04)
*TARGET : ARM (at91sam9g20)
*Buildsystem: buildroot 06/2009 - uclibc-0.9.30.1, gdb 6.8,gcc-4.3.3
*Striping : TURNED OFF. (for all files, this also means libs)
*Test-Application : a simpe applciation that uses PTHREAD's!! 
*GDB: GDB / Gdbserver 6.8 for ARM (all is built for arm-linux-uclibc- )


When the application is run in 'remote-'gdb the application 'HANGS' as
soon as the second thread is created.

(target : gdbserver *:9000 ./threading)
(host : gdb - over TCP/IP -> target ip-address port 9000)

>>> target console log <<<
# gdbserver *:9000 ./threading 
Process ./threading created; pid = 905
Listening on port 9000
Remote debugging from host 150.158.205.4
Creating thread 0

0: Hello World! 0 
Creating thread 1

0: Hello World! 1
 
--->> and now .. the target is 'HANGING' <<---------




>> a normal run on the target ARM -- gives me the expected output <<

When the Test-application runs STAND-ALONE on the target (normal
behavoir... As expected ;-))
./threading 
Creating thread 0
0: Hello World! 0 
Creating thread 1
1: Hello World! 0 
Creating thread 2
2: Hello World! 0 
Creating thread 3
3: Hello World! 0 
Creating thread 4
4: Hello World! 0 
Sleeping/printing in main ..... 
printing in main 0 
0: Hello World! 1 
1: Hello World! 1 
2: Hello World! 1 
<< some things.. Are removed here >>
 Hello World! 19 

4: Hello World! 19 
printing in main 19 
printing in main 20 
printing in main 21 
printing in main 22 
printing in main 23 
printing in main 24 
printing in main 25 
printing in main 26 
printing in main 27 
printing in main 28 
printing in main 29 
Sleeping in main ..... DONE .. 


What I do not understand is the following:
Most people (that have responded, again THANKS for all responses, and
sorry I'll keep on bothering you all, but I'm just trying to get my
DEBUGGING problem solved..) point me to the fact that my libs
(especially libthread_db) would be a wrong version..

But here it comes ... I can't see/understand why I would need
libthread_db .. I'm using pthreads !
In fact the only thing I try (at this time) is to step in the 'main' of
the program, even not in a 'p'thread.


<< please have a look at this GDB-CONSOLE-LOG  >>

/buildhome/20090601/buildroot/toolchain_build_arm/gdbhost-6.8/gdb$ ./gdb

GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "--host=i386-pc-linux-gnu
--target=arm-linux-uclibc".
Setting up the environment for debugging gdb.
Setting up the environment for debugging gdb - DONE .
Breakpoint 1 at 0x8784: file sources/main.c, line 46.
(NOEL2-gdb) run
Starting program: /tmp/threading 
[New Thread 906]
[Switching to Thread 906]
Stopped due to shared library event
(NOEL2-gdb) c
Continuing.
Stopped due to shared library event
(NOEL2-gdb) info shared li
From        To          Syms Read   Shared Object Library
0x40000930  0x40003eb0  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
d-uClibc.so.0
0x40011cc0  0x4001820c  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
ibpthread.so.0
0x40029ca0  0x40030ec4  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
ibgcc_s.so.1
0x40044c90  0x400855b0  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
ibc.so.0
(NOEL2-gdb) info breakpoints 
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x00008784 in main at sources/main.c:46
(NOEL2-gdb) l
37	  }
38	   pthread_exit(NULL);
39	}
40	
41	int main()
42	{
43	   pthread_t threads[NUM_THREADS];
44	   int rc, t;
45	   for(t=0;t<NUM_THREADS;t++){
46	      printf("Creating thread %d\r\n", t);
(NOEL2-gdb) l
47	      rc = pthread_create(&threads[t], NULL, PrintHello, (void
*)t);
48	      if (rc){
49	         printf("ERROR; return code from pthread_create() is
%d\r\n", rc);
50	         exit(-1);
51	      }
52	   }
53	
54	   printf("Sleeping/printing in main ..... \r\n");
55	   {
56		   int n;
(NOEL2-gdb) b main.c:48
Breakpoint 2 at 0x87f8: file sources/main.c, line 48.
(NOEL2-gdb) c
Continuing.

Breakpoint 1, main () at sources/main.c:46
46	      printf("Creating thread %d\r\n", t);
(NOEL2-gdb) info breakpoints 
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x00008784 in main at sources/main.c:46
	breakpoint already hit 1 time
2       breakpoint     keep y   0x000087f8 in main at sources/main.c:48
(NOEL2-gdb) info shared li
From        To          Syms Read   Shared Object Library
0x40000930  0x40003eb0  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
d-uClibc.so.0
0x40011cc0  0x4001820c  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
ibpthread.so.0
0x40029ca0  0x40030ec4  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
ibgcc_s.so.1
0x40044c90  0x400855b0  Yes
/buildhome/20090601/buildroot/project_build_arm/at91sam9g20ek/root/lib/l
ibc.so.0
(NOEL2-gdb) c
Continuing.

Breakpoint 2, main () at sources/main.c:48
48	      if (rc){
(NOEL2-gdb) info breakpoints 
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x00008784 in main at sources/main.c:46
	breakpoint already hit 1 time
2       breakpoint     keep y   0x000087f8 in main at sources/main.c:48
	breakpoint already hit 1 time
(NOEL2-gdb) c
Continuing.
<< HANGING >>



I would expect the GDB-debugger to stop at main.c:48 (the break point is
still there ...) but it doesn't. (and the programs HANGS forever)!



The Target Console output I get is :
Remote debugging from host 150.158.205.4
Process /tmp/threading created; pid = 906
Creating thread 0

0: Hello World! 0 
Creating thread 1

0: Hello World! 1 

<< HANGING >>






Kind regards,


Noel.



 

-----Original Message-----
From: Daniel Jacobowitz [mailto:drow@false.org] 
Sent: 2Jun09 21:34
To: Paul Pluzhnikov
Cc: Vellemans, Noel; gdb@sourceware.org
Subject: Re: Q: GDB - Threads

On Tue, Jun 02, 2009 at 11:34:40AM -0700, Paul Pluzhnikov wrote:
> On Tue, Jun 2, 2009 at 11:17 AM, Daniel Jacobowitz <drow@false.org>
wrote:
> 
> > GDB never uses libthread_db on the host if it is debugging a remote 
> > target.
> 
> Oops. Sorry, my mistake.
> 
> I guess then OP needs to verify that GDB is loading symbols from 
> expected libpthread ("set verbose on" should show that), and that 
> gdbserver on target is loading expected libthread_db ("ldd gdbserver" 
> on target should show that).

Right.  I don't remember if gdbserver's debug output helps with this or
not.

--
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]