public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove MAX_REGISTER_SIZE from remote.c
@ 2017-02-24 10:06 Alan Hayward
  2017-02-24 16:14 ` Yao Qi
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Hayward @ 2017-02-24 10:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: nd

remote_prepare_to_store only needs to make sure the value is cache is valid.
Create a new function (split from regcache_raw_read) to do this.

Tested using make check with board files unix and native-gdbserver.

Ok to commit?

Alan.

2017-02-24  Alan Hayward  <alan.hayward@arm.com>

	* regcache.c (regcache_raw_update): New function.
	(regcache_raw_read): Move code to regcache_raw_update.
	* regcache.h (regcache_raw_update): New declaration.
	* remote.c (remote_prepare_to_store): Call regcache_raw_update.



diff --git a/gdb/regcache.h b/gdb/regcache.h
index e5a7cf553279b8cc0d546ec1b8274cbf97e246d5..e1495f61426f879386b905ab1e97421bdd061bf5 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -50,6 +50,10 @@ extern struct address_space *get_regcache_aspace (const struct regcache *);
 enum register_status regcache_register_status (const struct regcache *regcache,
 					       int regnum);

+/* Make certain that the register REGNUM in REGCACHE is up-to-date.  */
+
+void regcache_raw_update (struct regcache *regcache, int regnum);
+
 /* Transfer a raw register [0..NUM_REGS) between core-gdb and the
    regcache.  The read variants return the status of the register.  */

diff --git a/gdb/regcache.c b/gdb/regcache.c
index eed1bd84c8a9dd07ee77f0c3269e49e78081b127..f190eda0e47c5c03744fc26263505d1c30ea1ee8 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -642,15 +642,17 @@ registers_changed (void)
   alloca (0);
 }

-enum register_status
-regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
+void
+regcache_raw_update (struct regcache *regcache, int regnum)
 {
-  gdb_assert (regcache != NULL && buf != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
   /* Make certain that the register cache is up-to-date with respect
      to the current thread.  This switching shouldn't be necessary
      only there is still only one target side register cache.  Sigh!
      On the bright side, at least there is a regcache object.  */
+
+  gdb_assert (regcache != NULL);
+  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+
   if (!regcache->readonly_p
       && regcache_register_status (regcache, regnum) == REG_UNKNOWN)
     {
@@ -666,6 +668,13 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
       if (regcache->register_status[regnum] == REG_UNKNOWN)
 	regcache->register_status[regnum] = REG_UNAVAILABLE;
     }
+}
+
+enum register_status
+regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
+{
+  gdb_assert (buf != NULL);
+  regcache_raw_update (regcache, regnum);

   if (regcache->register_status[regnum] != REG_VALID)
     memset (buf, 0, regcache->descr->sizeof_register[regnum]);
diff --git a/gdb/remote.c b/gdb/remote.c
index 3befbd3d154ee4f0fbf65120d783b8af447b3fbe..87fb6e02ea3df3d8fecaf3fecc45790bdbfb6f6f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7759,7 +7759,6 @@ remote_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
   struct remote_arch_state *rsa = get_remote_arch_state ();
   int i;
-  gdb_byte buf[MAX_REGISTER_SIZE];

   /* Make sure the entire registers array is valid.  */
   switch (packet_support (PACKET_P))
@@ -7769,7 +7768,7 @@ remote_prepare_to_store (struct target_ops *self, struct regcache *regcache)
       /* Make sure all the necessary registers are cached.  */
       for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
 	if (rsa->regs[i].in_g_packet)
-	  regcache_raw_read (regcache, rsa->regs[i].regnum, buf);
+	  regcache_raw_update (regcache, rsa->regs[i].regnum);
       break;
     case PACKET_ENABLE:
       break;



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove MAX_REGISTER_SIZE from remote.c
  2017-02-24 10:06 [PATCH] Remove MAX_REGISTER_SIZE from remote.c Alan Hayward
@ 2017-02-24 16:14 ` Yao Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Yao Qi @ 2017-02-24 16:14 UTC (permalink / raw)
  To: Alan Hayward; +Cc: gdb-patches

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

> -enum register_status
> -regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
> +void
> +regcache_raw_update (struct regcache *regcache, int regnum)
>  {
> -  gdb_assert (regcache != NULL && buf != NULL);
> -  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
>    /* Make certain that the register cache is up-to-date with respect
>       to the current thread.  This switching shouldn't be necessary
>       only there is still only one target side register cache.  Sigh!
>       On the bright side, at least there is a regcache object.  */
> +
> +  gdb_assert (regcache != NULL);
> +  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);

Nit, any reason you move these asserts from one place to another?  It
causes one unnecessary change.  Could you change the assert in its
original place?

OK with this change.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-24 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24 10:06 [PATCH] Remove MAX_REGISTER_SIZE from remote.c Alan Hayward
2017-02-24 16:14 ` Yao Qi

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).