This is the mail archive of the
mailing list for the GDB project.
Re: when can find_thread_pid (inferior_ptid) return NULL?
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb at sourceware dot org
- Cc: Doug Evans <dje at google dot com>
- Date: Thu, 26 Mar 2009 22:35:09 +0000
- Subject: Re: when can find_thread_pid (inferior_ptid) return NULL?
- References: <20090326213642.B9E771C74E3@localhost>
On Thursday 26 March 2009 21:36:42, Doug Evans wrote:
> Hi. Some places in gdb assert that find_thread_pid (inferior_ptid)
> is never NULL.
> tp = find_thread_pid (inferior_ptid);
> if (tp)
I think that in this particular case, it will always be true.
> 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?
When inferior_ptid is null_ptid. You'll also not
find the old ptid if running the cleanup after something
clears the thread list, e.g., after killing or poping the target.