2004-07-13 13:01:04 +00:00
|
|
|
# This testcase is part of GDB, the GNU debugger.
|
|
|
|
|
2009-01-03 05:58:08 +00:00
|
|
|
# Copyright 1997, 1998, 1999, 2003, 2004, 2007, 2008, 2009
|
2008-01-01 22:53:26 +00:00
|
|
|
# Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-04-16 01:35:26 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
1999-04-16 01:35:26 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
1999-04-16 01:35:26 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
if $tracelevel then {
|
2004-07-13 13:01:04 +00:00
|
|
|
strace $tracelevel
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
global usestubs
|
|
|
|
|
|
|
|
#
|
|
|
|
# test running programs
|
|
|
|
#
|
|
|
|
set prms_id 0
|
|
|
|
set bug_id 0
|
|
|
|
|
|
|
|
set testfile "break"
|
|
|
|
set srcfile ${testfile}.c
|
2003-12-09 18:19:20 +00:00
|
|
|
set srcfile1 ${testfile}1.c
|
1999-04-16 01:35:26 +00:00
|
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
|
2006-03-07 15:23:33 +00:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested ena-dis-br.exp
|
|
|
|
return -1
|
2003-12-09 18:19:20 +00:00
|
|
|
}
|
|
|
|
|
2006-03-07 15:23:33 +00:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested ena-dis-br.exp
|
|
|
|
return -1
|
2003-12-09 18:19:20 +00:00
|
|
|
}
|
|
|
|
|
2006-03-07 15:23:33 +00:00
|
|
|
if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested ena-dis-br.exp
|
|
|
|
return -1
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
2003-12-09 18:19:20 +00:00
|
|
|
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
|
|
|
|
set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
|
|
|
|
set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
|
|
|
|
set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
|
|
|
|
set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
|
|
|
|
set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
|
|
|
|
set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1]
|
|
|
|
set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1]
|
|
|
|
set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1]
|
|
|
|
set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1]
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
if ![runto_main] then { fail "enable/disable break tests suppressed" }
|
|
|
|
|
|
|
|
# Verify that we can set a breakpoint (the location is irrelevant),
|
|
|
|
# then enable it (yes, it's already enabled by default), then hit it.
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
proc break_at { breakpoint where } {
|
|
|
|
global gdb_prompt
|
|
|
|
global expect_out
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set test "break $breakpoint"
|
|
|
|
set bp 0
|
|
|
|
gdb_test_multiple "$test" "$test" {
|
|
|
|
-re "Breakpoint (\[0-9\]*) at .*$where.*$gdb_prompt $" {
|
|
|
|
set bp $expect_out(1,string)
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $bp
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set bp [break_at "marker1" " line ($bp_location15|$bp_location16)"]
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "enable $bp" "" "enable break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*" \
|
|
|
|
"info break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
# See the comments in condbreak.exp for "run until breakpoint at
|
|
|
|
# marker1" for an explanation of the xfail below.
|
|
|
|
set test "continue to break marker1"
|
|
|
|
gdb_test_multiple "continue" "$test" {
|
|
|
|
-re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $" {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
-re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $" {
|
|
|
|
xfail "$test"
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "delete $bp" "" "delete break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
# Verify that we can set a breakpoint to be self-disabling after the
|
|
|
|
# first time it triggers.
|
|
|
|
set bp [break_at "marker2" " line ($bp_location8|$bp_location9)"]
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "enable once $bp" "" "enable once break marker2"
|
|
|
|
|
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*" \
|
|
|
|
"info auto-disabled break marker2"
|
|
|
|
|
|
|
|
# See the comments in condbreak.exp for "run until breakpoint at
|
|
|
|
# marker1" for an explanation of the xfail below.
|
|
|
|
set test "continue to auto-disabled break marker2"
|
|
|
|
gdb_test_multiple "continue" "$test" {
|
|
|
|
-re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $" {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
-re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $" {
|
|
|
|
xfail "$test"
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*" \
|
|
|
|
"info auto-disabled break marker2"
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
# Verify that we don't stop at a disabled breakpoint.
|
1999-04-26 18:34:20 +00:00
|
|
|
gdb_continue_to_end "no stop"
|
|
|
|
rerun_to_main
|
|
|
|
gdb_continue_to_end "no stop at auto-disabled break marker2"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
# Verify that we can set a breakpoint to be self-deleting after the
|
|
|
|
# first time it triggers.
|
|
|
|
if ![runto_main] then {
|
|
|
|
fail "enable/disable break tests suppressed"
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set bp [break_at "marker3" " line ($bp_location17|$bp_location18)"]
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "enable del $bp" "" "enable del break marker3"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*" \
|
|
|
|
"info auto-deleted break marker2"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "continue" \
|
|
|
|
".*marker3 .*:($bp_location17|$bp_location18).*" \
|
|
|
|
"continue to auto-deleted break marker3"
|
|
|
|
|
|
|
|
gdb_test "info break $bp" \
|
|
|
|
".*No breakpoint or watchpoint number.*" \
|
|
|
|
"info auto-deleted break marker3"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Verify that we can set a breakpoint and manually disable it (we've
|
|
|
|
# already proven that disabled bp's don't trigger).
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set bp [break_at "marker4" " line ($bp_location14|$bp_location13).*"]
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "disable $bp" "" "disable break marker4"
|
|
|
|
|
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*" \
|
|
|
|
"info break marker4"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Verify that we can set a breakpoint with an ignore count N, which
|
|
|
|
# should cause the next N triggers of the bp to be ignored. (This is
|
|
|
|
# a flavor of enablement/disablement, after all.)
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
if ![runto_main] then {
|
|
|
|
fail "enable/disable break tests suppressed"
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set bp [break_at "marker1" " line ($bp_location15|$bp_location16).*"]
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
# Verify that an ignore of a non-existent breakpoint is gracefully
|
|
|
|
# handled.
|
2004-07-13 13:01:04 +00:00
|
|
|
|
|
|
|
gdb_test "ignore 999 2" \
|
|
|
|
"No breakpoint number 999..*" \
|
|
|
|
"ignore non-existent break"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Verify that a missing ignore count is gracefully handled.
|
2004-07-13 13:01:04 +00:00
|
|
|
|
|
|
|
gdb_test "ignore $bp" \
|
|
|
|
"Second argument .specified ignore-count. is missing..*" \
|
|
|
|
"ignore break with missing ignore count"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Verify that a negative or zero ignore count is handled gracefully
|
|
|
|
# (they both are treated the same).
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "ignore $bp -1" \
|
|
|
|
"Will stop next time breakpoint \[0-9\]* is reached..*" \
|
|
|
|
"ignore break marker1 -1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "ignore $bp 0" \
|
|
|
|
"Will stop next time breakpoint \[0-9\]* is reached..*" \
|
|
|
|
"ignore break marker1 0"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "ignore $bp 1" \
|
|
|
|
"Will ignore next crossing of breakpoint \[0-9\]*.*" \
|
|
|
|
"ignore break marker1"
|
|
|
|
|
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*" \
|
|
|
|
"info ignored break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
gdb_continue_to_end "no stop at ignored break marker1"
|
|
|
|
rerun_to_main
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-11-09 01:23:30 +00:00
|
|
|
# See the comments in condbreak.exp for "run until breakpoint at marker1"
|
|
|
|
# for an explanation of the xfail below.
|
2004-07-13 13:01:04 +00:00
|
|
|
set test "continue to break marker1, 2nd time"
|
|
|
|
gdb_test_multiple "continue" "$test" {
|
|
|
|
-re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $" {
|
|
|
|
pass "continue to break marker1, 2nd time"
|
|
|
|
}
|
|
|
|
-re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $" {
|
|
|
|
xfail "continue to break marker1, 2nd time"
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Verify that we can specify both an ignore count and an auto-delete.
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
if ![runto_main] then {
|
|
|
|
fail "enable/disable break tests suppressed"
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set bp [break_at marker1 " line ($bp_location15|$bp_location16).*"]
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "ignore $bp 1" \
|
|
|
|
"Will ignore next crossing of breakpoint \[0-9\]*.*" \
|
|
|
|
"ignore break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "enable del $bp" "" "enable del break marker1"
|
|
|
|
|
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*" \
|
|
|
|
"info break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
|
|
|
|
rerun_to_main
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "continue" \
|
|
|
|
".*marker1 .*:($bp_location15|$bp_location16).*" \
|
|
|
|
"continue to ignored & auto-deleted break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Verify that a disabled breakpoint's ignore count isn't updated when
|
|
|
|
# the bp is encountered.
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
if ![runto_main] then {
|
|
|
|
fail "enable/disable break tests suppressed"
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
set bp [break_at marker1 " line ($bp_location15|$bp_location16)"]
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "ignore $bp 10" \
|
|
|
|
"Will ignore next 10 crossings of breakpoint \[0-9\]*.*" \
|
|
|
|
"ignore break marker1"
|
|
|
|
|
|
|
|
gdb_test "disable $bp" "" "disable break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
gdb_continue_to_end "no stop at ignored & disabled break marker1"
|
|
|
|
rerun_to_main
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "info break $bp" \
|
|
|
|
"\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*" \
|
|
|
|
"info ignored & disabled break marker1"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Verify that GDB correctly handles the "continue" command with an argument,
|
|
|
|
# which is an ignore count to set on the currently stopped-at breakpoint.
|
|
|
|
# (Also verify that GDB gracefully handles the case where the inferior
|
|
|
|
# isn't stopped at a breakpoint.)
|
|
|
|
#
|
|
|
|
if ![runto_main] then { fail "enable/disable break tests suppressed" }
|
|
|
|
|
2004-07-13 13:01:04 +00:00
|
|
|
gdb_test "break $bp_location1" \
|
|
|
|
"Breakpoint \[0-9\]*.*, line $bp_location1.*" \
|
|
|
|
"prepare to continue with ignore count"
|
|
|
|
|
|
|
|
gdb_test "continue 2" \
|
|
|
|
"Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*" \
|
|
|
|
"continue with ignore count"
|
|
|
|
|
|
|
|
gdb_test "next" ".*$bp_location11\[ \t\]*marker1.*" \
|
|
|
|
step after continue with ignore count"
|
|
|
|
|
|
|
|
set test "continue with ignore count, not stopped at bpt"
|
|
|
|
gdb_test_multiple "continue 2" "$test" {
|
|
|
|
-re "Not stopped at any breakpoint; argument ignored.*$gdb_prompt $" {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
-re "No breakpoint number -1.*$gdb_prompt $" {
|
|
|
|
kfail gdb/1689 "$test"
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
return 0
|