Home | History | Annotate | Line # | Download | only in gdb.base
frameapply.exp revision 1.1.1.2
      1      1.1  christos # This testcase is part of GDB, the GNU debugger.
      2      1.1  christos 
      3  1.1.1.2  christos # Copyright 2018-2020 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 # Test 'frame apply [all | COUNT | -COUNT | level LEVEL...] [FLAG]... COMMAND'.
     20      1.1  christos 
     21      1.1  christos standard_testfile
     22      1.1  christos 
     23      1.1  christos if { [prepare_for_testing "failed to prepare" ${testfile}] } {
     24      1.1  christos     return -1
     25      1.1  christos }
     26      1.1  christos 
     27      1.1  christos clean_restart ${binfile}
     28      1.1  christos 
     29      1.1  christos 
     30      1.1  christos if ![runto setup_done] then {
     31      1.1  christos     fail "can't run to setup_done"
     32      1.1  christos     return 0
     33      1.1  christos }
     34      1.1  christos 
     35      1.1  christos set any "\[^\r\n\]*"
     36      1.1  christos set ws "\[ \t\]\+"
     37      1.1  christos set number "\[0-9]\+"
     38      1.1  christos 
     39      1.1  christos 
     40      1.1  christos # Check all | COUNT | -COUNT | level LEVEL... with a simple command.
     41      1.1  christos with_test_prefix "simple command" {
     42      1.1  christos     foreach_with_prefix frame_apply_args {
     43      1.1  christos 	"all"
     44      1.1  christos 	"6"
     45      1.1  christos 	"-6"
     46      1.1  christos 	"level 0-5"
     47      1.1  christos 	"level 0-3 4-5"
     48      1.1  christos 	"level 0 1-2 3-5"
     49      1.1  christos 	"level 0 1 2 3 4 5"
     50      1.1  christos 	"level 0-0 1-1 2-2 3-3 4-4 5-5" } {
     51      1.1  christos 	    set cmd "frame apply $frame_apply_args p /x 20"
     52      1.1  christos 	    gdb_test $cmd \
     53      1.1  christos 		[multi_line \
     54      1.1  christos 		     "#0${ws}setup_done ${any}" \
     55      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     56      1.1  christos 		     "#1${ws}${any} f1 ${any}" \
     57      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     58      1.1  christos 		     "#2${ws}${any} f2 ${any}" \
     59      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     60      1.1  christos 		     "#3${ws}${any} f3 ${any}" \
     61      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     62      1.1  christos 		     "#4${ws}${any} f4 ${any}" \
     63      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     64      1.1  christos 		     "#5${ws}${any} main ${any}" \
     65      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     66      1.1  christos 		    ] \
     67      1.1  christos 		"run a simple command on all frames"
     68      1.1  christos 	}
     69      1.1  christos }
     70      1.1  christos 
     71      1.1  christos # Check frame apply on 3 innermost frames.
     72      1.1  christos with_test_prefix "innermost 3" {
     73      1.1  christos     foreach_with_prefix frame_apply_args {
     74      1.1  christos 	"3"
     75      1.1  christos 	"level 0-2" } {
     76      1.1  christos 	    set cmd "frame apply $frame_apply_args p /x 20"
     77      1.1  christos 	    gdb_test $cmd \
     78      1.1  christos 		[multi_line \
     79      1.1  christos 		     "#0${ws}setup_done ${any}" \
     80      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     81      1.1  christos 		     "#1${ws}${any} f1 ${any}" \
     82      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     83      1.1  christos 		     "#2${ws}${any} f2 ${any}" \
     84      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     85      1.1  christos 		    ] \
     86      1.1  christos 		"run a simple command on the 3 innermost frames"
     87      1.1  christos 	}
     88      1.1  christos }
     89      1.1  christos 
     90      1.1  christos # Check frame apply on 3 outermost frames.
     91      1.1  christos with_test_prefix "outermost 3" {
     92      1.1  christos     foreach_with_prefix frame_apply_args {
     93      1.1  christos 	"-3" } {
     94      1.1  christos 	    set cmd "frame apply $frame_apply_args p /x 20"
     95      1.1  christos 	    gdb_test $cmd \
     96      1.1  christos 		[multi_line \
     97      1.1  christos 		     "#3${ws}${any} f3 ${any}" \
     98      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
     99      1.1  christos 		     "#4${ws}${any} f4 ${any}" \
    100      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
    101      1.1  christos 		     "#5${ws}${any} main ${any}" \
    102      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
    103      1.1  christos 		    ] \
    104      1.1  christos 		"run a simple command on the 3 outermost frames"
    105      1.1  christos 	}
    106      1.1  christos }
    107      1.1  christos 
    108      1.1  christos # Check -c (continue) and -s (silently continue) flags.
    109      1.1  christos with_test_prefix "!cont !silent flags" {
    110      1.1  christos     foreach_with_prefix frame_apply_args {
    111      1.1  christos 	"all"
    112      1.1  christos 	"level 0-5"
    113      1.1  christos     } {
    114      1.1  christos 	set cmd "frame apply $frame_apply_args p f3arg"
    115      1.1  christos 	gdb_test $cmd \
    116      1.1  christos 	    [multi_line \
    117      1.1  christos 		 "#0${ws}setup_done ${any}" \
    118      1.1  christos 		 "No symbol \\\"f3arg\\\" in current context." \
    119      1.1  christos 		] \
    120      1.1  christos 	    "run a failing command that aborts frame apply"
    121      1.1  christos     }
    122      1.1  christos }
    123      1.1  christos 
    124      1.1  christos with_test_prefix "cont !silent flags" {
    125      1.1  christos     foreach_with_prefix frame_apply_args {
    126      1.1  christos 	"all -c"
    127      1.1  christos 	"level 0-5 -c"} {
    128      1.1  christos 	    set cmd "frame apply $frame_apply_args p f3arg"
    129      1.1  christos 	    gdb_test $cmd \
    130      1.1  christos 		[multi_line \
    131      1.1  christos 		     "#0${ws}setup_done ${any}" \
    132      1.1  christos 		     "No symbol \\\"f3arg\\\" in current context." \
    133      1.1  christos 		     "#1${ws}${any} f1 ${any}" \
    134      1.1  christos 		     "No symbol \\\"f3arg\\\" in current context." \
    135      1.1  christos 		     "#2${ws}${any} f2 ${any}" \
    136      1.1  christos 		     "No symbol \\\"f3arg\\\" in current context." \
    137      1.1  christos 		     "#3${ws}${any} f3 ${any}" \
    138      1.1  christos 		     "\\\$\[0-9]+ = 3${any}" \
    139      1.1  christos 		     "#4${ws}${any} f4 ${any}" \
    140      1.1  christos 		     "No symbol \\\"f3arg\\\" in current context." \
    141      1.1  christos 		     "#5${ws}${any} main ${any}" \
    142      1.1  christos 		     "No symbol \\\"f3arg\\\" in current context." \
    143      1.1  christos 		    ] \
    144      1.1  christos 		"run a command failing in all frames except #3, -c to continue"
    145      1.1  christos 	}
    146      1.1  christos }
    147      1.1  christos 
    148      1.1  christos with_test_prefix "!cont silent flags" {
    149      1.1  christos     foreach_with_prefix cmd_and_args {
    150      1.1  christos 	"frame apply all -s"
    151      1.1  christos 	"faas"
    152      1.1  christos 	"frame apply level 0-5 -s"} {
    153      1.1  christos 	    set cmd "$cmd_and_args p f3arg"
    154      1.1  christos 	    gdb_test $cmd \
    155      1.1  christos 		[multi_line \
    156      1.1  christos 		     "#3${ws}${any} f3 ${any}" \
    157      1.1  christos 		     "\\\$\[0-9]+ = 3${any}" \
    158      1.1  christos 		    ] \
    159      1.1  christos 		"run a command failing in all frames except #3, -s to silently continue"
    160      1.1  christos 	}
    161      1.1  christos }
    162      1.1  christos 
    163      1.1  christos # Check quietness.
    164      1.1  christos with_test_prefix "!quiet flag" {
    165      1.1  christos     foreach_with_prefix frame_apply_args {
    166      1.1  christos 	"2"
    167      1.1  christos 	"level 0-1"} {
    168      1.1  christos 	    set cmd "frame apply $frame_apply_args p /x 20"
    169      1.1  christos 	    gdb_test $cmd \
    170      1.1  christos 		[multi_line \
    171      1.1  christos 		     "#0${ws}setup_done ${any}" \
    172      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
    173      1.1  christos 		     "#1${ws}${any} f1 ${any}" \
    174      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
    175      1.1  christos 		    ] \
    176      1.1  christos 		"run a command, printing location"
    177      1.1  christos 	}
    178      1.1  christos }
    179      1.1  christos 
    180      1.1  christos with_test_prefix "quiet flag" {
    181      1.1  christos     foreach_with_prefix frame_apply_args {
    182      1.1  christos 	"2 -q"
    183      1.1  christos 	"level 0-1 -q"} {
    184      1.1  christos 	    set cmd "frame apply $frame_apply_args p /x 20"
    185      1.1  christos 	    gdb_test $cmd \
    186      1.1  christos 		[multi_line \
    187      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
    188      1.1  christos 		     "\\\$\[0-9]+ = 0x14${any}" \
    189      1.1  christos 		    ] \
    190      1.1  christos 		"run a command with -q quiet flag, printing only command results"
    191      1.1  christos 	}
    192      1.1  christos }
    193      1.1  christos 
    194      1.1  christos # Check multiple flags together.
    195      1.1  christos with_test_prefix "quiet silent flags" {
    196      1.1  christos     foreach_with_prefix frame_apply_args {
    197      1.1  christos 	"all -q -s -q"
    198      1.1  christos 	"level 0-5 -q -s -q"} {
    199      1.1  christos 	    set cmd "frame apply $frame_apply_args p f3arg"
    200      1.1  christos 	    gdb_test $cmd \
    201      1.1  christos 		"\\\$\[0-9]+ = 3${any}" \
    202      1.1  christos 		"run a command failing in all frames except #3, -s to silently continue, quiet"
    203      1.1  christos 	}
    204      1.1  christos }
    205      1.1  christos 
    206      1.1  christos # Check invalid flag combinations.
    207      1.1  christos gdb_test "frame apply all -c -s p f3arg" \
    208      1.1  christos     "frame apply all: -c and -s are mutually exclusive" \
    209      1.1  christos     "check -c and -s cannot be used simultaneously"
    210      1.1  christos 
    211      1.1  christos # Check some cases of missing or wrong args.
    212      1.1  christos gdb_test "frame apply" "Missing COUNT argument." "missing COUNT"
    213      1.1  christos gdb_test "frame apply -c" "Invalid COUNT argument." "invalid COUNT arg"
    214      1.1  christos gdb_test "frame apply level 4-2 p 1" "inverted range" "inverted range"
    215      1.1  christos gdb_test "frame apply level 0-3" \
    216      1.1  christos     "Please specify a command to apply on the selected frames" \
    217      1.1  christos     "missing command"
    218  1.1.1.2  christos gdb_test "faas" "Please specify a command to apply on all frames" \
    219  1.1.1.2  christos     "missing command for faas"
    220