Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Cleanup mi_cmd_data_write_register_values
@ 2007-01-01  1:45 Mark Kettenis
  2007-01-01  3:07 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2007-01-01  1:45 UTC (permalink / raw)
  To: gdb-patches

The next victim in my vendetta agains deprecated_xxx.  Looks like this
function pretty was pretty much rolling its own
regcache_cooked_write_signed(), so why not use that?

ok?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* mi/mi-main.c (mi_cmd_data_write_register_values): Use
	regcache_cooked_write_signed instead of
	deprecated_write_register_bytes.

Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.86
diff -u -p -r1.86 mi-main.c
--- mi/mi-main.c 17 Nov 2006 19:30:41 -0000 1.86
+++ mi/mi-main.c 1 Jan 2007 01:42:23 -0000
@@ -545,10 +545,7 @@ get_register (int regnum, int format)
 enum mi_cmd_result
 mi_cmd_data_write_register_values (char *command, char **argv, int argc)
 {
-  int regnum;
-  int i;
-  int numregs;
-  LONGEST value;
+  int numregs, i;
   char format;
 
   /* Note that the test for a valid register must include checking the
@@ -587,26 +584,18 @@ mi_cmd_data_write_register_values (char 
 
   for (i = 1; i < argc; i = i + 2)
     {
-      regnum = atoi (argv[i]);
+      int regnum = atoi (argv[i]);
 
-      if (regnum >= 0
-	  && regnum < numregs
-	  && REGISTER_NAME (regnum) != NULL
-	  && *REGISTER_NAME (regnum) != '\000')
+      if (regnum >= 0 && regnum < numregs
+	  && REGISTER_NAME (regnum)  && *REGISTER_NAME (regnum))
 	{
-	  void *buffer;
-	  struct cleanup *old_chain;
+	  LONGEST value;
 
-	  /* Get the value as a number */
+	  /* Get the value as a number.  */
 	  value = parse_and_eval_address (argv[i + 1]);
-	  /* Get the value into an array */
-	  buffer = xmalloc (DEPRECATED_REGISTER_SIZE);
-	  old_chain = make_cleanup (xfree, buffer);
-	  store_signed_integer (buffer, DEPRECATED_REGISTER_SIZE, value);
+
 	  /* Write it down */
-	  deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (regnum), buffer, register_size (current_gdbarch, regnum));
-	  /* Free the buffer.  */
-	  do_cleanups (old_chain);
+	  regcache_cooked_write_signed (current_regcache, regnum, value);
 	}
       else
 	{


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

* Re: [RFA] Cleanup mi_cmd_data_write_register_values
  2007-01-01  1:45 [RFA] Cleanup mi_cmd_data_write_register_values Mark Kettenis
@ 2007-01-01  3:07 ` Daniel Jacobowitz
  2007-01-01 23:33   ` Nick Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2007-01-01  3:07 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Mon, Jan 01, 2007 at 02:45:08AM +0100, Mark Kettenis wrote:
> The next victim in my vendetta agains deprecated_xxx.

Thankyou thankyou!  This is a great thing to do.  I've been meaning to
do it myself, but I decided that my background cleanup project for now
would be testsuite results.

> Index: ChangeLog
> from  Mark Kettenis  <kettenis@gnu.org>
> 
> 	* mi/mi-main.c (mi_cmd_data_write_register_values): Use
> 	regcache_cooked_write_signed instead of
> 	deprecated_write_register_bytes.

Patch looks OK.  I'm almost glad this command is undocumented; this is
really all wrong as can be, since registers might not fit in the
LONGEST, and especially floating point registers have no business being
set from integer bit patterns.  And it encourages sloppy frontends to
hard code register numbers.  Yuck.

> +      if (regnum >= 0 && regnum < numregs
> +	  && REGISTER_NAME (regnum)  && *REGISTER_NAME (regnum))

Extra space in the middle there.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFA] Cleanup mi_cmd_data_write_register_values
  2007-01-01  3:07 ` Daniel Jacobowitz
@ 2007-01-01 23:33   ` Nick Roberts
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Roberts @ 2007-01-01 23:33 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Mark Kettenis, gdb-patches

 > > Index: ChangeLog
 > > from  Mark Kettenis  <kettenis@gnu.org>
 > > 
 > > 	* mi/mi-main.c (mi_cmd_data_write_register_values): Use
 > > 	regcache_cooked_write_signed instead of
 > > 	deprecated_write_register_bytes.
 > 
 > Patch looks OK.  I'm almost glad this command is undocumented; this is
 > really all wrong as can be, since registers might not fit in the
 > LONGEST, and especially floating point registers have no business being
 > set from integer bit patterns.  And it encourages sloppy frontends to
 > hard code register numbers.  Yuck.

Yes, previously it didn't work for me.  Perhaps, however, we can get rid of
this command if Vladimir commits his changes for "-var-list --registers".

-- 
Nick                                           http://www.inet.net.nz/~nickrob


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

end of thread, other threads:[~2007-01-01 23:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-01  1:45 [RFA] Cleanup mi_cmd_data_write_register_values Mark Kettenis
2007-01-01  3:07 ` Daniel Jacobowitz
2007-01-01 23:33   ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox