10086f71281bbac26aa51ab4ff7b7ea106c6ff94
[external/binutils.git] / gdb / testsuite / gdb.python / py-caller-is.exp
1 # Copyright (C) 2012-2016 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 # This file is part of the GDB testsuite.  It tests the convenience
17 # functions in caller_is.py.
18
19 load_lib gdb-python.exp
20
21 standard_testfile
22
23 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
24     return -1
25 }
26
27 if ![runto_main] {
28     return 0
29 }
30
31 # Skip all tests if Python scripting is not enabled.
32 if { [skip_python_tests] } { continue }
33
34 gdb_breakpoint "bottom_func"
35 gdb_continue_to_breakpoint "bottom_func"
36
37 proc test_all_caller_is_fns { } {
38     gdb_test "p \$_caller_is (\"bottom_func\", 0)" " = 1"
39     gdb_test "p \$_caller_is (\"middle_func\")" " = 1"
40     gdb_test "p \$_caller_is (\"top_func\")" " = 0"
41     gdb_test "p \$_caller_is (\"middle_func\", 2)" " = 0"
42     gdb_test "p \$_caller_is (\"top_func\", 2)" " = 1"
43     gdb_test "p \$_caller_is (\"foo\", 100)" " = 0"
44     gdb_test "p \$_caller_is (\"foo\", -1)" "nframes must be >= 0"
45
46     gdb_test "p \$_caller_matches (\"^bottom\", 0)" " = 1"
47     gdb_test "p \$_caller_matches (\"^middle_\")" " = 1"
48     gdb_test "p \$_caller_matches (\"^top_\")" " = 0"
49     gdb_test "p \$_caller_matches (\"^middle_\", 2)" " = 0"
50     gdb_test "p \$_caller_matches (\"^top_f\", 2)" " = 1"
51     gdb_test "p \$_caller_matches (\"foo\", 100)" " = 0"
52     gdb_test "p \$_caller_matches (\"foo\", -1)" "nframes must be >= 0"
53
54     gdb_test "p \$_any_caller_is (\"bottom_func\", 0)" " = 1"
55     gdb_test "p \$_any_caller_is (\"middle_func\")" " = 1"
56     gdb_test "p \$_any_caller_is (\"top_func\")" " = 0"
57     gdb_test "p \$_any_caller_is (\"middle_func\", 2)" " = 1"
58     gdb_test "p \$_any_caller_is (\"top_func\", 2)" " = 1"
59     gdb_test "p \$_any_caller_is (\"main\", 100)" " = 1"
60     gdb_test "p \$_any_caller_is (\"foo\", 100)" " = 0"
61     gdb_test "p \$_any_caller_is (\"foo\", -1)" "nframes must be >= 0"
62
63     gdb_test "p \$_any_caller_matches (\"^bottom\", 0)" " = 1"
64     gdb_test "p \$_any_caller_matches (\"^middle_\")" " = 1"
65     gdb_test "p \$_any_caller_matches (\"^top_\")" " = 0"
66     gdb_test "p \$_any_caller_matches (\"^middle_\", 2)" " = 1"
67     gdb_test "p \$_any_caller_matches (\"^top_f\", 2)" " = 1"
68     gdb_test "p \$_any_caller_matches (\"^main\", 100)" " = 1"
69     gdb_test "p \$_any_caller_matches (\"foo\", 100)" " = 0"
70     gdb_test "p \$_any_caller_matches (\"foo\", -1)" "nframes must be >= 0"
71 }
72
73 test_all_caller_is_fns