diff mbox

Remove MAX_REGISTER_SIZE from mi/mi-main.c

Message ID B92EB568-29C2-4CD8-B3BF-3F3F552366EE@arm.com
State New
Headers show

Commit Message

Alan Hayward June 8, 2017, 12:57 p.m. UTC
> On 8 Jun 2017, at 10:55, Pedro Alves <palves@redhat.com> wrote:
> 
> On 06/08/2017 10:42 AM, Alan Hayward wrote:
> 
>>   /* Get register contents and compare.  */
>> -  prev_status = regcache_cooked_read (prev_regs, regnum, prev_buffer);
>> -  this_status = regcache_cooked_read (this_regs, regnum, this_buffer);
>> -
>> -  if (this_status != prev_status)
>> -    return 1;
>> -  else if (this_status == REG_VALID)
>> -    return memcmp (prev_buffer, this_buffer,
>> -		   register_size (gdbarch, regnum)) != 0;
>> +  prev_value = prev_regs->cooked_read_value (regnum);
>> +  this_value = this_regs->cooked_read_value (regnum);
>> +  gdb_assert (prev_value != NULL);
>> +  gdb_assert (this_value != NULL);
>> +
>> +  if (value_optimized_out (prev_value) != value_optimized_out (this_value)
>> +      || value_entirely_available (prev_value)
>> +	 != value_entirely_available (this_value))
>> +    ret = 1;
>> +  if (value_optimized_out (prev_value)
>> +      || !value_entirely_available (prev_value))
>> +    ret = 0;
>>   else
>> -    return 0;
>> +    ret = memcmp (value_contents_all (prev_value),
>> +		  value_contents_all (this_value),
>> +		  register_size (gdbarch, regnum)) != 0;
>> +
>> +  release_value (prev_value);
>> +  release_value (this_value);
>> +  value_free (prev_value);
>> +  value_free (this_value);
>> +  return ret;
>> }
>> 
> 
> Use value_contents_eq?

That simplifies things!

Updated using value_contents_eq.

Tested on a --enable-targets=all build
No regressions in gdb.mi/*.exp
Also tested with board files unix and native-gdbserver.


Ok to commit?

Alan.


2017-06-08  Alan Hayward  <alan.hayward@arm.com>

	* mi/mi-main.c (register_changed_p): Use cooked_read_value

Comments

Pedro Alves June 8, 2017, 1 p.m. UTC | #1
On 06/08/2017 01:57 PM, Alan Hayward wrote:

> 
> Ok to commit?
> 

OK.

> Alan.
> 
> 
> 2017-06-08  Alan Hayward  <alan.hayward@arm.com>
> 
> 	* mi/mi-main.c (register_changed_p): Use cooked_read_value

(Missing period.)

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index bdc5dda30537c7e5797fb8c44b689a63c5c0f4b8..9cbd3a454d20b4429725a00328840e4b4cce47f9 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1111,10 +1111,8 @@  register_changed_p (int regnum, struct regcache *prev_regs,
 		    struct regcache *this_regs)
 {
   struct gdbarch *gdbarch = get_regcache_arch (this_regs);
-  gdb_byte prev_buffer[MAX_REGISTER_SIZE];
-  gdb_byte this_buffer[MAX_REGISTER_SIZE];
-  enum register_status prev_status;
-  enum register_status this_status;
+  struct value *prev_value, *this_value;
+  int ret;

   /* First time through or after gdbarch change consider all registers
      as changed.  */
@@ -1122,16 +1120,17 @@  register_changed_p (int regnum, struct regcache *prev_regs,
     return 1;

   /* Get register contents and compare.  */
-  prev_status = regcache_cooked_read (prev_regs, regnum, prev_buffer);
-  this_status = regcache_cooked_read (this_regs, regnum, this_buffer);
+  prev_value = prev_regs->cooked_read_value (regnum);
+  this_value = this_regs->cooked_read_value (regnum);

-  if (this_status != prev_status)
-    return 1;
-  else if (this_status == REG_VALID)
-    return memcmp (prev_buffer, this_buffer,
-		   register_size (gdbarch, regnum)) != 0;
-  else
-    return 0;
+  ret = value_contents_eq (prev_value, 0, this_value, 0,
+			   register_size (gdbarch, regnum)) == 0;
+
+  release_value (prev_value);
+  release_value (this_value);
+  value_free (prev_value);
+  value_free (this_value);
+  return ret;
 }

 /* Return a list of register number and value pairs.  The valid