Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Alan Hayward <Alan.Hayward@arm.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>,
	 nd <nd@arm.com>
Subject: Re: [PATCH] Replace regbuf with regcache in record-full.c
Date: Thu, 22 Jun 2017 08:44:00 -0000	[thread overview]
Message-ID: <86fuesjtss.fsf@gmail.com> (raw)
In-Reply-To: <ACA547E7-2928-4ACC-9AA9-011883854B78@arm.com> (Alan Hayward's	message of "Wed, 14 Jun 2017 14:02:04 +0000")

Alan Hayward <Alan.Hayward@arm.com> writes:

> In record-full.c, instead of backing up all the registers into a large
> buffer, duplicate the regcache.
> This enables the removal of an instance of MAX_REGISTER_SIZE.
>
> Note that regcache_dup() create a read-only copy of a register cache,
> which ensures the new regcache cannot write back to the target.
>
> Once created, we need to be able to copy registers between the two caches,
> which we want to do without creating a temporary buffer.
>
> I've added regcache::raw_copy() to allow the copying of raw registers
> between two regcaches - either of which might be set as read-only.

Can we name this method raw_supply?

>
> Alternatively, I could make the new regcache as writable (by enabling a
> regcache copy constructor). But, I think this would be dangerous as it
> it then has the potential to write back to the target if the wrong function
> is called.

regcache only interacts with target through ::raw_update and
::raw_write.  Can we have a regcache class without raw_update and
raw_write?  regcache has two set of methods, {raw,cooked}_{read,write}
and raw_{collect,supply}XXX.  The former interacts with target, but the
latter doesn't.  We can create a new class regcache_collect_supply which
has methods raw_{collect,supply}XXXX, regcache extends it.  Then, add a
method "void raw_supply (int regnum, const regcache_collect_supply &src)"
and change record_full_core_regbuf to a regcache_collect_supply.  The
interface looks like this, (regcache_collect_supply is regcache_1 in the
doxygen doc, because I didn't figure out a reasonable name yesterday),

http://people.linaro.org/~yao.qi/gdb/doxy/regcache-split/gdb-xref/classregcache.html

Do you like this design?  One more thing is that the new class
regcache_collect_supply can be used in target_ops hooks
to_fetch_registers, to_store_registers, to_prepare_to_store,

    void (*to_fetch_registers) (struct target_ops *, regcache_collect_supply *, int)
      TARGET_DEFAULT_IGNORE ();
    void (*to_store_registers) (struct target_ops *, regcache_collect_supply *, int)
      TARGET_DEFAULT_NORETURN (noprocess ());
    void (*to_prepare_to_store) (struct target_ops *, regcache_collect_supply *)
      TARGET_DEFAULT_NORETURN (noprocess ());

so that all the implementations of these methods above can only access
raw_{collect,supply}XX methods, and they can't access
{raw,cooked}_{read,write}XXX methods, which in turn may call target_ops
to_fetch_registers and to_store_registers again.

-- 
Yao (齐尧)


  reply	other threads:[~2017-06-22  8:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 14:02 Alan Hayward
2017-06-22  8:44 ` Yao Qi [this message]
2017-06-22 16:02   ` Alan Hayward
2017-06-23  7:39     ` Yao Qi
2017-08-10  9:25       ` Alan Hayward

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=86fuesjtss.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=Alan.Hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.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