Home | History | Annotate | Line # | Download | only in gdb.btrace
      1 # This testcase is part of GDB, the GNU debugger.
      2 #
      3 # Copyright 2024 Free Software Foundation, Inc.
      4 #
      5 # This program is free software; you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation; either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 # Test basic Intel PT event tracing
     19 
     20 require allow_btrace_pt_event_trace_tests
     21 
     22 standard_testfile null-deref.c
     23 
     24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
     25     return -1
     26 }
     27 
     28 if {![runto_main]} {
     29     return -1
     30 }
     31 
     32 gdb_test_no_output "set record btrace pt event-tracing on"
     33 gdb_test_no_output "record btrace pt"
     34 
     35 gdb_test "continue" "Program received signal SIGSEGV, Segmentation fault.*"
     36 
     37 # Test printing of at least one INTERRUPT and one IRET event.
     38 # This uses test_sequence to avoid random events failing the tests.
     39 gdb_test_sequence "record function-call-history" "function-call-history" {
     40     "\[0-9\]+\tmain"
     41     "\t  \\\[iret(: ip = $hex)?\\\]"
     42     "\t  \\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
     43 }
     44 
     45 # Test the instruction-history.  Assembly can differ between compilers. To
     46 # avoid creating a .S file for this test we just check the event at the end.
     47 gdb_test "record instruction-history" \
     48   "$decimal\t     \\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = $hex)?\\\]"
     49 
     50 # Test reverse stepping and replay stepping
     51 gdb_test "reverse-stepi" "\\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = $hex)?\\\].*"
     52 gdb_test "stepi" "\\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = $hex)?\\\].*"
     53