[binutils-gdb] gdb/record: add support for comis instructions

Guinevere Larsen guinevere@sourceware.org
Fri Jul 11 15:07:02 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7f774c3914d0b43ca26c17790461f0b06c1c227e

commit 7f774c3914d0b43ca26c17790461f0b06c1c227e
Author: Guinevere Larsen <guinevere@redhat.com>
Date:   Fri Jun 13 10:09:19 2025 -0300

    gdb/record: add support for comis instructions
    
    This commit adds support for the following instructions:
    * VCOMIS[S|D]
    * VUCOMIS[S|D]
    
    And associanted tests.

Diff:
---
 gdb/i386-tdep.c                                | 11 +++++++++++
 gdb/testsuite/gdb.reverse/i386-avx-reverse.c   | 23 +++++++++++++++++++++++
 gdb/testsuite/gdb.reverse/i386-avx-reverse.exp | 23 +++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 863872dcb9f..ecac5cd8aa3 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -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;
diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c
index c4148033f59..863f5b6a102 100644
--- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c
+++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c
@@ -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 */
 }
diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
index 7307f88fe07..f401aef34ab 100644
--- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
@@ -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"


More information about the Gdb-cvs mailing list