gdb/testsuite: add simavr.exp board
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-record-btrace-threads.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2017-2020 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 # Skip this test if btrace is disabled.
19
20 if { [skip_btrace_tests] } {
21 untested "skipping btrace tests"
22 return -1
23 }
24
25 standard_testfile
26
27 if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug} ] != "" } {
28 untested "failed to prepare"
29 return -1
30 }
31 clean_restart $testfile
32
33 # Skip this test if python is disabled.
34
35 load_lib gdb-python.exp
36 if { [skip_python_tests] } {
37 untested "skipping python tests"
38 return -1
39 }
40
41 if { ![runto_main] } {
42 untested "failed to run to main"
43 return -1
44 }
45
46 # set up breakpoints
47 gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
48 gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
49
50 # record data
51 gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
52 gdb_test_no_output "record btrace"
53 gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
54
55 # acquire the record objects for thread 1 and thread 2
56 gdb_test "thread 1" ".*"
57 gdb_test "record function-call-history" ".*" "fch thread 1"
58 gdb_test_no_output "python rec1 = gdb.current_recording()"
59 gdb_test "thread 2" ".*"
60 gdb_test "record function-call-history" ".*" "fch thread 2"
61 gdb_test_no_output "python rec2 = gdb.current_recording()"
62
63 # Thread 1 is supposed to call func1 (), thread 2 is supposed to call func2 ().
64 # Check that the function call history for the current thread contains a call
65 # to the right function and does not contain a call to the wrong function.
66 proc check_insn_for_thread { self other } {
67 with_test_prefix "checking thread $self" {
68 gdb_test_no_output "python fch = rec$self.function_call_history"
69 gdb_test_no_output "python f1calls = \{x for x in fch if x.symbol and x.symbol.name == \"func1\"\}"
70 gdb_test_no_output "python f2calls = \{x for x in fch if x.symbol and x.symbol.name == \"func2\"\}"
71
72 gdb_test "python print(not f${self}calls)" "False"
73 gdb_test "python print(not f${other}calls)" "True"
74 }
75 }
76
77 foreach_with_prefix thread { 1 2 } {
78 gdb_test "thread $thread"
79 check_insn_for_thread 1 2
80 check_insn_for_thread 2 1
81 }
This page took 0.037586 seconds and 4 git commands to generate.