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] remote.c: Ensure that inferior_ptid is on the thread list


On 07/18/2015 09:27 PM, Kevin Buettner wrote:

> I'm wary about adding an additional check to make sure that nothing
> follows the thread id.  It could be that there's something innocuous
> there.  That said, if you really want it in there, I'll revise my
> patch again.

We could add a debug log, so that someone working on some
random stub sees the issue early.  My thinking is that with the fix
in place, it's easy to miss the stub bug, as the first thread will
usually be the thread that the remote side says is current too.

static ptid_t
remote_current_thread (ptid_t oldpid)
{
  struct remote_state *rs = get_remote_state ();

  putpkt ("qC");
  getpkt (&rs->buf, &rs->buf_size, 0);
  if (rs->buf[0] == 'Q' && rs->buf[1] == 'C')
    {
      char *obuf;
      ptid_t res;

      res = read_ptid (&rs->buf[2], &obuf);
      if (*obuf != '\0' && remote_debug)
        {
           fprintf_unfiltered (gdb_stdlog,
                               "warning: garbage after thread id "
                                "in qC reply\n")
        }
      return res;
    }
  else
    return oldpid;
}

> 
>>> This (consultation of the thread list) is what is done when
>>> inferior_ptid is null_ptid:
>>>
>>>       if (ptid_equal (inferior_ptid, null_ptid))
>>> 	{
>>
>> Would you mind adding a remote_debug log here?
> 
> As noted at the outset, I've updated my description.  I haven't
> changed this comment in the actual code.  Hopefully, that's what
> you want.
> 

Oh, I just meant adding something like:

if (remote_debug)
  fprintf_unfiltered (gdb_stdlog,
                      "couldn't determine remote current thread "
                      "picking first in list.");

here.

> Here's my updated change:

Looks good to me.  Thanks!

-- 
Pedro Alves


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