From 99ebac02397f19bc16cad6a6fef7828fbc716803 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 13 Feb 2023 18:27:17 +0100 Subject: [PATCH] [gdb/testsuite] Add xfail in gdb.python/py-record-btrace.exp There's a HW bug affecting Processor Trace on some Intel processors (Ice Lake to Raptor Lake microarchitectures). The bug was exposed by linux kernel commit 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output mode"), added in version v5.5.0, and was worked around by commit ce0d998be927 ("perf/x86/intel/pt: Fix sampling using single range output") in version 6.1.0. The bug manifests (on a Performance-core of an i7-1250U, an Alder Lake cpu) in a single test-case: ... (gdb) python insn = r.instruction_history^M warning: Decode error (-20) at instruction 33 (offset = 0x3d6a, \ pc = 0x400501): compressed return without call.^M (gdb) FAIL: gdb.python/py-record-btrace.exp: prepare record: \ python insn = r.instruction_history ... Add a corresponding XFAIL. Note that the i7-1250U has both Performance-cores and Efficient-cores, and on an Efficient-Core the test-case runs without any problems, so if the testsuite run is not pinned to a specific cpu, the test may either PASS or XFAIL. Tested on x86_64-linux: - openSUSE Leap 15.4 with linux kernel version 5.14.21 - openSUSE Tumbleweed with linux kernel version 6.1.8 PR testsuite/30075 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30075 --- gdb/testsuite/gdb.python/py-record-btrace.exp | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp index 555b70ae336..7deb157b73c 100644 --- a/gdb/testsuite/gdb.python/py-record-btrace.exp +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp @@ -54,7 +54,49 @@ with_test_prefix "prepare record" { gdb_test "python print(r.method)" "btrace" gdb_test "python print(r.format)" "pt|bts" gdb_test "stepi 100" ".*" - gdb_test_no_output "python insn = r.instruction_history" + + # There's a HW bug affecting Processor Trace on some Intel processors. + # The bug was exposed by linux kernel commit 670638477aed + # ("perf/x86/intel/pt: Opportunistically use single range output mode"), + # added in version v5.5.0, and was worked around by commit ce0d998be927 + # ("perf/x86/intel/pt: Fix sampling using single range output") in version + # 6.1.0. Detect the kernel version range for which the problem may + # manifest. + set have_xfail 0 + set v [linux_kernel_version] + if { $v == {} } { + set have_xfail 0 + } else { + set have_xfail \ + [expr [version_compare [list 5 5 0] <= $v] \ + && [version_compare $v < [list 6 1 0]]] + } + set xfail_re \ + [join \ + [list \ + "warning: Decode error \\(.*\\) at instruction $decimal" \ + "\\(offset = $hex, pc = $hex\\):" \ + "compressed return without call\\."]] + + set got_xfail 0 + set cmd "python insn = r.instruction_history" + gdb_test_multiple $cmd "" { + -re "^[string_to_regexp $cmd]\r\n$::gdb_prompt $" { + pass $gdb_test_name + } + -re -wrap "$xfail_re" { + if { $have_xfail } { + xfail $gdb_test_name + set got_xfail 1 + } else { + fail $gdb_test_name + } + } + } + if { $got_xfail } { + return + } + gdb_test_no_output "python call = r.function_call_history" gdb_test_no_output "python i = insn\[0\]" gdb_test_no_output "python c = call\[0\]" base-commit: 37d75d4552d6b4d292ffb4dee92329a449288375 -- 2.35.3