This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 0/7] Pass ptid to target_ops register methods
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Pedro Alves <palves at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Fri, 10 Mar 2017 11:06:06 -0500
- Subject: Re: [PATCH 0/7] Pass ptid to target_ops register methods
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=ericsson.com;
- References: <20170308164140.7281-1-simon.marchi@ericsson.com> <706d8cd5-f3a2-c9dc-9d87-3cf171b3d012@redhat.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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?