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


Simon Marchi wrote:

> 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.

It is possible, but that would be a bug :-)  All callers currently do

      struct cleanup *old_chain = save_inferior_ptid ();

      inferior_ptid = regcache->ptid;
      target_fetch_registers (regcache, regnum);

or the equivalent.

> In that regard, using the ptid from the
> regcache is probably the safest thing to do.  I'll try that.

Basically, we should move the above from the call site into all
implementations of the routine, and then push it down as far as
possible until it hopefully disappears in most cases.

> 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?

Yes, the target routines must only be called on a regcache that is
associated with a ptid.

You'll probably need to add a get_regcache_ptid() routine or so;
that routine should assert that the regcache has a ptid.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


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