]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.python/py-record-btrace-threads.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-record-btrace-threads.exp
CommitLineData
ae20e79a
TW
1# This testcase is part of GDB, the GNU debugger.
2#
3666a048 3# Copyright 2017-2021 Free Software Foundation, Inc.
ae20e79a
TW
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
20if { [skip_btrace_tests] } {
21 untested "skipping btrace tests"
22 return -1
23}
24
25standard_testfile
26
27if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug} ] != "" } {
28 untested "failed to prepare"
29 return -1
30}
31clean_restart $testfile
32
33# Skip this test if python is disabled.
34
35load_lib gdb-python.exp
36if { [skip_python_tests] } {
37 untested "skipping python tests"
38 return -1
39}
40
41if { ![runto_main] } {
42 untested "failed to run to main"
43 return -1
44}
45
46# set up breakpoints
47gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
48gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
49
50# record data
51gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
52gdb_test_no_output "record btrace"
53gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
54
55# acquire the record objects for thread 1 and thread 2
56gdb_test "thread 1" ".*"
57gdb_test "record function-call-history" ".*" "fch thread 1"
58gdb_test_no_output "python rec1 = gdb.current_recording()"
59gdb_test "thread 2" ".*"
60gdb_test "record function-call-history" ".*" "fch thread 2"
61gdb_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.
66proc 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
d512d31c
PA
72 gdb_test "python print(not f${self}calls)" "False"
73 gdb_test "python print(not f${other}calls)" "True"
ae20e79a
TW
74 }
75}
76
77foreach_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}