Home | History | Annotate | Line # | Download | only in gdb.base
pending.exp revision 1.10
      1  1.10  christos #   Copyright 2003-2023 Free Software Foundation, Inc.
      2   1.1  christos 
      3   1.1  christos # This program is free software; you can redistribute it and/or modify
      4   1.1  christos # it under the terms of the GNU General Public License as published by
      5   1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6   1.1  christos # (at your option) any later version.
      7   1.1  christos #
      8   1.1  christos # This program is distributed in the hope that it will be useful,
      9   1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10   1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11   1.1  christos # GNU General Public License for more details.
     12   1.1  christos #
     13   1.1  christos # You should have received a copy of the GNU General Public License
     14   1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15   1.1  christos 
     16   1.1  christos # This file was created by Jeff Johnston. (jjohnstn (at) redhat.com)
     17   1.1  christos 
     18   1.1  christos #
     19   1.1  christos # test running programs
     20   1.1  christos #
     21   1.1  christos 
     22   1.1  christos if {[skip_shlib_tests]} {
     23   1.1  christos     return 0
     24   1.1  christos }
     25   1.1  christos 
     26   1.1  christos standard_testfile .c
     27   1.1  christos set libfile "pendshr"
     28   1.1  christos set libsrc  $srcdir/$subdir/$libfile.c
     29   1.1  christos set lib_sl  [standard_output_file $libfile.sl]
     30   1.1  christos 
     31   1.1  christos set lib_opts  debug
     32   1.1  christos set exec_opts [list debug shlib=$lib_sl]
     33   1.1  christos 
     34   1.1  christos if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
     35   1.1  christos      || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
     36   1.7  christos     untested "failed to compile"
     37   1.1  christos     return -1
     38   1.1  christos }
     39   1.1  christos 
     40   1.1  christos # Start with a fresh gdb.
     41   1.1  christos 
     42   1.1  christos gdb_exit
     43   1.1  christos gdb_start
     44   1.1  christos gdb_reinitialize_dir $srcdir/$subdir
     45   1.1  christos 
     46   1.1  christos gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
     47   1.1  christos      -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
     48   1.1  christos 	    gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint (without symbols)"
     49   1.1  christos      }
     50   1.1  christos }
     51   1.1  christos 
     52   1.1  christos # Complete the condition (PR 15413).
     53   1.1  christos gdb_test "complete condition " "condition 1"
     54   1.1  christos 
     55   1.1  christos gdb_test "info break" \
     56   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
     57   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendfunc1.*" \
     58   1.1  christos "single pending breakpoint info (without symbols)"
     59   1.1  christos 
     60  1.10  christos with_test_prefix "first load" {
     61  1.10  christos     gdb_load ${binfile}
     62  1.10  christos     gdb_load_shlib $lib_sl
     63  1.10  christos }
     64   1.1  christos 
     65   1.1  christos set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
     66   1.1  christos 
     67   1.1  christos gdb_run_cmd
     68   1.1  christos 
     69   1.1  christos gdb_test "" \
     70   1.1  christos ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
     71   1.1  christos "run to resolved breakpoint 1 (without symbols)"
     72   1.1  christos 
     73   1.1  christos # Restart with a fresh gdb.
     74   1.1  christos 
     75   1.1  christos gdb_exit
     76   1.1  christos gdb_start
     77   1.1  christos gdb_reinitialize_dir $srcdir/$subdir
     78   1.1  christos 
     79  1.10  christos with_test_prefix "second load" {
     80  1.10  christos     gdb_load ${binfile}
     81  1.10  christos     gdb_load_shlib $lib_sl
     82  1.10  christos }
     83   1.1  christos 
     84   1.1  christos #
     85   1.1  christos # Test setting, querying, and modifying pending breakpoints
     86   1.1  christos #
     87   1.1  christos 
     88   1.1  christos gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
     89   1.1  christos      -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
     90   1.1  christos 	    gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
     91   1.1  christos      }
     92   1.1  christos }
     93   1.1  christos 
     94   1.1  christos gdb_test "info break" \
     95   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
     96   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendfunc1.*" \
     97   1.1  christos "single pending breakpoint info"
     98   1.1  christos 
     99   1.1  christos #
    100   1.1  christos # Test breaking at existing function
    101   1.1  christos #
    102   1.1  christos 
    103   1.1  christos set mainline [gdb_get_line_number "break main here"]
    104   1.1  christos 
    105  1.10  christos gdb_test "break -q main" \
    106   1.1  christos     "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
    107   1.1  christos     "breakpoint function"
    108   1.1  christos 
    109   1.1  christos gdb_test "info break" \
    110   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    111   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendfunc1.*
    112   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline" \
    113   1.1  christos "pending plus real breakpoint info"
    114   1.1  christos 
    115   1.1  christos 
    116   1.1  christos #
    117   1.1  christos # Test not setting a pending breakpoint
    118   1.1  christos #
    119   1.1  christos gdb_test "break pendfunc2" \
    120   1.1  christos     "" \
    121   1.1  christos     "Don't set pending breakpoint" \
    122   1.1  christos     ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
    123   1.1  christos     "n"
    124   1.1  christos 
    125   1.1  christos #
    126   1.1  christos # Add condition to pending breakpoint
    127   1.1  christos #
    128   1.1  christos 
    129   1.1  christos gdb_test_no_output "condition 1 k == 1"
    130   1.1  christos 
    131   1.1  christos gdb_test "info break" \
    132   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    133   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendfunc1.*
    134   1.1  christos \[\t \]+stop only if k == 1.*
    135   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline" \
    136   1.1  christos "pending plus condition"
    137   1.1  christos 
    138   1.1  christos #
    139   1.1  christos # Disable pending breakpoint
    140   1.1  christos #
    141   1.1  christos 
    142   1.1  christos gdb_test_no_output "disable 1"
    143   1.1  christos 
    144   1.1  christos gdb_test "info break" \
    145   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    146   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep n.*PENDING.*pendfunc1.*
    147   1.1  christos \[\t \]+stop only if k == 1.*
    148   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline" \
    149   1.1  christos "pending disabled"
    150   1.1  christos 
    151   1.1  christos #
    152   1.1  christos # Add commands to pending breakpoint
    153   1.1  christos #
    154   1.1  christos gdb_test "commands 1\nprint k\nend" "" \
    155   1.1  christos     "Set commands for pending breakpoint"
    156   1.1  christos 
    157   1.1  christos gdb_test "info break" \
    158   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    159   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep n.*PENDING.*pendfunc1.*
    160   1.1  christos \[\t \]+stop only if k == 1.*
    161   1.1  christos \[\t \]+print k.*
    162   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline" \
    163   1.1  christos "pending disabled plus commands"
    164   1.1  christos 
    165   1.1  christos #
    166   1.1  christos # Try a pending break for a line in a source file with a condition
    167   1.1  christos #
    168   1.1  christos 
    169   1.1  christos set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
    170   1.7  christos gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "set pending breakpoint 2" {
    171   1.1  christos      -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
    172   1.1  christos 	    gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
    173   1.1  christos 		"Set pending breakpoint 2"
    174   1.1  christos      }
    175   1.1  christos }
    176   1.1  christos 
    177   1.1  christos gdb_test "info break" \
    178   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    179   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep n.*PENDING.*pendfunc1.*
    180   1.1  christos \[\t \]+stop only if k == 1.*
    181   1.1  christos \[\t \]+print k.*
    182   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline.*
    183   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
    184   1.1  christos "multiple pending breakpoints"
    185   1.1  christos 
    186   1.1  christos 
    187   1.1  christos #
    188   1.1  christos # Try a pending break for a line in a source file with ignore count:
    189   1.1  christos #
    190   1.1  christos 
    191   1.1  christos set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
    192   1.7  christos gdb_test_multiple "break pendshr.c:$bp3_loc" "set pending breakpoint 3" {
    193   1.1  christos      -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
    194   1.1  christos 	    gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
    195   1.1  christos 		"Set pending breakpoint 3"
    196   1.1  christos      }
    197   1.1  christos }
    198   1.1  christos 
    199   1.1  christos gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
    200   1.1  christos     "set ignore count on pending breakpoint 3"
    201   1.1  christos 
    202   1.1  christos gdb_test "info break" \
    203   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    204   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep n.*PENDING.*pendfunc1.*
    205   1.1  christos \[\t \]+stop only if k == 1.*
    206   1.1  christos \[\t \]+print k.*
    207   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline.*
    208   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*
    209   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*" \
    210   1.1  christos "multiple pending breakpoints 2"
    211   1.1  christos 
    212   1.1  christos #
    213   1.1  christos # Run to main which should resolve a pending breakpoint
    214   1.1  christos #
    215   1.1  christos 
    216   1.1  christos gdb_run_cmd
    217   1.1  christos gdb_test "" \
    218   1.1  christos ".*Breakpoint.*, main.*$mainline.*" \
    219   1.1  christos "running to main"
    220   1.1  christos 
    221   1.1  christos #
    222   1.1  christos # Re-enable the first pending breakpoint which should resolve
    223   1.1  christos #
    224   1.1  christos 
    225   1.1  christos gdb_test_no_output "enable 1" \
    226   1.1  christos "re-enabling pending breakpoint that can resolve instantly"
    227   1.1  christos 
    228   1.1  christos #
    229   1.1  christos # Continue to verify conditionals and commands for breakpoints are honored
    230   1.1  christos #
    231   1.1  christos 
    232   1.1  christos gdb_test "continue" \
    233   1.1  christos ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
    234   1.1  christos "continue to resolved breakpoint 2"
    235   1.1  christos 
    236   1.1  christos gdb_test "continue" \
    237   1.1  christos ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
    238   1.1  christos \[$\]1 = 1." \
    239   1.1  christos "continue to resolved breakpoint 1"
    240   1.1  christos 
    241   1.1  christos #
    242   1.1  christos # Disable the other two breakpoints, and continue to the one with
    243   1.1  christos # the ignore count.  Make sure you hit it the third time, x should
    244   1.1  christos # be 3 then.
    245   1.1  christos #
    246   1.1  christos 
    247  1.10  christos gdb_test "disable 7" "" "disable breakpoint 7"
    248  1.10  christos gdb_test "disable 5" "" "disable breakpoint 5"
    249   1.1  christos 
    250   1.1  christos gdb_test "continue" \
    251   1.1  christos 	 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
    252   1.1  christos "continue to resolved breakpoint 3"
    253   1.1  christos 
    254   1.1  christos delete_breakpoints
    255   1.1  christos 
    256   1.1  christos gdb_breakpoint "main"
    257   1.1  christos 
    258   1.1  christos #
    259   1.1  christos # Set non-existent pending breakpoint
    260   1.1  christos #
    261   1.1  christos gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
    262   1.1  christos      -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
    263   1.1  christos 	    gdb_test "y" "Breakpoint.*imaginary.*pending." \
    264   1.1  christos 		"set imaginary pending breakpoint"
    265   1.1  christos      }
    266   1.1  christos }
    267   1.1  christos 
    268   1.1  christos #
    269   1.1  christos # rerun program and make sure that any pending breakpoint remains and no
    270   1.1  christos # error messages are issued for the missing function
    271   1.1  christos #
    272   1.1  christos 
    273   1.1  christos rerun_to_main
    274   1.1  christos 
    275   1.1  christos gdb_test "info break" \
    276   1.1  christos     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
    277   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$mainline.*
    278   1.1  christos \[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*imaginary.*" \
    279   1.1  christos "verify pending breakpoint after restart"
    280