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]

when can find_thread_pid (inferior_ptid) return NULL?


Hi.  Some places in gdb assert that find_thread_pid (inferior_ptid)
is never NULL.

e.g.

struct thread_info*
inferior_thread (void)
{
  struct thread_info *tp = find_thread_pid (inferior_ptid);
  gdb_assert (tp);
  return tp;
}

Other places check.  E.g.

make_cleanup_restore_current_thread:

      tp = find_thread_pid (inferior_ptid);
      if (tp)
	tp->refcount++;

Since delete_thread_1 has this:

  /* If this is the current thread, or there's code out there that
     relies on it existing (refcount > 0) we can't delete yet.  Mark
     it as exited, and notify it.  */
  if (tp->refcount > 0
      || ptid_equal (tp->ptid, inferior_ptid))
    {

I would expect that one can always assert
find_thread_pid (inferior_ptid) != NULL.

Is that true?
Or are there situations where it's not true?


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