public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdb-gdbserver, non-stop, async - thread identifier more than only a thread id?
@ 2011-07-02 13:54 D. Lehne
  2011-07-06 20:58 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: D. Lehne @ 2011-07-02 13:54 UTC (permalink / raw)
  To: gdb

Hello,

i've made a startup for a remote debug session on an ARM target by using 
async, non-stop mode. The environment to control this is Eclipse 3.2 - 
Embedded Debug (Native).

The settings are the following:
set target-async on
set pagination on
set non-stop on
set sysroot /home/xxx
set solib-search-path /home/yyy
set auto-solib-add on
target extended-remote 192.168.0.243:1234
remote put /home/xxx.so.0 /usr/local/xxx.so.0
remote put /home/xxx.dat
set remote exec-file xxx.dat

This means the main task is xxx.dat and loads a shared library xxx.so.0, 
which i want to debug. This library is creating a lot of new threads 
(based on libpthread.so).
In non-stop mode the breakpoint is on the first created thread and step 
for step i can see how new threads are created. I looks like this example:

   3 Thread 692.694  (running)
   2 Thread 692.693  (running)
* 1 Thread 692.692  SInit () at ../system/module/SMain.cpp:923

There are 3 threads, but it isn't clear which thread represents which 
functionality (fucntion call) . When a thread is created, isn't it 
possible to refer the first function call on stack as an reference name 
of a thread?

Basically a thread represents:

|void *start_routine(void*)
{
  while(1)
  {
   ... thread routines
  }
}|

created by :

|#include<pthread.h  <http://pubs.opengroup.org/onlinepubs/007908799/xsh/pthread.h.html>>

int pthread_create(pthread_t */thread/, const pthread_attr_t */attr/,
     void *(*/start_routine/)(void*), void */arg/);|


So on stack the address &start_routine is pushed on first position which 
could transmitted to gdb which refers by the memory map of the object 
file the relevant function name start_routine(). So in the gdb session 
it seems to be more user-friendly than an thread id only. And could 
shown as:

   3 Thread 692.694  start_routine2(running)
   2 Thread 692.693  start_routine1(running)
* 1 Thread 692.692  SInit () at ../system/module/SMain.cpp:923
|

|Best regards!

-- 
D. Lehne
Dep. Development

AMK Drives and Controls Ltd.
Bulgaria / Gabrovo

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

* Re: gdb-gdbserver, non-stop, async - thread identifier more than only a thread id?
  2011-07-02 13:54 gdb-gdbserver, non-stop, async - thread identifier more than only a thread id? D. Lehne
@ 2011-07-06 20:58 ` Tom Tromey
  2011-07-06 23:44   ` Petr Hluzín
  2011-07-11  5:58   ` D. Lehne
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey @ 2011-07-06 20:58 UTC (permalink / raw)
  To: D. Lehne; +Cc: gdb

>>>>> "D" == D Lehne <daniel.lehne@amk-drives.bg> writes:

D> There are 3 threads, but it isn't clear which thread represents which
D> functionality (fucntion call) . When a thread is created, isn't it
D> possible to refer the first function call on stack as an reference
D> name of a thread?

I guess it would be possible, but I don't know if it is desirable.

You can name threads manually now.  So, you could perhaps script this if
you wanted.

Tom

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

* Re: gdb-gdbserver, non-stop, async - thread identifier more than only a thread id?
  2011-07-06 20:58 ` Tom Tromey
@ 2011-07-06 23:44   ` Petr Hluzín
  2011-07-07 14:08     ` Tom Tromey
  2011-07-11  5:58   ` D. Lehne
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Hluzín @ 2011-07-06 23:44 UTC (permalink / raw)
  To: Tom Tromey; +Cc: D. Lehne, gdb

On 6 July 2011 22:57, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "D" == D Lehne <daniel.lehne@amk-drives.bg> writes:
>
> D> There are 3 threads, but it isn't clear which thread represents which
> D> functionality (fucntion call) . When a thread is created, isn't it
> D> possible to refer the first function call on stack as an reference
> D> name of a thread?
>
> I guess it would be possible, but I don't know if it is desirable.

What about using the first function call on stack only if OS (or
remote target) does not report the name? And of course allow
overriding from command line.

I guess it would be useful to skip the first several functions which
are always there. (E.g. OS thread entry, C runtime
initialization/deinitialization, a fancy framework init/deinit
routine, and finally the function the user wanted.)

Daniel: The command is "thread name", see [1]

[1] http://sourceware.org/gdb/current/onlinedocs/gdb/Threads.html

-- 
Petr Hluzin

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

* Re: gdb-gdbserver, non-stop, async - thread identifier more than only a thread id?
  2011-07-06 23:44   ` Petr Hluzín
@ 2011-07-07 14:08     ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2011-07-07 14:08 UTC (permalink / raw)
  To: Petr Hluzín; +Cc: D. Lehne, gdb

>>>>> "Petr" == Petr Hluzín <petr.hluzin@gmail.com> writes:

Petr> I guess it would be useful to skip the first several functions which
Petr> are always there. (E.g. OS thread entry, C runtime
Petr> initialization/deinitialization, a fancy framework init/deinit
Petr> routine, and finally the function the user wanted.)

Yeah, this is one reason I think it may not be advisable to do this in
GDB.  Putting this information into GDB doesn't seem very good.

I think it is easy enough to script this.

Tom

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

* Re: gdb-gdbserver, non-stop, async - thread identifier more than only a thread id?
  2011-07-06 20:58 ` Tom Tromey
  2011-07-06 23:44   ` Petr Hluzín
@ 2011-07-11  5:58   ` D. Lehne
  1 sibling, 0 replies; 5+ messages in thread
From: D. Lehne @ 2011-07-11  5:58 UTC (permalink / raw)
  To: gdb

On 06.7.2011 г. 23:57, Tom Tromey wrote:
>>>>>> "D" == D Lehne<daniel.lehne@amk-drives.bg>  writes:
> D>  There are 3 threads, but it isn't clear which thread represents which
> D>  functionality (fucntion call) . When a thread is created, isn't it
> D>  possible to refer the first function call on stack as an reference
> D>  name of a thread?
>
> I guess it would be possible, but I don't know if it is desirable.
>
> You can name threads manually now.  So, you could perhaps script this if
> you wanted.
>
> Tom
>
>
Hello,

Thanks for your opinions and advises !

>The command is "thread name", see [1]
>[1]http://sourceware.org/gdb/current/onlinedocs/gdb/Threads.html

... was an unknown field for me. So i will script this in .gdbinit.

Best regards!


-- 
D. Lehne
Dep. Development

AMK Drives and Controls Ltd.
Bulgaria / Gabrovo

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

end of thread, other threads:[~2011-07-11  5:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-02 13:54 gdb-gdbserver, non-stop, async - thread identifier more than only a thread id? D. Lehne
2011-07-06 20:58 ` Tom Tromey
2011-07-06 23:44   ` Petr Hluzín
2011-07-07 14:08     ` Tom Tromey
2011-07-11  5:58   ` D. Lehne

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 read-only IMAP folder(s) and NNTP newsgroup(s).