]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/record: Add support for recording vpmovmskb
authorGuinevere Larsen <guinevere@redhat.com>
Tue, 12 Nov 2024 20:45:05 +0000 (17:45 -0300)
committerGuinevere Larsen <guinevere@redhat.com>
Fri, 22 Nov 2024 20:40:25 +0000 (17:40 -0300)
This commit adds support for recording the AVX instruction vpmovmskb,
and tests to the relevant file. The test didn't really support checking
general purpose registers, so this commit also adds a proc to
gdb.reverse/i386-avx-reverse.exp, which can be used to test them

Approved-By: Tom Tromey <tom@tromey.com>
gdb/i386-tdep.c
gdb/testsuite/gdb.reverse/i386-avx-reverse.c
gdb/testsuite/gdb.reverse/i386-avx-reverse.exp

index 2a076700a672a3623b11a5afedb018d797b8d3bc..0f366daa29f5dd9eb59adc3c97a9da916079ad3b 100644 (file)
@@ -4992,6 +4992,15 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
        break;
       }
 
+    case 0xd7: /* VPMOVMSKB  */
+      {
+       i386_record_modrm (ir);
+       record_full_arch_list_add_reg (ir->regcache,
+                                      ir->regmap[X86_RECORD_REAX_REGNUM
+                                                 + ir->reg + 8 * vex_r]);
+      }
+      break;
+
     case 0xef:
       {
        i386_record_modrm (ir);
index 57b53d1390c9239626432e1dd818dfffb436a8d2..02fd3da3fc04c97be49732f2fb769a8af80c22dd 100644 (file)
@@ -260,6 +260,23 @@ vpcmpeq_test ()
   return 0; /* end vpcmpeq_test  */
 }
 
+int
+vpmovmskb_test ()
+{
+  /* start vpmovmskb_test.  */
+  /* Using GDB, load these values onto registers for testing.
+     rbx = 2
+     r8  = 3
+     r9  = 4
+     this way it's easy to confirm we're undoing things correctly.  */
+  asm volatile ("vpmovmskb %ymm0, %eax");
+  asm volatile ("vpmovmskb %ymm0, %ebx");
+
+  asm volatile ("vpmovmskb %ymm0, %r8");
+  asm volatile ("vpmovmskb %ymm0, %r9");
+  return 0; /* end vpmovmskb_test  */
+}
+
 /* This include is used to allocate the dynamic buffer and have
    the pointers aligned to a 32-bit boundary, so we can test instructions
    that require aligned memory.  */
@@ -287,5 +304,6 @@ main ()
   vzeroupper_test ();
   vpxor_test ();
   vpcmpeq_test ();
+  vpmovmskb_test ();
   return 0;    /* end of main */
 }
index b4f0e3b38b52a3242c11917234409040715dfc6f..198025ed885b0031ff579d808a6233329f8f2e5c 100644 (file)
@@ -63,6 +63,19 @@ proc test_one_register {insn register value {prefix ""}} {
        "${prefix}verify $register before $insn"
 }
 
+# Shorthand to test reversing through one instruction and
+# testing if a general purpose register has the expected value.
+# Prefix, if included, should end with a colon and space.
+
+proc test_one_general_register {insn register value {prefix ""}} {
+    gdb_test "reverse-step" "$insn.*" \
+       "${prefix}reverse-step from $insn to test register $register"
+
+    gdb_test "info register $register" \
+       "$register\\s+$value.*" \
+       "${prefix}verify $register before $insn"
+}
+
 # Shorthand to test reversing through one instruction and
 # testing if a variable has the expected value.
 # Prefix, if used, should end with a colon and space.
@@ -403,3 +416,24 @@ if {[record_full_function "vpcmpeq"] == true} {
 }
 gdb_test "finish" "Run till exit from.*vpcmpeq_test.*" \
     "leaving vpcmpeq"
+
+# Preparation and testing vpcmpeq instructions.
+gdb_test_no_output "set \$rbx = 2" "set rbx for vpmovmskb"
+gdb_test_no_output "set \$r8 = 3" "set r8 for vpmovmskb"
+gdb_test_no_output "set \$r9 = 4" "set ymm15 for vpmovmskb"
+
+if {[record_full_function "vpmovmskb"] == true} {
+    test_one_general_register "vpmovmskb" "r9" "0x4"
+    test_one_general_register "vpmovmskb" "r8" "0x3"
+    test_one_general_register "vpmovmskb" "rbx" "0x2"
+    # Because of the infrastructure of the test, we can't set rax.
+    # However, it seems to always be set to 0, so this should be fine.
+    test_one_general_register "vpmovmskb" "rax" "0x0"
+
+    gdb_test "record stop" "Process record is stopped.*" \
+       "delete history for vpmovmskb_test"
+} else {
+    untested "couldn't run vpmovmskb tests"
+}
+gdb_test "finish" "Run till exit from.*vpmovmskb_test.*" \
+    "leaving vpmovmskb"