From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: simon.marchi@ericsson.com (Simon Marchi)
Cc: palves@redhat.com (Pedro Alves), gdb-patches@sourceware.org
Subject: Re: [PATCH 0/7] Pass ptid to target_ops register methods
Date: Fri, 10 Mar 2017 17:12:00 -0000 [thread overview]
Message-ID: <20170310171230.A9A22D806B1@oc3748833570.ibm.com> (raw)
In-Reply-To: <402e87d0-f05a-07dc-fb3f-0c0bbc5eef28@ericsson.com> from "Simon Marchi" at Mar 10, 2017 11:06:06 AM
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
next prev parent reply other threads:[~2017-03-10 17:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 16:42 Simon Marchi
2017-03-08 16:42 ` [PATCH 7/7] Pass ptid to to_prepare_to_store Simon Marchi
2017-03-08 16:42 ` [PATCH 5/7] Pass ptid to target_fetch_registers Simon Marchi
2017-03-08 21:08 ` Simon Marchi
2017-03-08 16:42 ` [PATCH 2/7] Add overload of s390_inferior_tid with a parameter Simon Marchi
2017-03-08 16:42 ` [PATCH 1/7] windows: Don't use current_thread for register fetch/store Simon Marchi
2017-03-08 16:42 ` [PATCH 6/7] Pass ptid to target_store_registers Simon Marchi
2017-03-08 16:42 ` [PATCH 4/7] Pass down ptid in bsd_uthread_ops layer Simon Marchi
2017-03-08 16:42 ` [PATCH 3/7] Define and use typedefs for bsd_uthread_ops fields Simon Marchi
2017-03-08 17:03 ` [PATCH 0/7] Pass ptid to target_ops register methods Simon Marchi
2017-03-08 23:31 ` Pedro Alves
2017-03-10 16:06 ` Simon Marchi
2017-03-10 17:12 ` Ulrich Weigand [this message]
2017-03-10 17:51 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170310171230.A9A22D806B1@oc3748833570.ibm.com \
--to=uweigand@de.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox