AIX, always a thread, experimental patch

Pedro Alves pedro@codesourcery.com
Tue Aug 19 17:08:00 GMT 2008


Hi,

I've given another look at aix-thread.c, in an effort to make it work with the
always-a-thread changes, and came up with the attached patch.  It is obviously
not finished, but it should point at the direction we should take (I hope).

I still can't tell if rs6000_wait can ever return a ptid different from 
pid_to_ptid(main_process_pid), (or -1).  I assume that GDB is already assuming
that libpthdebug.a is always available, as IBM's docs claim AIX can operate
under an M:N model (aix-threads.c seems to manage that), but there isn't 
anything in rs6000-nat.c managing lwps.  I hope this is not relying on
handle_inferior_event:new_thread_event when debugging a thread app, and 
libpthdebug.a isn't available for some reason or for debugging lwp based
apps that don't use pthreads.  ptids representing the lwps of the same
inferior should be of the form (pid,lwpid,0), not (lwpid,0,0), as it
would happen if rs6000-nat.c relied on new_thread_event.

As I mentioned before, one needs to:

 1) make sure the core never gets a thread related event
    that corresponds to a thread the core doesn't know
    about yet.

 2) #1 implies that every target should register the main thread, even when
    debugging a single-threaded app.
    rs6000-nat.c, being a ptrace based target, already has that covered by
    these:
   http://sourceware.org/ml/gdb-patches/2008-08/msg00505.html
   http://sourceware.org/ml/gdb-patches/2008-08/msg00171.html

 3) #2 implies that a thread_stratum layer should decorate the main thread's
    ptid with thread id info, instead of adding it again. That's 
    thread_change_ptid which is already in the tree.

The attached patch is a first try at it.  Hopefully the changes are 
self-explanatory and the comments point at what to do if things crash badly.

In case I've missed something big, it is my undertanding that the target stack
on AIX is:

threaded:
 aix-thread.c                       (thread_stratum)
 rs6000-nat.c extends inf-ptrace.c  (process_stratum)

non-threaded:
 rs6000-nat.c extends inf-ptrace.c  (process_stratum)

This patch depends on these other patches:

This one for the fork-child.c change:
http://sourceware.org/ml/gdb-patches/2008-08/msg00505.html

This one for the inf-ptrace.c change:
http://sourceware.org/ml/gdb-patches/2008-08/msg00171.html

The thread_change_ptid function is already checked in.

I hope this helps.

-- 
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aix_thread_always_a_thread.diff
Type: text/x-diff
Size: 3533 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080819/a4913cb5/attachment.bin>


More information about the Gdb-patches mailing list