[PATCH v3 5/7] gdb/record: Add recording support to vpbroadcast instructions
Guinevere Larsen
blarsen@redhat.com
Mon Jul 29 19:08:51 GMT 2024
This commit adds recording support to all AVX and AVX2 instructions of
the form vpbroadcast. GDB is not yet concerned about AVX512 in recording
mode, so for now we only support the AVX2 registers and instructions.
This commit also updates the gdb.reverse/i386-avx-reverse.exp to test
broadcast instructions.
---
gdb/i386-tdep.c | 13 +++++++++
gdb/testsuite/gdb.reverse/i386-avx-reverse.c | 29 +++++++++++++++++++
.../gdb.reverse/i386-avx-reverse.exp | 29 +++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 5189949532b..04892a2ae20 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -5088,6 +5088,19 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
}
break;
+ case 0x78: /* VPBROADCASTB */
+ case 0x79: /* VPBROADCASTW */
+ case 0x58: /* VPBROADCASTD */
+ case 0x59: /* VPBROADCASTQ */
+ {
+ i386_record_modrm (ir);
+ int reg_offset = ir->reg + vex_r * 8;
+ gdb_assert (tdep->num_ymm_regs > reg_offset);
+ 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 "
diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c
index c897436995e..16303a42248 100644
--- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c
+++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c
@@ -130,6 +130,34 @@ vpunpck_test ()
return 0; /* end vpunpck_test */
}
+/* Test if we can record vpbroadcast instructions. */
+int
+vpbroadcast_test ()
+{
+ /* Using GDB, load this value onto the register, for ease of testing.
+ xmm0.uint128 = 0x0
+ xmm1.uint128 = 0x1f1e1d1c1b1a19181716151413121110
+ xmm15.uint128 = 0x0
+ this way it's easy to confirm we're undoing things correctly. */
+ /* start vpbroadcast_test. */
+
+ asm volatile ("vpbroadcastb %xmm1, %xmm0");
+ asm volatile ("vpbroadcastb %xmm1, %xmm15");
+
+ asm volatile ("vpbroadcastw %xmm1, %ymm0");
+ asm volatile ("vpbroadcastw %xmm1, %ymm15");
+
+ asm volatile ("vpbroadcastd %xmm1, %xmm0");
+ asm volatile ("vpbroadcastd %xmm1, %xmm15");
+
+ asm volatile ("vpbroadcastq %xmm1, %ymm0");
+ asm volatile ("vpbroadcastq %xmm1, %ymm15");
+
+ /* We have a return statement to deal with
+ epilogue in different compilers. */
+ return 0; /* end vpbroadcast_test */
+}
+
int
main ()
{
@@ -148,5 +176,6 @@ main ()
vmov_test ();
vpunpck_test ();
+ vpbroadcast_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 718dca3429a..75c313c2225 100644
--- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
@@ -237,3 +237,32 @@ if {[record_full_function "vpunpck"] == true} {
gdb_test "record stop" "Process record is stopped.*" \
"delete history for vpunpck_test"
gdb_test "finish" "Run till exit from.*vpunpck_test.*" "leaving vpunpck_test"
+
+# Start vpbroadcast tests
+gdb_test_no_output "set \$ymm0.v2_int128 = {0x0, 0x0}" "set xmm0 for vpbroadcast"
+gdb_test_no_output "set \$xmm1.v2_int64 = {0x1716151413121110, 0x1f1e1d1c1b1a1918}" \
+ "set xmm1 for vpbroadcast"
+gdb_test_no_output "set \$ymm15.v2_int128 = {0x0, 0x0}" "set xmm15 for vpbroadcast"
+if {[record_full_function "vpbroadcast"] == true} {
+ test_one_register "vpbroadcastq" "ymm15" "0x13121110131211101312111013121110, 0x0"
+ test_one_register "vpbroadcastq" "ymm0" "0x13121110131211101312111013121110, 0x0"
+
+ test_one_register "vpbroadcastd" "ymm15" \
+ "0x11101110111011101110111011101110, 0x11101110111011101110111011101110"
+ test_one_register "vpbroadcastd" "ymm0" \
+ "0x11101110111011101110111011101110, 0x11101110111011101110111011101110"
+
+ test_one_register "vpbroadcastw" "ymm15" "0x10101010101010101010101010101010, 0x0"
+ test_one_register "vpbroadcastw" "ymm0" "0x10101010101010101010101010101010, 0x0"
+
+ test_one_register "vpbroadcastb" "ymm15" "0x0, 0x0"
+ test_one_register "vpbroadcastb" "ymm0" "0x0, 0x0"
+
+ gdb_test "record stop" "Process record is stopped.*" \
+ "delete history for vpbroadcast_test"
+} else {
+ untested "couldn't run vpbroadcast tests"
+}
+
+gdb_test "finish" "Run till exit from.*vpbroadcast_test.*" \
+ "leaving vpbroadcast"
--
2.45.2
More information about the Gdb-patches
mailing list