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 0/7] Pass ptid to target_ops register methods


On 17-03-08 06:31 PM, Pedro Alves wrote:
> A question that I think needs answering is:
> 
> A regcache stores the ptid it is connected to as a field.
> We rely on it for get_thread_regcache for example.
> 
> So, couldn't we instead just use that ptid?
> 
> Thanks,
> Pedro Alves

Huh, good point.  At first I wasn't sure I liked it, because I thought
the method interfaces would clearer with the ptid as its own parameter.
However, it would probably be more error-prone, because it would make it
possible to call to_fetch/store_register with a regcache that doesn't
match the provided ptid.  Actually, in the current state, I guess it's
also possible to call to_fetch/store_register with a regcache that
doesn't match inferior_ptid.  In that regard, using the ptid from the
regcache is probably the safest thing to do.  I'll try that.

Looking at the comments in regcache:

  /* Is this a read-only cache?  A read-only cache is used for saving
     the target's register state (e.g, across an inferior function
     call or just before forcing a function return).  A read-only
     cache can only be updated via the methods regcache_dup() and
     regcache_cpy().  The actual contents are determined by the
     reggroup_save and reggroup_restore methods.  */
  int readonly_p;
  /* If this is a read-write cache, which thread's registers is
     it connected to?  */
  ptid_t ptid;

I understand that in some situations, a regcache can have a minus_one ptid.
However, it looks like a regcache with an invalid ptid is never used to
directly fetch and store registers.  Instead, it is used as a "backup", the
content being copied from and to a regcache connected to a thread.  Does
that sound right?


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