This is the mail archive of the gdb-patches@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]

Re: [PATCH 2/2] Don't delete thread_info if refcount isn't zero


Pedro Alves <palves@redhat.com> writes:

>> -  tp = find_thread_ptid (old->inferior_ptid);
>> -
>> -  /* If the previously selected thread belonged to a process that has
>> -     in the mean time been deleted (due to normal exit, detach, etc.),
>> -     then don't revert back to it, but instead simply drop back to no
>> -     thread selected.  */
>
> This comment still makes sense, with a small tweak -- saying "deleted"
> has always been a bit misleading here:
>
>   /* If the previously selected thread belonged to a process that has
>      in the mean time exited (or killed, detached, etc.), then don't revert
>      back to it, but instead simply drop back to no thread selected.  */
>
> I'll be happy with restoring this comment alongside your new comment.

The comments describe something different from what the code does.  With
my patch, in make_cleanup_restore_current_thread, if we can find
thread_info by inferior_ptid, saved it in old->thread and increase the
refcount, so that it won't be deleted, but it can be marked as exited.
Then, in do_restore_current_thread_cleanup, 

+  if (old->thread != NULL
+      && find_inferior_ptid (old->thread->ptid) != NULL)
+    restore_current_thread (old->thread->ptid);
   else
     {
       restore_current_thread (null_ptid);

the first line means we previously selected one existing thread, we
still switch to that thread, which may be already marked as exited.  It
is nothing wrong as far as I can see.

-- 
Yao (齐尧)


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