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] Use "switch_to_thread" more thoroughly on gdbserver


On Thursday, September 21 2017, Pedro Alves wrote:

> On 09/15/2017 07:25 PM, Sergio Durigan Junior wrote:
>> On Friday, September 15 2017, Pedro Alves wrote:
>> 
>>> Do you remember why that check is there in switch_to_thread in the
>>> first place, as opposed to, say, an assertion?
>> 
>> I tried to do some archaeology here and find the patch that implemented
>> this feature, and it seems to me that the patch always used 'if' instead
>> of an 'assert'.  
>
> Yeah, gdbserver's switch_to_thread was added with your fork
> inferior sharing series.

Exactly.

>> Maybe that's because GDB's version of switch_to_thread
>> also doesn't assert that ptid != minus_one_ptid...
>
> Except it does:
>
> static void
> switch_to_thread (thread_info *thr)
> {
>   gdb_assert (thr != NULL);
>   ^^^^^^^^^^^^^^^^^^^^^^^^
> ...
>
> Called from:
>
> void
> switch_to_thread (ptid_t ptid)
> {
>   if (ptid == null_ptid)
>     switch_to_no_thread ();
>   else
>     switch_to_thread (find_thread_ptid (ptid));
> }
>
> ... and find_thread_ptid returns NULL because there's
> never a thread with ptid == minus_one_ptid.

Oh.  There's an overload, then.  And there's also a check to see if ptid
== null_ptid.  Maybe it's worth extending gdbserver's switch_to_thread
to mimic that behaviour.

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


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