This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Linux/gdbserver: Clean up fetch_register and store_register


Hi,

 More changes to fetch_register and store_register -- the two functions 
complement each other but their code looks as if they were written 
independently and then at one point included here together.

 This is an overall cleanup, although by no means exhaustive -- there are 
still some minor issues I did not want to address lest I got buried into 
this cleanup forever.  Apart from obvious formatting fixes there are two 
minor functional changes -- the result of .cannot_store_register is now 
checked for a non-zero rather than explicit one.  This change makes the 
API of this backend consistent with that of .cannot_fetch_register.  The 
other change moves the retrieval of the PID used by ptrace in 
fetch_register to immediately precede the loop it is used in, just like in 
store_register.

 No regressions on i686-linux-gnu or mips-linux-gnu (like with the 
previous change I had to force srv_linux_regsets to "no" and deal with 
some bitrot of that configuration to get indicative results).  OK to 
apply?

2011-11-22  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/gdbserver/
	* linux-low.c (fetch_register, store_register): Make code
	consistent, fix formatting.

  Maciej

gdb-gdbserver-linux-fetch-store-format.diff
Index: gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/gdbserver/linux-low.c	2011-11-18 17:21:54.425560931 +0000
+++ gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c	2011-11-18 17:21:54.445622134 +0000
@@ -3745,10 +3745,11 @@ fetch_register (struct regcache *regcach
   if (regaddr == -1)
     return;
 
-  pid = lwpid_of (get_thread_lwp (current_inferior));
   size = ((register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
-	  & - sizeof (PTRACE_XFER_TYPE));
+	  & -sizeof (PTRACE_XFER_TYPE));
   buf = alloca (size);
+
+  pid = lwpid_of (get_thread_lwp (current_inferior));
   for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
     {
       errno = 0;
@@ -3779,16 +3780,15 @@ store_register (struct regcache *regcach
 
   if (regno >= the_low_target.num_regs)
     return;
-
-  if ((*the_low_target.cannot_store_register) (regno) == 1)
+  if ((*the_low_target.cannot_store_register) (regno))
     return;
 
   regaddr = register_addr (regno);
   if (regaddr == -1)
     return;
-  errno = 0;
-  size = (register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
-	 & - sizeof (PTRACE_XFER_TYPE);
+
+  size = ((register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
+	  & -sizeof (PTRACE_XFER_TYPE));
   buf = alloca (size);
   memset (buf, 0, size);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]