Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/8] Remove regcache_descr::nr_raw_registers
Date: Fri, 27 Oct 2017 09:31:00 -0000	[thread overview]
Message-ID: <1509096702-12202-5-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1509096702-12202-1-git-send-email-yao.qi@linaro.org>

struct regcache_descr has fields nr_raw_registers and gdbarch, and
nr_raw_registers can be got via gdbarch_num_regs (gdbarch), so it looks
nr_raw_registers is redundant.  This patch removes it.

gdb:

2017-10-19  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (struct regcache_descr) <nr_raw_registers>: Remove.
	(init_regcache_descr): Use gdbarch_num_regs.
	(regcache::regcache): Likewise.
	(regcache::get_register_status): Likewise.
	(regcache::assert_raw_regnum): Likewise.
	(regcache::cooked_read): Likewise.
	(regcache::cooked_read_value): Likewise.
	(regcache::cooked_write): Likewise.
	(regcache::dump): Likewise.
---
 gdb/regcache.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 0aee934..fa1ed48 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -51,7 +51,6 @@ struct regcache_descr
      redundant information - if the PC is constructed from two
      registers then those registers and not the PC lives in the raw
      cache.  */
-  int nr_raw_registers;
   long sizeof_raw_registers;
 
   /* The cooked register space.  Each cooked register in the range
@@ -100,7 +99,6 @@ init_regcache_descr (struct gdbarch *gdbarch)
 
   /* Construct a strictly RAW register cache.  Don't allow pseudo's
      into the register cache.  */
-  descr->nr_raw_registers = gdbarch_num_regs (gdbarch);
 
   /* Lay out the register cache.
 
@@ -116,7 +114,7 @@ init_regcache_descr (struct gdbarch *gdbarch)
       = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
     descr->register_offset
       = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
-    for (i = 0; i < descr->nr_raw_registers; i++)
+    for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
       {
 	descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
 	descr->register_offset[i] = offset;
@@ -199,8 +197,7 @@ regcache::regcache (gdbarch *gdbarch, address_space *aspace_,
   else
     {
       m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_raw_registers);
-      m_register_status = XCNEWVEC (signed char,
-				    m_descr->nr_raw_registers);
+      m_register_status = XCNEWVEC (signed char, gdbarch_num_regs (gdbarch));
     }
   m_ptid = minus_one_ptid;
 }
@@ -378,7 +375,7 @@ regcache::get_register_status (int regnum) const
   if (m_readonly_p)
     gdb_assert (regnum < m_descr->nr_cooked_registers);
   else
-    gdb_assert (regnum < m_descr->nr_raw_registers);
+    gdb_assert (regnum < gdbarch_num_regs (arch ()));
 
   return (enum register_status) m_register_status[regnum];
 }
@@ -401,7 +398,7 @@ regcache::invalidate (int regnum)
 void
 regcache::assert_regnum (int regnum) const
 {
-  gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+  gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (arch ()));
 }
 
 /* Global structure containing the current regcache.  */
@@ -677,7 +674,7 @@ regcache::cooked_read (int regnum, gdb_byte *buf)
 {
   gdb_assert (regnum >= 0);
   gdb_assert (regnum < m_descr->nr_cooked_registers);
-  if (regnum < m_descr->nr_raw_registers)
+  if (regnum < gdbarch_num_regs (arch ()))
     return raw_read (regnum, buf);
   else if (m_readonly_p
 	   && m_register_status[regnum] != REG_UNKNOWN)
@@ -731,7 +728,7 @@ regcache::cooked_read_value (int regnum)
   gdb_assert (regnum >= 0);
   gdb_assert (regnum < m_descr->nr_cooked_registers);
 
-  if (regnum < m_descr->nr_raw_registers
+  if (regnum < gdbarch_num_regs (arch ())
       || (m_readonly_p && m_register_status[regnum] != REG_UNKNOWN)
       || !gdbarch_pseudo_register_read_value_p (m_descr->gdbarch))
     {
@@ -890,7 +887,7 @@ regcache::cooked_write (int regnum, const gdb_byte *buf)
 {
   gdb_assert (regnum >= 0);
   gdb_assert (regnum < m_descr->nr_cooked_registers);
-  if (regnum < m_descr->nr_raw_registers)
+  if (regnum < gdbarch_num_regs (arch ()))
     raw_write (regnum, buf);
   else
     gdbarch_pseudo_register_write (m_descr->gdbarch, this,
@@ -1435,7 +1432,7 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
 	{
 	  if (regnum < 0)
 	    fprintf_unfiltered (file, "Raw value");
-	  else if (regnum >= m_descr->nr_raw_registers)
+	  else if (regnum >= gdbarch_num_regs (arch ()))
 	    fprintf_unfiltered (file, "<cooked>");
 	  else if (get_register_status (regnum) == REG_UNKNOWN)
 	    fprintf_unfiltered (file, "<invalid>");
@@ -1461,7 +1458,7 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
 	      enum register_status status;
 	      struct value *value = NULL;
 
-	      if (regnum < m_descr->nr_raw_registers)
+	      if (regnum < gdbarch_num_regs (arch ()))
 		{
 		  raw_update (regnum);
 		  status = get_register_status (regnum);
@@ -1529,7 +1526,7 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
 	    {
 	      fprintf_unfiltered (file, "Rmt Nr  g/G Offset");
 	    }
-	  else if (regnum < m_descr->nr_raw_registers)
+	  else if (regnum < gdbarch_num_regs (arch ()))
 	    {
 	      int pnum, poffset;
 
-- 
1.9.1


  parent reply	other threads:[~2017-10-27  9:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27  9:31 [PATCH 0/8] regcache misc cleanup and refactor Yao Qi
2017-10-27  9:31 ` [PATCH 3/8] New method regcache::assert_regnum Yao Qi
2017-10-27  9:31 ` [PATCH 1/8] Remove regcache_descr fields sizeof_raw_register_status and sizeof_cooked_register_status Yao Qi
2017-10-27  9:31 ` Yao Qi [this message]
2017-10-31 14:27   ` [PATCH 4/8] Remove regcache_descr::nr_raw_registers Simon Marchi
2017-11-02 15:20     ` Yao Qi
2017-10-27  9:32 ` [PATCH 8/8] Construct readonly regcache without address space Yao Qi
2017-10-31 14:35   ` Simon Marchi
     [not found]     ` <CAH=s-PMFXtwS-3J9et_onyEOCUL9P-AgO9V=pBt60neQn67g9g@mail.gmail.com>
2017-10-31 18:04       ` Simon Marchi
2017-10-27  9:32 ` [PATCH 6/8] const-fy regcache::m_aspace Yao Qi
2017-10-31 14:19   ` Simon Marchi
2017-11-01  9:43     ` Yao Qi
2017-11-01 14:00       ` Simon Marchi
2017-11-01 14:35         ` Yao Qi
2017-10-27  9:32 ` [PATCH 7/8] const-fy regcache::m_readonly_p Yao Qi
2017-10-27  9:32 ` [PATCH 5/8] s/get_regcache_aspace (regcache)/regcache->aspace ()/g Yao Qi
2017-10-27  9:32 ` [PATCH 2/8] Remove code wrapped by "#if 0" 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=1509096702-12202-5-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