]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/record: Support for rdtscp in i386_process_record.
authorCupertino Miranda <cupertino.miranda@oracle.com>
Tue, 5 Dec 2023 23:09:57 +0000 (23:09 +0000)
committerCupertino Miranda <cupertino.miranda@oracle.com>
Thu, 7 Dec 2023 10:55:55 +0000 (10:55 +0000)
This patch adds support for process recording of the instruction rdtscp in
x86 architecture.
Debugging applications with "record full" fail to record with the error
message "Process record does not support instruction 0xf01f9".

Approved-by: Guinevere Larsen <blarsen@redhat.com>
gdb/i386-tdep.c
gdb/testsuite/gdb.reverse/insn-reverse-x86.c

index e00c3bd9d5685db81a8ea79fe0ba8ebafcf51f5b..e379c17988547d267a6ffd860b4b7ad09ebdbb4d 100644 (file)
@@ -7008,6 +7008,9 @@ Do you want to stop the program?"),
       goto no_support;
       break;
 
+    case 0x0f01f9:  /* rdtscp */
+      I386_RECORD_FULL_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGNUM);
+      [[fallthrough]];
     case 0x0f31:    /* rdtsc */
       I386_RECORD_FULL_ARCH_LIST_ADD_REG (X86_RECORD_REAX_REGNUM);
       I386_RECORD_FULL_ARCH_LIST_ADD_REG (X86_RECORD_REDX_REGNUM);
@@ -7117,6 +7120,11 @@ Do you want to stop the program?"),
     case 0x0f01:
       if (i386_record_modrm (&ir))
        return -1;
+      if (ir.modrm == 0xf9)
+       {
+         opcode = (opcode << 8) | 0xf9;
+         goto reswitch;
+       }
       switch (ir.reg)
        {
        case 0:  /* sgdt */
index 2b4fb4c10e01ad14efbbc92ae1520109c2ae8695..23888ba7350e079b8e3de7a3b7a3198482b2cfc3 100644 (file)
@@ -270,6 +270,16 @@ rdseed (void)
 #endif
 }
 
+/* Test rdtscp support.  */
+
+void
+rdtscp (void)
+{
+#ifdef __x86_64__
+  __asm__ volatile ("rdtscp");
+#endif
+}
+
 /* Initialize arch-specific bits.  */
 
 static void
@@ -283,5 +293,6 @@ initialize (void)
 static testcase_ftype testcases[] =
 {
   rdrand,
-  rdseed
+  rdseed,
+  rdtscp
 };