Hi, This patch makes it so that right after a fork-child, we add the main task of the inferior to GDB's thread tables. We don't have lwp or thread info at this point, which means that targets should decorate more of inferior_ptid as soon as they have the chance. Some targets will do it as soon as we get to the first target_wait, others, will only have info available when a thread library is loaded. The issue of changing inferior_ptid to accomodate a new ptid that represents the same task, in GDB's perspective is not new. See below for examples are all over the place. Since we're now making sure inferior_ptid is always in the thread list, when we update it to include more lwp or tid info, we also need to make sure that entry in the thread list is updated. In addition, if there are other GDB's sub-components that were holding info on this thread, we should be able to inform them of the ptid change. Hence, I'm adding a new thread_change_ptid function, which takes care of updating the thread table, and a new observer that is called by this function, so other modules can react: @deftypefun void thread_ptid_changed (ptid_t @var{old_ptid}, ptid_t @var{new_ptid}) The thread's ptid has changed. The @var{old_ptid} parameter specifies the old value, and @var{new_ptid} specifies the new value. @end deftypefun I'm including the linux-nat.c change in this patch, for an example usable. The following patches in the series will introduce more uses. The whole series was tested on x86_64-unknown-linux-gnu, i386-pc-solaris2.11 (OpenSolaris 10), i386-unknown-openbsd4.3, i386-unknown-freebsd6.0, i386-unknown-freebsd7.0 and i686-unknown-gnu0.3 (Debian GNU/Hurd). OK, when the rest of the series is OK? -------- infrun.c: /* The call to in_thread_list is necessary because PTIDs sometimes change when we go from single-threaded to multi-threaded. If the singlestep_ptid is still in the list, assume that it is really different from ecs->ptid. */ if (!ptid_equal (singlestep_ptid, ecs->ptid) && in_thread_list (singlestep_ptid)) { bsd-uthread.c: /* HACK: Twiddle INFERIOR_PTID such that the initial thread of a process isn't recognized as a new thread. */ if (ptid_get_tid (ptid) != 0 && !in_thread_list (ptid) && ptid_get_tid (inferior_ptid) == 0) { add_thread_silent (ptid); inferior_ptid = ptid; } linux-nat.c: /* The first time we get here after starting a new inferior, we may not have added it to the LWP list yet - this is the earliest moment at which we know its PID. */ if (num_lwps == 0) { gdb_assert (!is_lwp (inferior_ptid)); inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid)); inf-trace.c: /* HACK: Twiddle INFERIOR_PTID such that the initial thread of a process isn't recognized as a new thread. */ if (ptid_get_lwp (inferior_ptid) == 0) inferior_ptid = ptid; -- Pedro Alves