]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.python/py-record-btrace-threads.exp
Update copyright year range in header of all files managed by GDB
[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#
213516ef 3# Copyright 2017-2023 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] } {
ae20e79a
TW
42 return -1
43}
44
45# set up breakpoints
46gdb_breakpoint $srcfile:[gdb_get_line_number "bp1" $srcfile]
47gdb_breakpoint $srcfile:[gdb_get_line_number "bp2" $srcfile]
48
49# record data
50gdb_continue_to_breakpoint "cont to bp.1" ".*bp1.*"
51gdb_test_no_output "record btrace"
52gdb_continue_to_breakpoint "cont to bp.2" ".*bp2.*"
53
54# acquire the record objects for thread 1 and thread 2
55gdb_test "thread 1" ".*"
56gdb_test "record function-call-history" ".*" "fch thread 1"
57gdb_test_no_output "python rec1 = gdb.current_recording()"
58gdb_test "thread 2" ".*"
59gdb_test "record function-call-history" ".*" "fch thread 2"
60gdb_test_no_output "python rec2 = gdb.current_recording()"
61
62# Thread 1 is supposed to call func1 (), thread 2 is supposed to call func2 ().
63# Check that the function call history for the current thread contains a call
64# to the right function and does not contain a call to the wrong function.
65proc check_insn_for_thread { self other } {
66 with_test_prefix "checking thread $self" {
67 gdb_test_no_output "python fch = rec$self.function_call_history"
68 gdb_test_no_output "python f1calls = \{x for x in fch if x.symbol and x.symbol.name == \"func1\"\}"
69 gdb_test_no_output "python f2calls = \{x for x in fch if x.symbol and x.symbol.name == \"func2\"\}"
70
d512d31c
PA
71 gdb_test "python print(not f${self}calls)" "False"
72 gdb_test "python print(not f${other}calls)" "True"
ae20e79a
TW
73 }
74}
75
76foreach_with_prefix thread { 1 2 } {
77 gdb_test "thread $thread"
78 check_insn_for_thread 1 2
79 check_insn_for_thread 2 1
80}