]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/record: add support for vpxor instruction
authorGuinevere Larsen <guinevere@redhat.com>
Fri, 1 Nov 2024 16:30:49 +0000 (13:30 -0300)
committerGuinevere Larsen <guinevere@redhat.com>
Fri, 22 Nov 2024 20:40:25 +0000 (17:40 -0300)
This commit adds support for recording the instruction vpxor,
introduced in the AVX extension, and extended in AVX2 to use 256 bit
registers. The test gdb.reverse/i386-avx-reverse.exp has been extended
to test this instruction as well.

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 6a919bf6473a7ae8df11f42e13a0e100351c2d22..38b1e7a1f02b196038637e9e8dd5f0d2be961a36 100644 (file)
@@ -4981,6 +4981,15 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
        break;
       }
 
+    case 0xef:
+      {
+       i386_record_modrm (ir);
+       int reg_offset = ir->reg + vex_r * 8;
+       record_full_arch_list_add_reg (ir->regcache,
+                                      tdep->ymm0_regnum + reg_offset);
+       break;
+      }
+
     default:
       gdb_printf (gdb_stderr,
                  _("Process record does not support VEX instruction 0x%02x "
index edd931b9f8c86a638c4657c6ee5e3411b7f51fc8..9bdc365ed86df71379c719bd14e2d0f295a9ca7a 100644 (file)
@@ -210,6 +210,25 @@ vzeroupper_test ()
   return 0; /* end vzeroupper_test  */
 }
 
+int
+vpxor_test ()
+{
+  /* start vpxor_test.  */
+  /* Using GDB, load this value onto the register, for ease of testing.
+     ymm0.v2_int128  = {0x0, 0x12345}
+     ymm1.v2_int128  = {0x1f1e1d1c1b1a1918, 0x0}
+     ymm2.v2_int128  = {0x0, 0xbeef}
+     ymm15.v2_int128 = {0x0, 0xcafeface}
+     this way it's easy to confirm we're undoing things correctly.  */
+
+  asm volatile ("vpxor %ymm0, %ymm0, %ymm0");
+  asm volatile ("vpxor %xmm0, %xmm1, %xmm0");
+  asm volatile ("vpxor %ymm2, %ymm15, %ymm1");
+  asm volatile ("vpxor %xmm2, %xmm15, %xmm2");
+  asm volatile ("vpxor %ymm2, %ymm1, %ymm15");
+  return 0; /* end vpxor_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.  */
@@ -235,5 +254,6 @@ main ()
   vpunpck_test ();
   vpbroadcast_test ();
   vzeroupper_test ();
+  vpxor_test ();
   return 0;    /* end of main */
 }
index 7ed12937391814b3c6fc4bc73a095973484cd4db..c4a54211592d5da2add0c679f9f5fa306ebef797 100644 (file)
@@ -327,9 +327,34 @@ if {[record_full_function "vzeroupper"] == true} {
            "Register ymm15h changed: 3405707982" \
            "Register rip changed: \[^\r\n\]+" ] \
        "verify vzeroupper recording"
+
+    gdb_test "record stop" "Process record is stopped.*" \
+       "delete history for vzeroupper_test"
 } else {
     untested "couldn't run vzeroupper tests"
 }
 
 gdb_test "finish" "Run till exit from.*vzeroupper_test.*" \
     "leaving vzeroupper"
+
+# Preparation and testing vpxor instructions.
+gdb_test_no_output "set \$ymm0.v2_int128 = {0x0, 0x12345}" "set ymm0 for vpxor"
+gdb_test_no_output "set \$ymm1.v2_int128 = {0x1f1e1d1c1b1a1918, 0x0}" \
+    "set ymm1 for vpxor"
+gdb_test_no_output "set \$ymm2.v2_int128 = {0x0, 0xbeef}" "set ymm2 for vpxor"
+gdb_test_no_output "set \$ymm15.v2_int128 = {0x0, 0xcafeface}" "set ymm15 for vpxor"
+
+if {[record_full_function "vpxor"] == true} {
+    test_one_register "vpxor" "ymm15" "0x0, 0xcafeface"
+    test_one_register "vpxor" "ymm2" "0x0, 0xbeef"
+    test_one_register "vpxor" "ymm1" "0x1f1e1d1c1b1a1918, 0x0"
+    test_one_register "vpxor" "ymm0" "0x0, 0x0" "first"
+    test_one_register "vpxor" "ymm0" "0x0, 0x12345" "second"
+
+    gdb_test "record stop" "Process record is stopped.*" \
+       "delete history for vpxor_test"
+} else {
+    untested "couldn't run vpxor tests"
+}
+gdb_test "finish" "Run till exit from.*vpxor_test.*" \
+    "leaving vpxor"