Home | History | Annotate | Line # | Download | only in gdb.base
      1      1.1  christos # This testcase is part of GDB, the GNU debugger.
      2      1.1  christos 
      3  1.1.1.4  christos # Copyright 2018-2024 Free Software Foundation, Inc.
      4      1.1  christos 
      5      1.1  christos # This program is free software; you can redistribute it and/or modify
      6      1.1  christos # it under the terms of the GNU General Public License as published by
      7      1.1  christos # the Free Software Foundation; either version 3 of the License, or
      8      1.1  christos # (at your option) any later version.
      9      1.1  christos #
     10      1.1  christos # This program is distributed in the hope that it will be useful,
     11      1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12      1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13      1.1  christos # GNU General Public License for more details.
     14      1.1  christos #
     15      1.1  christos # You should have received a copy of the GNU General Public License
     16      1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17      1.1  christos 
     18      1.1  christos 
     19      1.1  christos # This test verifies the TYPEREGEXP and NAMEREGEXP matching logic
     20      1.1  christos # in the commands
     21      1.1  christos #   info [args|functions|locals|variables] [-q] [-t TYPEREGEXP] [NAMEREGEXP].
     22      1.1  christos 
     23      1.1  christos 
     24      1.1  christos standard_testfile
     25      1.1  christos 
     26      1.1  christos if { [prepare_for_testing "failed to prepare" ${testfile}] } {
     27      1.1  christos     return -1
     28      1.1  christos }
     29      1.1  christos 
     30  1.1.1.3  christos if {![runto setup_done]} {
     31      1.1  christos     return 0
     32      1.1  christos }
     33      1.1  christos 
     34      1.1  christos set any "\[^\r\n\]*"
     35      1.1  christos set ws "\[ \t\]\+"
     36      1.1  christos set number "\[0-9]\+"
     37      1.1  christos 
     38      1.1  christos 
     39      1.1  christos ############# Test 'info functions'.
     40      1.1  christos 
     41      1.1  christos with_test_prefix "info functions nameregexp" {
     42      1.1  christos     foreach cmd {
     43      1.1  christos 	"info functions info_fun"
     44      1.1  christos 	"info functions -- info_fun"
     45      1.1  christos 	"info functions ^info_fun" } {
     46      1.1  christos 	    gdb_test $cmd \
     47      1.1  christos 		[multi_line \
     48      1.1  christos 		     "All functions matching regular expression \".*info_fun.*\":" \
     49      1.1  christos 		     "" \
     50      1.1  christos 		     "File .*info_qt.c:" \
     51      1.1  christos 		     "${number}:	void info_fun1\\\(void\\\);" \
     52      1.1  christos 		     "${number}:	int info_fun2\\\(char\\\);" \
     53      1.1  christos 		     "${number}:	int info_fun2bis\\\(char\\\);" \
     54      1.1  christos 		     "${number}:	entier info_fun2xxx\\\(char, int, int\\\);" \
     55      1.1  christos 		     "${number}:	entier info_fun2yyy\\\(char, int, int\\\);" \
     56      1.1  christos 		    ]
     57      1.1  christos     }
     58      1.1  christos }
     59      1.1  christos 
     60      1.1  christos with_test_prefix "info functions nameregexp quiet" {
     61      1.1  christos     foreach cmd {
     62      1.1  christos 	"info functions -q info_fun"
     63      1.1  christos 	"info functions -q -- info_fun" } {
     64      1.1  christos 	    gdb_test $cmd \
     65      1.1  christos 		[multi_line \
     66      1.1  christos 		     "" \
     67      1.1  christos 		     "File .*info_qt.c:" \
     68      1.1  christos 		     "${number}:	void info_fun1\\\(void\\\);" \
     69      1.1  christos 		     "${number}:	int info_fun2\\\(char\\\);" \
     70      1.1  christos 		     "${number}:	int info_fun2bis\\\(char\\\);" \
     71      1.1  christos 		     "${number}:	entier info_fun2xxx\\\(char, int, int\\\);" \
     72      1.1  christos 		     "${number}:	entier info_fun2yyy\\\(char, int, int\\\);" \
     73      1.1  christos 		    ]
     74      1.1  christos 	}
     75      1.1  christos }
     76      1.1  christos 
     77      1.1  christos with_test_prefix "info functions nameregexp quiet no match" {
     78      1.1  christos     foreach cmd {
     79      1.1  christos 	"info functions -q nowaythiscanmatch"
     80      1.1  christos 	"info functions -q -- -q" } {
     81      1.1  christos 	    gdb_test_no_output $cmd
     82      1.1  christos 	}
     83      1.1  christos }
     84      1.1  christos 
     85      1.1  christos with_test_prefix "info functions typeregexp nameregexp" {
     86      1.1  christos     foreach cmd {
     87      1.1  christos 	"info functions -t entier -q info_fun"
     88      1.1  christos 	"info functions -q -t 'entier (' -- info_fun"
     89      1.1  christos 	"info functions -q -t '(char, int, int)' -- info_fun"
     90      1.1  christos 	"info functions -q -t 'entier (char, int, int)' -- info_fun" } {
     91      1.1  christos 	    gdb_test $cmd \
     92      1.1  christos 		[multi_line \
     93      1.1  christos 		     "" \
     94      1.1  christos 		     "File .*info_qt.c:" \
     95      1.1  christos 		     "${number}:	entier info_fun2xxx\\\(char, int, int\\\);" \
     96      1.1  christos 		     "${number}:	entier info_fun2yyy\\\(char, int, int\\\);" \
     97      1.1  christos 		    ]
     98      1.1  christos 	}
     99      1.1  christos }
    100      1.1  christos 
    101      1.1  christos with_test_prefix "info functions typeregexp nameregexp no match" {
    102      1.1  christos     gdb_test_no_output "info functions -t ganze_Zahl -q info_fun" \
    103      1.1  christos 	"quiet output info functions no matching type"
    104      1.1  christos }
    105      1.1  christos 
    106      1.1  christos ############# Test 'info variables'.
    107      1.1  christos 
    108      1.1  christos with_test_prefix "info variables nameregexp" {
    109      1.1  christos     foreach cmd {
    110      1.1  christos 	"info variables info_qt"
    111      1.1  christos 	"info variables -- info_qt"
    112      1.1  christos 	"info variables ^info_qt" } {
    113      1.1  christos 	    gdb_test $cmd \
    114      1.1  christos 		[multi_line \
    115      1.1  christos 		     "All variables matching regular expression \".*info_qt.*\":" \
    116      1.1  christos 		     "" \
    117      1.1  christos 		     "File .*info_qt.c:" \
    118      1.1  christos 		     "${number}:	entier info_qt_ent;" \
    119      1.1  christos 		     "${number}:	int info_qt_inc;" \
    120      1.1  christos 		    ]
    121      1.1  christos 	}
    122      1.1  christos }
    123      1.1  christos 
    124      1.1  christos with_test_prefix "info variables nameregexp quiet no match" {
    125      1.1  christos     foreach cmd {
    126      1.1  christos 	"info variables -q nowaythiscanmatch"
    127      1.1  christos 	"info variables -q -- -q" } {
    128      1.1  christos 	    gdb_test_no_output $cmd
    129      1.1  christos 	}
    130      1.1  christos }
    131      1.1  christos 
    132      1.1  christos with_test_prefix "info variables typeregexp nameregexp quiet" {
    133      1.1  christos     foreach cmd {
    134      1.1  christos 	"info variables -t entier -q info_qt"
    135      1.1  christos 	"info variables -q -t entier -- info_qt" } {
    136      1.1  christos 	    gdb_test $cmd \
    137      1.1  christos 		[multi_line \
    138      1.1  christos 		     "" \
    139      1.1  christos 		     "File .*info_qt.c:" \
    140      1.1  christos 		     "${number}:	entier info_qt_ent;" \
    141      1.1  christos 		    ]
    142      1.1  christos 	}
    143      1.1  christos }
    144      1.1  christos 
    145      1.1  christos with_test_prefix "info variables typeregexp nameregexp quiet no match" {
    146      1.1  christos     gdb_test_no_output "info variables -t ganze_Zahl -q info_at" \
    147      1.1  christos 	"quiet output info variables no matching type"
    148      1.1  christos }
    149      1.1  christos 
    150      1.1  christos 
    151      1.1  christos 
    152      1.1  christos ############# Test 'info args' in function setup.
    153      1.1  christos 
    154      1.1  christos gdb_test "frame 1" ".* in setup .*" "set frame 1 for info args"
    155      1.1  christos 
    156      1.1  christos with_test_prefix "info args matching all args" {
    157      1.1  christos     foreach cmd {
    158      1.1  christos 	"info args"
    159      1.1  christos 	"info args arg_"
    160      1.1  christos 	"info args g"
    161      1.1  christos 	"info args -- .*" } {
    162      1.1  christos 	    gdb_test $cmd \
    163      1.1  christos 		[multi_line \
    164      1.1  christos 		     "arg_c = 100 'd'" \
    165      1.1  christos 		     "arg_i = 3" \
    166      1.1  christos 		     "arg_j = 4" \
    167      1.1  christos 		    ]
    168      1.1  christos 	}
    169      1.1  christos }
    170      1.1  christos 
    171      1.1  christos with_test_prefix "info args matching some args" {
    172      1.1  christos     foreach cmd {
    173      1.1  christos 	"info args -t int"
    174      1.1  christos 	"info args arg_[ij]"} {
    175      1.1  christos 	    gdb_test $cmd \
    176      1.1  christos 		[multi_line \
    177      1.1  christos 		     "arg_i = 3" \
    178      1.1  christos 		     "arg_j = 4" \
    179      1.1  christos 		    ]
    180      1.1  christos 	}
    181      1.1  christos }
    182      1.1  christos 
    183      1.1  christos with_test_prefix "info args no match" {
    184      1.1  christos     gdb_test "info args nowaythiscanmatch" "No matching arguments." "no matching args"
    185      1.1  christos     gdb_test_no_output "info args -q nowaythiscanmatch" "quiet no matching args"
    186      1.1  christos     gdb_test_no_output "info args -q -t entier" "quiet no matching args with type"
    187      1.1  christos }
    188      1.1  christos 
    189      1.1  christos ############# Test 'info locals' in function setup.
    190      1.1  christos 
    191      1.1  christos gdb_test "frame 1" ".* in setup .*" "set frame 1 for info locals"
    192      1.1  christos 
    193      1.1  christos with_test_prefix "info locals matching all locals" {
    194      1.1  christos     foreach cmd {
    195      1.1  christos 	"info locals"
    196      1.1  christos 	"info locals loc_arg_"
    197      1.1  christos 	"info locals g"
    198      1.1  christos 	"info locals -- .*" } {
    199      1.1  christos 	    gdb_test $cmd \
    200      1.1  christos 		[multi_line \
    201      1.1  christos 		     "loc_arg_c = 100 'd'" \
    202      1.1  christos 		     "loc_arg_i = 3" \
    203      1.1  christos 		     "loc_arg_j = 4" \
    204      1.1  christos 		    ]
    205      1.1  christos 	}
    206      1.1  christos }
    207      1.1  christos 
    208      1.1  christos with_test_prefix "info locals matching some locals" {
    209      1.1  christos     foreach cmd {
    210      1.1  christos 	"info locals -t int"
    211      1.1  christos 	"info locals arg_[ij]"
    212      1.1  christos 	"info locals loc_arg_[ij]"} {
    213      1.1  christos 	    gdb_test $cmd \
    214      1.1  christos 		[multi_line \
    215      1.1  christos 		     "loc_arg_i = 3" \
    216      1.1  christos 		     "loc_arg_j = 4" \
    217      1.1  christos 		    ]
    218      1.1  christos 	}
    219      1.1  christos }
    220      1.1  christos 
    221      1.1  christos with_test_prefix "info locals no match" {
    222      1.1  christos     gdb_test "info locals nowaythiscanmatch" "No matching locals." "no matching locals"
    223      1.1  christos     gdb_test_no_output "info locals -q nowaythiscanmatch" "quiet no matching locals"
    224      1.1  christos     gdb_test_no_output "info locals -q -t ganze_Zahl loc" "quiet no matching locals with type"
    225      1.1  christos }
    226      1.1  christos 
    227      1.1  christos # Verify that the rest of the args is taken as a single regexp.
    228      1.1  christos with_test_prefix "rest of args as single regexp" {
    229      1.1  christos     gdb_test "info functions abc def" \
    230      1.1  christos 	"All functions matching regular expression \\\"abc def\\\":" \
    231      1.1  christos 	"single regexp"
    232      1.1  christos 
    233      1.1  christos     gdb_test "info functions -t uvw abc def" \
    234      1.1  christos 	"All functions matching regular expression \\\"abc def\\\" with type matching regular expression \\\"uvw\\\":" \
    235      1.1  christos 	"-t noquote single regexp"
    236      1.1  christos 
    237      1.1  christos     gdb_test "info functions -t 'uvw xyz' abc def" \
    238      1.1  christos 	"All functions matching regular expression \\\"abc def\\\" with type matching regular expression \\\"uvw xyz\\\":" \
    239      1.1  christos 	"-t quote single regexp"
    240      1.1  christos }
    241