record: Fix the error message for (E)VEX encoded instructions.

Message ID 1557843768-32341-1-git-send-email-arash.bakhtiari@intel.com
State New, archived
Headers

Commit Message

Arash Bakhtiari May 14, 2019, 2:22 p.m. UTC
  From: "Bakhtiari, Arash" <arash.bakhtiari@intel.com>

The procedure to indentify the instructions in
GDB "record full" misidentifies the VEX and EVEX
encoded instructions with BOUND, LDS and LES
instructions.

Excerpts from gdb.log of "gdb.reverse/*.exp" tests.
before:
    Process record does not support instruction 0x62 at address 0x7ffff7ded757.
    Process record: failed to record execution log.

after:
    Process record does not support EVEX encoded instructions.
    Process record does not support instruction 0x62 at address 0x7ffff7ded757.
    Process record: failed to record execution log.

gdb/ChangeLog:

2018-04-03 Arash Bakhtiari  <arash.bakhtiari@intel.com>

	* i386-tdep.c (i386_process_record): Fix the error message for {E}VEX
	encoded instructions in GDB record full.


---
 gdb/i386-tdep.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 54d9dd873b8..67f23f365c1 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -5013,6 +5013,7 @@  i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   uint8_t rex_w = -1;
   uint8_t rex_r = 0;
+  const bool is_64bit = gdbarch_addr_bit (gdbarch) == 64;
 
   memset (&ir, 0, sizeof (struct i386_record_s));
   ir.regcache = regcache;
@@ -5894,8 +5895,20 @@  Do you want to stop the program?"),
 
     case 0xc4:    /* les Gv */
     case 0xc5:    /* lds Gv */
+      {
+	gdb_byte next_byte;
+	record_read_memory (gdbarch, ir.addr, &next_byte, 1);
+	/* Check if it's a VEX encoded instruction in 32/64-bit mode.  */
+	if (is_64bit || (next_byte & 0xc0) == 0xc0)
+	  {
+	    printf_unfiltered (_("Process record does not support "
+				 "VEX encoded instructions.\n"));
+	    ir.addr -= 1;
+	    goto no_support;
+	  }
+      }
       if (ir.regmap[X86_RECORD_R8_REGNUM])
-        {
+	{
 	  ir.addr -= 1;
 	  goto no_support;
 	}
@@ -6841,8 +6854,17 @@  Do you want to stop the program?"),
       break;
 
     case 0x62:    /* bound */
-      printf_unfiltered (_("Process record does not support "
-			   "instruction bound.\n"));
+      {
+	gdb_byte next_byte;
+	record_read_memory (gdbarch, ir.addr, &next_byte, 1);
+	/* Check if it's a EVEX encoded instruction in 32/64-bit mode.  */
+	if (is_64bit || (next_byte & 0xc0) == 0xc0)
+	  printf_unfiltered (_("Process record does not support "
+			       "EVEX encoded instructions.\n"));
+	else
+	  printf_unfiltered (_("Process record does not support "
+			       "instruction bound.\n"));
+      }
       ir.addr -= 1;
       goto no_support;
       break;