[v2,5/6] btrace: Add support for IRET events.

Message ID 20240913125722.2145486-6-felix.willgerodt@intel.com
State New
Headers
Series btrace: Intel PT event tracing support |

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-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Felix Willgerodt Sept. 13, 2024, 12:57 p.m. UTC
  This is similar to the previous events that we added.
---
 gdb/btrace.c                                   | 14 ++++++++++++++
 gdb/testsuite/gdb.btrace/event-tracing-gap.exp |  4 ++++
 gdb/testsuite/gdb.btrace/event-tracing.exp     |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/btrace.c b/gdb/btrace.c
index 1ba0d6f2bef..05159b06a18 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1421,6 +1421,20 @@  handle_pt_insn_events (struct btrace_thread_info *btinfo,
 	    handle_pt_aux_insn (btinfo, aux_string, pc);
 	    break;
 	  }
+
+	case ptev_iret:
+	  {
+	    std::string aux_string = std::string (_("iret"));
+
+	    if (event.ip_suppressed == 0)
+	      {
+		pc = event.variant.iret.ip;
+		aux_string += std::string (": ip = ") + hex_string (pc);
+	      }
+
+	    handle_pt_aux_insn (btinfo, aux_string, pc);
+	    break;
+	  }
 #endif /* defined (LIBIPT_VERSION >= 0x201) */
 	}
     }
diff --git a/gdb/testsuite/gdb.btrace/event-tracing-gap.exp b/gdb/testsuite/gdb.btrace/event-tracing-gap.exp
index ee0f4a5b26b..038b2b08da7 100644
--- a/gdb/testsuite/gdb.btrace/event-tracing-gap.exp
+++ b/gdb/testsuite/gdb.btrace/event-tracing-gap.exp
@@ -61,13 +61,17 @@  gdb_continue_to_breakpoint "break at bp_2" ".*$srcfile:$bp_2.*"
 # gdb_test_sequence and check only for events that we can control.
 gdb_test_sequence "record function-call-history" "function-call-history" {
     "\[0-9\]+\tmain"
+    "\\\[iret(: ip = $hex)?\\\]"
     "\\\[interrupt: vector = 0x1 \\\(#db\\\)(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
+    "\\\[iret(: ip = $hex)?\\\]"
     "\[0-9\]+\t\\\[non-contiguous\\\]"
     "\[0-9\]+\tsquare"
     "\\\[interrupt: vector = 0x3 \\\(#bp\\\)(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
+    "\\\[iret(: ip = $hex)?\\\]"
     "\[0-9\]+\t\\\[non-contiguous\\\]"
     "\[0-9\]+\tmain"
     "\[0-9\]+\tsquare"
     "\\\[interrupt: vector = 0x3 \\\(#bp\\\)(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
+    "\\\[iret(: ip = $hex)?\\\]"
     "\[0-9\]+\tmain"
 }
diff --git a/gdb/testsuite/gdb.btrace/event-tracing.exp b/gdb/testsuite/gdb.btrace/event-tracing.exp
index 362e715490c..6cad758ae20 100644
--- a/gdb/testsuite/gdb.btrace/event-tracing.exp
+++ b/gdb/testsuite/gdb.btrace/event-tracing.exp
@@ -34,10 +34,11 @@  gdb_test_no_output "record btrace pt"
 
 gdb_test "continue" "Program received signal SIGSEGV, Segmentation fault.*"
 
-# Test printing of at least one INTERRUPT event.
+# Test printing of at least one INTERRUPT and one IRET event.
 # This uses test_sequence to avoid random events failing the tests.
 gdb_test_sequence "record function-call-history" "function-call-history" {
     "\[0-9\]+\tmain"
+    "\t  \\\[iret(: ip = $hex)?\\\]"
     "\[0-9\]+\tcall1"
     "\[0-9\]+\tmain"
     "\t  \\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = 0x\[0-9a-fA-F\]+)?\\\]"