From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [RFC 00/15] Remove regcache::m_readonly_p
Date: Fri, 01 Dec 2017 10:48:00 -0000 [thread overview]
Message-ID: <1512125286-29788-1-git-send-email-yao.qi@linaro.org> (raw)
regcache is used in many places in gdb in different ways, so regcache
becomes a flat and fat object. That exposes some unnecessary APIs to
different part, and some APIs are misused or abused:
1) gdbarch methods pseudo_register_read and pseudo_register_read_value
have a parameter 'regcache *', but these two gdbarch methods only need
raw_read* and cooked_read* methods. So it is better to pass a class
which only has raw_read* and cooked_read* methods, and other regcache
methods are invisible to each gdbarch implementation.
2) target_ops methods to_fetch_registers and to_store_registers have a
parameter 'regcache *', but these two target_ops methods only need
raw_supply and raw_collect methods, because raw registers are from target
layer, pseudo registers are "composed" or "created" by gdbarch.
3) jit.c uses regcache in an odd way, and record-full.c should use
a simple version regcache instead of an array (see patch 11)
Beside these api issues, one issue in regcache is that there is no
type or class for readonly regcache. We use a flag field m_readonly_p
to indicate the regcache is readonly or not, so some regcache apis have
assert that this regcache is or is not readonly. The better way to do
this is to create a new class for readonly regcache which doesn't have
write methods at all.
This patch series fixes all of the problems above except 2) (I had a
patch to fix 2 in my tree, but still need more time to polish it.) by
designing a class hierarchy about regcache, like this,
reg_buffer
^
|
------+-----
^
|
regcache_read
^
|
------+------
^ ^
| |
reg_buffer_rw regcache_readonly
^
|
regcache
Class reg_buffer is a simple class, having register contents and status
(in patch 7). regcache_read is an abstract class only having raw_read*
and cooked_read* methods (in patch 8). reg_buffer_rw is a class which
has read and write methods, but it disconnects from target, IOW, the
write doesn't go through. Class regcache_readonly is the readonly
regcache, created from regcache::save method.
This patch series is tested on {x86_64, aarch64, ppc64}-linux. It is
an RFC, want to get comments. I write them in at least seven different
ways, and this one is satisfying. I don't push them in until 8.1 is
branched.
*** BLURB HERE ***
Yao Qi (15):
Call cooked_read in ppu2spu_prev_register
Don't call gdbarch_pseudo_register_read_value in jit.c
Remove mt port
Replace regcache_raw_read with regcache->raw_read
regcache_cooked_read -> regcache->cooked_read
regcache::cooked_write test
Class reg_buffer
class regcache_read and Pass regcache_read to gdbarch methods
Remove regcache_save and regcache_cpy
Class regcache_readonly
Class reg_buffer_rw
Replace regcache::dump with class register_dump
No longer create readonly regcache
Remove regcache::m_readonly_p
Move register_dump to regcache-dump.c
gdb/Makefile.in | 3 +-
gdb/aarch64-tdep.c | 12 +-
gdb/amd64-tdep.c | 11 +-
gdb/arm-tdep.c | 12 +-
gdb/avr-tdep.c | 4 +-
gdb/bfin-tdep.c | 4 +-
gdb/configure.tgt | 6 +-
gdb/dummy-frame.c | 6 +-
gdb/frame.c | 15 +-
gdb/frame.h | 3 +-
gdb/frv-tdep.c | 8 +-
gdb/gdbarch.c | 4 +-
gdb/gdbarch.h | 8 +-
gdb/gdbarch.sh | 4 +-
gdb/h8300-tdep.c | 8 +-
gdb/hppa-tdep.c | 4 +-
gdb/i386-tdep.c | 72 ++-
gdb/i386-tdep.h | 2 +-
gdb/ia64-tdep.c | 32 +-
gdb/infcmd.c | 6 +-
gdb/inferior.h | 2 +-
gdb/infrun.c | 8 +-
gdb/jit.c | 26 +-
gdb/linux-fork.c | 20 +-
gdb/m32c-tdep.c | 54 +--
gdb/m68hc11-tdep.c | 6 +-
gdb/mep-tdep.c | 12 +-
gdb/mi/mi-main.c | 12 +-
gdb/mips-tdep.c | 8 +-
gdb/msp430-tdep.c | 4 +-
gdb/mt-tdep.c | 1218 -------------------------------------------------
gdb/nds32-tdep.c | 4 +-
gdb/ppc-linux-tdep.c | 15 +-
gdb/record-full.c | 21 +-
gdb/regcache-dump.c | 335 ++++++++++++++
gdb/regcache.c | 586 ++++++++++--------------
gdb/regcache.h | 242 ++++++----
gdb/rl78-tdep.c | 29 +-
gdb/rs6000-tdep.c | 88 ++--
gdb/s390-linux-tdep.c | 17 +-
gdb/sh-tdep.c | 8 +-
gdb/sh64-tdep.c | 12 +-
gdb/sparc-tdep.c | 6 +-
gdb/sparc64-tdep.c | 22 +-
gdb/spu-tdep.c | 16 +-
gdb/xtensa-tdep.c | 15 +-
46 files changed, 1024 insertions(+), 1986 deletions(-)
delete mode 100644 gdb/mt-tdep.c
create mode 100644 gdb/regcache-dump.c
--
1.9.1
next reply other threads:[~2017-12-01 10:48 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 10:48 Yao Qi [this message]
2017-12-01 10:48 ` [PATCH 09/15] Remove regcache_save and regcache_cpy Yao Qi
2017-12-01 10:48 ` [PATCH 01/15] Call cooked_read in ppu2spu_prev_register Yao Qi
2018-01-16 16:19 ` Yao Qi
2018-01-16 18:05 ` Ulrich Weigand
2018-01-18 12:22 ` Yao Qi
2017-12-01 10:48 ` [PATCH 04/15] Replace regcache_raw_read with regcache->raw_read Yao Qi
2017-12-01 10:48 ` [PATCH 15/15] Move register_dump to regcache-dump.c Yao Qi
2017-12-01 10:48 ` [PATCH 08/15] class regcache_read and Pass regcache_read to gdbarch methods Yao Qi
2018-01-23 21:51 ` Simon Marchi
2018-01-23 22:28 ` Yao Qi
2017-12-01 10:48 ` [PATCH 13/15] No longer create readonly regcache Yao Qi
2017-12-01 10:48 ` [PATCH 05/15] regcache_cooked_read -> regcache->cooked_read Yao Qi
2017-12-01 10:48 ` [PATCH 03/15] Remove mt port Yao Qi
2017-12-01 10:48 ` [PATCH 02/15] Don't call gdbarch_pseudo_register_read_value in jit.c Yao Qi
2017-12-01 10:48 ` [PATCH 06/15] regcache::cooked_write test Yao Qi
2018-01-18 16:13 ` Simon Marchi
2018-01-22 11:12 ` Yao Qi
2017-12-01 10:48 ` [PATCH 11/15] Class reg_buffer_rw Yao Qi
2017-12-01 10:48 ` [PATCH 14/15] Remove regcache::m_readonly_p Yao Qi
2017-12-01 10:48 ` [PATCH 10/15] Class regcache_readonly Yao Qi
2018-01-24 3:05 ` Simon Marchi
2018-01-24 9:43 ` Yao Qi
2018-01-24 16:57 ` Simon Marchi
2018-01-24 17:37 ` Yao Qi
2018-01-24 18:01 ` Simon Marchi
2018-01-24 21:01 ` Yao Qi
2017-12-01 10:48 ` [PATCH 07/15] Class reg_buffer Yao Qi
2017-12-01 10:48 ` [PATCH 12/15] Replace regcache::dump with class register_dump Yao Qi
2018-01-16 16:18 ` [RFC 00/15] Remove regcache::m_readonly_p Yao Qi
2018-01-18 16:56 ` Simon Marchi
2018-01-22 14:58 ` Yao Qi
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=1512125286-29788-1-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).