public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, RFC] Changes to sim_store_register API
@ 2010-11-08  8:12 Andrew Burgess
  2010-11-17  8:29 ` Andrew Burgess
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2010-11-08  8:12 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

The current API to sim_store_register returns the length of the register that was updated. However if the length returned is <= 0 then this is acceptable. Some simulators return 0 or -1 even on a successful register write.

I would like to propose the following changes,

(1) As the length of the register to be written is already passed into sim_store_register all simulators should return that length if they successfully update the register.
(2) If a length of 0 is returned this indicates that the simulator understood the request but couldn't update the register, this might mean that the register is read only, or just that updating of this register has not been implemented yet; in this case gdb will give a warning that the register has not been updated and continue.
(3) If a length of -1 is returned this indicates that the simulator didn't understand the request or some other non-recoverable error has occurred; in this case gdb will quit with an error.

The attached patch implements this change and updates the existing simulators to either return the length in the case of success or to return 0 for errors. 

I would welcome your feedback and suggestions.

I would be happy to update the fetch register case in a similar fashion but thought I'd start small to begin with.

Thanks,
Andrew


[-- Attachment #2: sim-store-register.patch --]
[-- Type: application/octet-stream, Size: 4381 bytes --]

diff -pru clean/gdb-7.2.50.20101027/gdb/remote-sim.c working/gdb-7.2.50.20101027/gdb/remote-sim.c
--- clean/gdb-7.2.50.20101027/gdb/remote-sim.c	2010-08-10 05:39:26.000000000 +0100
+++ working/gdb-7.2.50.20101027/gdb/remote-sim.c	2010-11-07 16:47:01.998498944 +0000
@@ -527,9 +527,13 @@ gdbsim_store_register (struct target_ops
       if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
 	internal_error (__FILE__, __LINE__,
 			_("Register size different to expected"));
-      /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
-	 indicating that GDB and the SIM have different ideas about
-	 which registers are fetchable.  */
+      if (nr_bytes < 0)
+        internal_error (__FILE__, __LINE__,
+			_("Register %d not updated"), regno);
+      if (nr_bytes == 0)
+        warning (_("Register not updated"),
+                 gdbarch_register_name (gdbarch, regno));
+      
       if (remote_debug)
 	{
 	  printf_filtered ("gdbsim_store_register: %d", regno);
Only in working/gdb-7.2.50.20101027/gdb: remote-sim.c~
diff -pru clean/gdb-7.2.50.20101027/sim/erc32/interf.c working/gdb-7.2.50.20101027/sim/erc32/interf.c
--- clean/gdb-7.2.50.20101027/sim/erc32/interf.c	2010-05-11 15:18:20.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/erc32/interf.c	2010-10-27 16:56:12.607262027 +0100
@@ -330,7 +330,7 @@ sim_store_register(sd, regno, value, len
 	regval = (value[3] << 24) | (value[2] << 16)
 		 | (value[1] << 8) | value[0];
     set_regi(&sregs, regno, regval);
-    return -1;
+    return length;
 }
 
 
diff -pru clean/gdb-7.2.50.20101027/sim/h8300/compile.c working/gdb-7.2.50.20101027/sim/h8300/compile.c
--- clean/gdb-7.2.50.20101027/sim/h8300/compile.c	2010-04-14 08:38:04.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/h8300/compile.c	2010-10-27 16:56:28.193119915 +0100
@@ -4715,7 +4715,7 @@ sim_store_register (SIM_DESC sd, int rn,
       h8_set_ticks (sd, longval);
       break;
     }
-  return -1;
+  return length;
 }
 
 int
diff -pru clean/gdb-7.2.50.20101027/sim/m32c/gdb-if.c working/gdb-7.2.50.20101027/sim/m32c/gdb-if.c
--- clean/gdb-7.2.50.20101027/sim/m32c/gdb-if.c	2010-04-14 08:38:04.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/m32c/gdb-if.c	2010-10-27 16:57:29.622058082 +0100
@@ -502,7 +502,7 @@ sim_store_register (SIM_DESC sd, int reg
 	default:
 	  fprintf (stderr, "m32c minisim: unrecognized register number: %d\n",
 		   regno);
-	  return -1;
+	  return 0;
 	}
     }
 
diff -pru clean/gdb-7.2.50.20101027/sim/mn10300/interp.c working/gdb-7.2.50.20101027/sim/mn10300/interp.c
--- clean/gdb-7.2.50.20101027/sim/mn10300/interp.c	2004-06-26 23:18:18.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/mn10300/interp.c	2010-10-27 16:59:00.810068620 +0100
@@ -410,7 +410,7 @@ sim_store_register (SIM_DESC sd,
 		    int length)
 {
   State.regs[rn] = get_word (memory);
-  return -1;
+  return length;
 }
 
 
diff -pru clean/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c working/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c
--- clean/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c	2010-01-01 10:03:33.000000000 +0000
+++ working/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c	2010-10-27 17:00:16.559040694 +0100
@@ -1289,7 +1289,7 @@ sim_store_register (SIM_DESC sd, int reg
   const char *regname = regnum2name (regno);
 
   if (simulator == NULL || regname == NULL)
-    return -1;
+    return 0;
 
   TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%lx)\n",
 		    regno, regname, (long)buf));
diff -pru clean/gdb-7.2.50.20101027/sim/rx/gdb-if.c working/gdb-7.2.50.20101027/sim/rx/gdb-if.c
--- clean/gdb-7.2.50.20101027/sim/rx/gdb-if.c	2010-09-24 00:05:28.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/rx/gdb-if.c	2010-10-27 16:59:37.090066882 +0100
@@ -630,7 +630,7 @@ sim_store_register (SIM_DESC sd, int reg
     default:
       fprintf (stderr, "rx minisim: unrecognized register number: %d\n",
 	       regno);
-      return -1;
+      return 0;
     }
 
   return size;
diff -pru clean/gdb-7.2.50.20101027/sim/v850/interp.c working/gdb-7.2.50.20101027/sim/v850/interp.c
--- clean/gdb-7.2.50.20101027/sim/v850/interp.c	2010-03-31 00:43:03.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/v850/interp.c	2010-10-27 17:00:02.016083444 +0100
@@ -327,7 +327,7 @@ sim_store_register (sd, rn, memory, leng
      int length;
 {
   State.regs[rn] = T2H_4 (*(unsigned32*)memory);
-  return -1;
+  return length;
 }
 
 void

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

end of thread, other threads:[~2011-01-11 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-08  8:12 [PATCH, RFC] Changes to sim_store_register API Andrew Burgess
2010-11-17  8:29 ` Andrew Burgess
2010-12-14  6:49   ` Joel Brobecker
2010-12-14  9:14     ` Andrew Burgess
2010-12-28  6:40       ` Joel Brobecker
2011-01-04  9:34         ` Andrew Burgess
2011-01-11 14:21         ` [PATCH, RFC] [commit] " Andrew Burgess

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