#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
set prms_id 0
set bug_id 0
-set binfile "run"
-
-if ![file exists $objdir/$subdir/$binfile] then {
- perror "$objdir/$subdir/$binfile does not exist."
- return 0
+set testfile "run"
+set srcfile ${srcdir}/$subdir/${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [compile "${srcfile} -g -o ${binfile}"] != "" } {
+ perror "Couldn't compile ${srcfile}"
+ return -1
}
gdb_exit
gdb_start
delete_breakpoints
gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $objdir/$subdir/$binfile
+gdb_load ${binfile}
proc gdbvar_simple_if_test {} {
global prompt
proc progvar_simple_if_test {} {
global prompt
+ global noargs
+
+ if $noargs {
+ verbose "Skipping progvar_simple_if_test because of noargs."
+ return
+ }
gdb_test "set args 5" "" "set args in progvar_simple_if_test"
if { ![runto factorial] } then { return }
proc progvar_simple_while_test {} {
global prompt
+ global noargs
+
+ if $noargs {
+ verbose "Skipping progvar_simple_while_test because of noargs."
+ return
+ }
gdb_test "set args 5" "" "set args in progvar_simple_while_test"
if { ![runto factorial] } then { return }
proc progvar_complex_if_while_test {} {
global prompt
+ global noargs
+
+ if $noargs {
+ verbose "Skipping progvar_simple_if_while_test because of noargs."
+ return
+ }
gdb_test "set args 4" "" "set args in progvar_complex_if_while_test"
if { ![runto factorial] } then { return }
}
proc if_while_breakpoint_command_test {} {
+ global noargs
+
+ if $noargs {
+ verbose "Skipping if_while_breakpoint_command_test because of noargs."
+ return
+ }
+
gdb_test "set args 5" "" "set args in if_while_breakpoint_command_test"
if { ![runto factorial] } then { return }
delete_breakpoints
# Test that we can run the inferior from breakpoint commands.
proc infrun_breakpoint_command_test {} {
+ global noargs
+
+ if $noargs {
+ verbose "Skipping infrun_breakpoint_command_test because of noargs."
+ return
+ }
+
gdb_test "set args 6" "" "set args in progvar_simple_while_test"
if { ![runto factorial] } then { return }
delete_breakpoints
"continue in infrun_breakpoint_command_test"
}
+proc breakpoint_command_test {} {
+ global noargs
+
+ if $noargs {
+ verbose "Skipping breakpoint_command_test because of noargs."
+ return
+ }
+
+ gdb_test "set args 6" "" "set args in progvar_simple_while_test"
+ if { ![runto factorial] } then { return }
+ delete_breakpoints
+ gdb_test "break factorial" "Breakpoint.*at.*"
+ gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \
+ "End with.*" "commands in breakpoint_command_test"
+ gdb_test "continue" "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \
+ "continue in breakpoint_command_test"
+ gdb_test "print value" " = 5" "print value in breakpoint_command_test"
+}
+
# Test a simple user defined command (with arguments)
proc user_defined_command_test {} {
global prompt
progvar_complex_if_while_test
if_while_breakpoint_command_test
infrun_breakpoint_command_test
+breakpoint_command_test
user_defined_command_test