[RFC,05/23] X86: Replace regset_alloc() invocations by static regset structures.

Message ID 8761ls1phk.fsf@br87z6lw.de.ibm.com
State Committed
Headers

Commit Message

Andreas Arnez April 29, 2014, 8:58 a.m. UTC
  On Mon, Apr 28 2014, Mark Kettenis wrote:

>> From: Andreas Arnez <arnez@linux.vnet.ibm.com>
>> Date: Mon, 28 Apr 2014 11:47:03 +0200
>> 
>> diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c
>> index c5ed731..e7041c9 100644
>> --- a/gdb/amd64obsd-tdep.c
>> +++ b/gdb/amd64obsd-tdep.c
>> @@ -49,11 +49,17 @@ amd64obsd_supply_regset (const struct regset *regset,
>>  
>>    gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE);
>>  
>> -  i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
>> +  i386_gregset.supply_regset (regset, regcache, regnum, regs,
>> +			      tdep->sizeof_gregset);
>
> I'm not too happy with the additional level of indirection you're
> introducing here.  Don't particularly see the need to do this...

Sure, I can keep i386_supply_gregset as a global function, if you
prefer.  I'll adjust [RFC 05/23] by the patch below.  OK?

--
  

Patch

diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c
index e7041c9..3a46956 100644
--- a/gdb/amd64obsd-tdep.c
+++ b/gdb/amd64obsd-tdep.c
@@ -49,8 +49,7 @@  amd64obsd_supply_regset (const struct regset *regset,
 
   gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE);
 
-  i386_gregset.supply_regset (regset, regcache, regnum, regs,
-			      tdep->sizeof_gregset);
+  i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
   amd64_supply_fxsave (regcache, regnum,
 		       ((const gdb_byte *)regs) + tdep->sizeof_gregset);
 }
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index bee27f8..293e87a 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3720,7 +3720,7 @@  i386_value_to_register (struct frame_info *frame, int regnum,
    in the general-purpose register set REGSET to register cache
    REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
 
-static void
+void
 i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
 		     int regnum, const void *gregs, size_t len)
 {
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index fd601f2..e0950a3 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -377,6 +377,13 @@  extern int i386_sigtramp_p (struct frame_info *this_frame);
 extern int i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 				     struct reggroup *group);
 
+/* Supply register REGNUM from the general-purpose register set REGSET
+   to register cache REGCACHE.  If REGNUM is -1, do this for all
+   registers in REGSET.  */
+extern void i386_supply_gregset (const struct regset *regset,
+				 struct regcache *regcache, int regnum,
+				 const void *gregs, size_t len);
+
 /* General-purpose register set. */
 extern const struct regset i386_gregset;
 
diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c
index 46b4719..70dd0eb 100644
--- a/gdb/i386obsd-tdep.c
+++ b/gdb/i386obsd-tdep.c
@@ -147,8 +147,7 @@  i386obsd_aout_supply_regset (const struct regset *regset,
 
   gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE);
 
-  i386_gregset.supply_regset (regset, regcache, regnum, regs,
-			      tdep->sizeof_gregset);
+  i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
   i387_supply_fsave (regcache, regnum, gregs + tdep->sizeof_gregset);
 }