]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/record: add support for comis instructions
authorGuinevere Larsen <guinevere@redhat.com>
Fri, 13 Jun 2025 13:09:19 +0000 (10:09 -0300)
committerGuinevere Larsen <guinevere@redhat.com>
Fri, 11 Jul 2025 14:55:34 +0000 (11:55 -0300)
This commit adds support for the following instructions:
* VCOMIS[S|D]
* VUCOMIS[S|D]

And associanted tests.

gdb/i386-tdep.c
gdb/testsuite/gdb.reverse/i386-avx-reverse.c
gdb/testsuite/gdb.reverse/i386-avx-reverse.exp

index 863872dcb9f7b3940434178451de08113b6b6b02..ecac5cd8aa34a5a6c34620078c1f87b10fb6909a 100644 (file)
@@ -5164,6 +5164,17 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
       }
       break;
 
+    case 0x2e: /* VUCOMIS[S|D].  */
+    case 0x2f: /* VCOMIS[S|D].  */
+      {
+       /* Despite what the manual implies, saying that the first register
+          will be written to, actual testing shows that the only register
+          changed is EFLAGS.  */
+       record_full_arch_list_add_reg (ir->regcache,
+                                      ir->regmap[X86_RECORD_EFLAGS_REGNUM]);
+       break;
+      }
+
     case 0x77:/* VZEROUPPER  */
       {
        int num_regs = tdep->num_ymm_regs;
index c4148033f59feab8f27e81f928e11eaaeb27fd78..863f5b6a10295289e9ff1bbb712937406e76bc06 100644 (file)
@@ -654,6 +654,28 @@ blend_test ()
   return 0; /* end blend_test  */
 }
 
+int
+compare_test ()
+{
+  /* start compare_test.  */
+  /* Using GDB, load these values onto registers for testing.
+     xmm0.v4_float = {0, 1.5, 2, 0}
+     xmm1.v4_float = {0, 1, 2.5, -1}
+     xmm15.v4_float = {-1, -2, 10, 100}
+     eflags = 2
+     eflags can't be set to some values, if we set it to 0, it'll
+     be reset to 2, so set it to that directly to make results less
+     confusing.
+     this way it's easy to confirm we're undoing things correctly.  */
+
+  asm volatile ("vcomisd %xmm0, %xmm1");
+  asm volatile ("vcomiss %xmm15, %xmm1");
+  asm volatile ("vucomiss %xmm1, %xmm15");
+  asm volatile ("vucomisd %xmm15, %xmm0");
+
+  return 0; /* end compare_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.  */
@@ -691,5 +713,6 @@ main ()
   permute_test ();
   extract_insert_test ();
   blend_test ();
+  compare_test ();
   return 0;    /* end of main */
 }
index 7307f88fe079d7abb31297666029bef383d411e6..f401aef34ab79e3424cdd2ba0009d6c40f6ed052 100644 (file)
@@ -1054,3 +1054,26 @@ if {[record_full_function "blend"] == true} {
 }
 gdb_test "finish" "Run till exit from.*blend_test.*" \
     "leaving blend"
+
+# Preparation and testing compare instructions.
+gdb_test_no_output \
+    "set \$xmm0.v4_float = {0, 1.5, 2, 0}" "set ymm0 for compare"
+gdb_test_no_output \
+    "set \$xmm1.v4_float = {0, 1, 2.5, -1}" "set ymm1 for compare"
+gdb_test_no_output \
+    "set \$xmm15.v4_float = {-1, -2, 10, 100}" "set ymm15 for compare"
+gdb_test_no_output "set \$eflags = 2"
+
+if {[record_full_function "compare"] == true} {
+    test_one_general_register "vucomisd" "eflags" "0x203"
+    test_one_general_register "vucomiss" "eflags" "0x202"
+    test_one_general_register "vcomiss" "eflags" "0x203"
+    test_one_general_register "vcomisd" "eflags" "0x202"
+
+    gdb_test "record stop" "Process record is stopped.*" \
+       "delete history for compare_test"
+} else {
+    untested "couldn't run compare tests"
+}
+gdb_test "finish" "Run till exit from.*compare_test.*" \
+    "leaving compare"