Re: [PATCH 08/15] class regcache_read and Pass regcache_read to gdbarch methods

Simon Marchi
2018-01-23T21:51:40Z

Hi Yao,

On 2017-12-01 05:47 AM, Yao Qi wrote:
> pseudo registers are either from raw registers or memory, so
> gdbarch methods pseudo_register_read and pseudo_register_read_value
> should have regcache object which only have read methods. In other
> words, we should disallow writing to regcache in these two gdbarch
> methods. In order to apply this restriction, this patch adds a new
> class regcache_read, derived from reg_buffer, and it only has
> raw_read and cooked_read methods. regcache is derived from
> regcache_read. This patch also passes regcache_read instead of
> regcache to gdbarch methods pseudo_register_read and
> pseudo_register_read_value.

Did you consider changing other gdbarch methods that only need to read the
registers? read_pc comes to mind, but there are perhaps others.

> This patch moves raw_read* and cooked_read* methods to regcache_read,
> which is straightforward. One thing not straightforward is that I split
> regcache::xfer_part to regcache_read::read_part and regcache::write_part,
> because regcache_read can only have methods to read.

That is fine with me.

> regcache_read is an abstract base class, and it has a pure virtual
> function raw_update, because I don't want regcache_read know where these
> raw registers are from. They can be from either the target (readwrite
> regcache) or the regcache itself (readonly regcache).

About the naming, I think that readcache_read sounds like a function (it
sounds like an action). Instinctively, I would call it readable_regcache.

Simon