[gdb/testsuite] Fix regexp in py-rbreak.exp
[external/binutils.git] / gdb / testsuite / gdb.python / py-rbreak.exp
1 # Copyright (C) 2017-2018 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 mechanism
17 # exposing values to Python.
18
19 load_lib gdb-python.exp
20
21 standard_testfile py-rbreak.c py-rbreak-func2.c
22
23 if {[prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } {
24     return 1
25 }
26
27 # Skip all tests if Python scripting is not enabled.
28 if { [skip_python_tests] } { continue }
29
30 if ![runto_main] then {
31     fail "can't run to main"
32     return 0
33 }
34
35 gdb_test_no_output "nosharedlibrary"
36 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"^\[^_\]\",minsyms=False)" \
37     "get all function breakpoints" 0
38 gdb_test "py print(len(sl))" "11" \
39     "check number of returned breakpoints is 11"
40 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"main\.\*\",minsyms=False)" \
41     "get main function breakpoint" 0
42 gdb_test "py print(len(sl))" "1" \
43     "check number of returned breakpoints is 1"
44 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func\.\*\",minsyms=False,throttle=10)" \
45     "get functions matching func.*" 0
46 gdb_test "py print(len(sl))" "9" \
47     "check number of returned breakpoints is 9"
48 gdb_test "py gdb.rbreak(\"func\.\*\",minsyms=False,throttle=5)" \
49     "Number of breakpoints exceeds throttled maximum.*" \
50     "check throttle errors on too many breakpoints"
51 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func1\",minsyms=True)" \
52     "including minimal symbols, get functions matching func.*" 0
53 gdb_test "py print(len(sl))" "2" \
54     "check number of returned breakpoints is 2"
55 gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"efunc1\")" \
56     "find a symbol in objfile" 1
57 gdb_py_test_silent_cmd "python symtab = sym\[0\].symtab" \
58     "get backing symbol table" 1
59 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func\.\*\",minsyms=False,throttle=10,symtabs=\[symtab\])" \
60     "get functions matching func.* in one symtab only" 0
61 gdb_test "py print(len(sl))" "3" \
62     "check number of returned breakpoints is 3"