[v4,7/7] gdb/record: add support to vzeroupper instruction
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
This commit adds recording support for the AVX instruction vzeroupper,
which zeroes the high bits of ymm registers 0..15. In the programmer's
manual, it is explicitly states that ymm registers 16..31 won't be
affected if present, so we only need to record the first 16 registers.
We record ymm_h registers since only the higher bits are touched, and
that reduces the memory footprint of the instruction.
This instruction is tested differently as we want to confirm we're only
saving the relevant registers, and we want to ensure we're saving
all of them, so it makes use of "maint print record-instruction" to see
exactly what was recorded.
---
gdb/i386-tdep.c | 17 +++++++++
gdb/testsuite/gdb.reverse/i386-avx-reverse.c | 19 ++++++++++
.../gdb.reverse/i386-avx-reverse.exp | 37 +++++++++++++++++++
3 files changed, 73 insertions(+)
@@ -5149,6 +5149,23 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
}
break;
+ case 0x77:/* VZEROUPPER */
+ {
+ int num_regs = tdep->num_ymm_regs;
+ /* This instruction only works on ymm0..15, even if 16..31 are
+ available. */
+ if (num_regs > 16)
+ num_regs = 16;
+ for (int i = 0; i < num_regs; i++)
+ {
+ /* We only need to record ymm_h, because the low bits
+ are not touched. */
+ record_full_arch_list_add_reg (ir->regcache,
+ tdep->ymm0h_regnum + i);
+ }
+ break;
+ }
+
default:
gdb_printf (gdb_stderr,
_("Process record does not support VEX instruction 0x%02x "
@@ -192,6 +192,24 @@ vpbroadcast_test ()
return 0; /* end vpbroadcast_test */
}
+int
+vzeroupper_test ()
+{
+ /* start vzeroupper_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 ("vzeroupper");
+
+ /* We have a return statement to deal with
+ epilogue in different compilers. */
+ return 0; /* end vzeroupper_test */
+}
+
int
main ()
{
@@ -211,5 +229,6 @@ main ()
vmov_test ();
vpunpck_test ();
vpbroadcast_test ();
+ vzeroupper_test ();
return 0; /* end of main */
}
@@ -294,3 +294,40 @@ if {[record_full_function "vpbroadcast"] == true} {
gdb_test "finish" "Run till exit from.*vpbroadcast_test.*" \
"leaving vpbroadcast"
+
+# Preparation and testing of vzeroupper
+gdb_test_no_output "set \$ymm0.v2_int128 = {0x0, 0x12345}" "set ymm0 for vzeroupper"
+gdb_test_no_output "set \$ymm1.v2_int128 = {0x1f1e1d1c1b1a1918, 0x0}" \
+ "set ymm1 for vzeroupper"
+gdb_test_no_output "set \$ymm2.v2_int128 = {0x0, 0xbeef}" "set ymm2 for vzeroupper"
+gdb_test_no_output "set \$ymm15.v2_int128 = {0x0, 0xcafeface}" "set ymm15 for vpbroadcast"
+if {[record_full_function "vzeroupper"] == true} {
+ # Since vzeroupper needs to save 8 or 16 registers, let's check what was
+ # actually recorded, instead of just undoing an instruction. Only
+ # really check the values of egisters 0, 1, 2 and 15 because those are
+ # the only ones we're setting.
+ gdb_test "maint print record-instruction" \
+ [multi_line "Register ymm0h changed: 74565" \
+ "Register ymm1h changed: 0" \
+ "Register ymm2h changed: 48879" \
+ "Register ymm3h changed: ${decimal}" \
+ "Register ymm4h changed: ${decimal}" \
+ "Register ymm5h changed: ${decimal}" \
+ "Register ymm6h changed: ${decimal}" \
+ "Register ymm7h changed: ${decimal}" \
+ "Register ymm8h changed: ${decimal}" \
+ "Register ymm9h changed: ${decimal}" \
+ "Register ymm10h changed: ${decimal}" \
+ "Register ymm11h changed: ${decimal}" \
+ "Register ymm12h changed: ${decimal}" \
+ "Register ymm13h changed: ${decimal}" \
+ "Register ymm14h changed: ${decimal}" \
+ "Register ymm15h changed: 3405707982" \
+ "Register rip changed: \[^\r\n\]+" ] \
+ "verify vzeroupper recording"
+} else {
+ untested "couldn't run vzeroupper tests"
+}
+
+gdb_test "finish" "Run till exit from.*vzeroupper_test.*" \
+ "leaving vzeroupper"