Home | History | Annotate | Line # | Download | only in gdb.python
      1 # Copyright (C) 2017-2024 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 require allow_python_tests
     22 
     23 standard_testfile py-rbreak.c py-rbreak-func2.c
     24 
     25 if {[prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } {
     26     return 1
     27 }
     28 
     29 if {![runto_main]} {
     30     return 0
     31 }
     32 
     33 gdb_test_no_output "nosharedlibrary"
     34 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"\",minsyms=False)" \
     35     "get all function breakpoints" 0
     36 set min_breakpoints 11
     37 gdb_test_multiple "py print(len(sl))" \
     38     "check number of returned breakpoints is at least $min_breakpoints" {
     39 	-re -wrap "($decimal)" {
     40 	    set n $expect_out(1,string)
     41 	    gdb_assert { $n >= $min_breakpoints } $gdb_test_name
     42 	}
     43     }
     44 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"main\.\*\",minsyms=False)" \
     45     "get main function breakpoint" 0
     46 gdb_test "py print(len(sl))" "1" \
     47     "check number of returned breakpoints is 1"
     48 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func\.\*\",minsyms=False,throttle=10)" \
     49     "get functions matching func.*" 0
     50 gdb_test "py print(len(sl))" "9" \
     51     "check number of returned breakpoints is 9"
     52 gdb_test "py gdb.rbreak(\"func\.\*\",minsyms=False,throttle=5)" \
     53     "Number of breakpoints exceeds throttled maximum.*" \
     54     "check throttle errors on too many breakpoints"
     55 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func1\",minsyms=True)" \
     56     "including minimal symbols, get functions matching func.*" 0
     57 gdb_test "py print(len(sl))" "2" \
     58     "check number of returned breakpoints is 2"
     59 gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"efunc1\")" \
     60     "find a symbol in objfile" 1
     61 gdb_py_test_silent_cmd "python symtab = sym\[0\].symtab" \
     62     "get backing symbol table" 1
     63 gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func\.\*\",minsyms=False,throttle=10,symtabs=\[symtab\])" \
     64     "get functions matching func.* in one symtab only" 0
     65 gdb_test "py print(len(sl))" "3" \
     66     "check number of returned breakpoints is 3"
     67