[4/4] gdb.trace: Fix off-by-one in tfile_fetch_registers.

Message ID 1454773157-31569-5-git-send-email-koriakin@0x04.net
State New, archived
Headers

Commit Message

Marcin Kościelnicki Feb. 6, 2016, 3:39 p.m. UTC
  This resulted in the last register being considered unavailable.
On plain x86_64 (without AVX), this happened to be orig_rax.

gdb/ChangeLog:

	* tracefile-tfile.c (tfile_fetch_registers): Fix off-by-one in bounds
	check.
---
 gdb/ChangeLog         | 5 +++++
 gdb/tracefile-tfile.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
  

Comments

Pedro Alves Feb. 10, 2016, 1:21 p.m. UTC | #1
On 02/06/2016 03:39 PM, Marcin Kościelnicki wrote:
> This resulted in the last register being considered unavailable.
> On plain x86_64 (without AVX), this happened to be orig_rax.
> 
> gdb/ChangeLog:
> 
> 	* tracefile-tfile.c (tfile_fetch_registers): Fix off-by-one in bounds
> 	check.

OK.

Thanks,
Pedro Alves
  
Marcin Kościelnicki Feb. 10, 2016, 1:52 p.m. UTC | #2
On 10/02/16 14:21, Pedro Alves wrote:
> On 02/06/2016 03:39 PM, Marcin Kościelnicki wrote:
>> This resulted in the last register being considered unavailable.
>> On plain x86_64 (without AVX), this happened to be orig_rax.
>>
>> gdb/ChangeLog:
>>
>> 	* tracefile-tfile.c (tfile_fetch_registers): Fix off-by-one in bounds
>> 	check.
>
> OK.
>
> Thanks,
> Pedro Alves
>

Thanks, pushed.
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5afdb60..339f2d0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@ 
 2016-02-06  Marcin Kościelnicki  <koriakin@0x04.net>
 
+	* tracefile-tfile.c (tfile_fetch_registers): Fix off-by-one in bounds
+	check.
+
+2016-02-06  Marcin Kościelnicki  <koriakin@0x04.net>
+
 	* tracefile-tfile.c (tfile_fetch_registers): Use g packet order
 	instead of gdb order.
 
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 23d78c3..a6c3c9c 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -879,7 +879,7 @@  tfile_fetch_registers (struct target_ops *ops,
 
 	  regsize = register_size (gdbarch, regn);
 	  /* Make sure we stay within block bounds.  */
-	  if (offset + regsize >= trace_regblock_size)
+	  if (offset + regsize > trace_regblock_size)
 	    break;
 	  if (regcache_register_status (regcache, regn) == REG_UNKNOWN)
 	    {