-# Copyright 1998, 1999, 2001, 2003, 2004, 2007, 2008, 2009, 2010
-# Free Software Foundation, Inc.
+# Copyright 1998-2019 Free Software Foundation, Inc.
# 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
# This file was written by Elena Zannoni. (ezannoni@cygnus.com)
-if $tracelevel then {
- strace $tracelevel
- }
-
-global usestubs
-
#
# test running programs
#
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile break.c break1.c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
- untested define.exp
- return -1
+if {[prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $srcfile2] {debug nowarnings}]} {
+ return -1
}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
- untested define.exp
- return -1
-}
-
-if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
- untested define.exp
- return -1
-}
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly"
+# Verify that the command parser properly handles command abbreviations.
+with_test_prefix "command abbreviations in define" {
+ set test "define user command: breakmain"
+ gdb_test_multiple "define breakmain" "$test" {
+ -re "Type commands for definition of \"breakmain\".\r\nEnd with a line saying just \"end\".\r\n>$" {
+ pass "$test"
+ set test "send body of breakmain"
+ gdb_test_multiple "break main\ncommand\necho\nend\nend" "$test" {
+ -re "$gdb_prompt $"\
+ {pass "$test"}
+ }
+ }
+ }
+
+ gdb_test "breakmain" ".*Breakpoint .*" "run user command"
+
+ # If GDB fails to interpret properly the abbrev "command", the last "end"
+ # will be missing. Issue it to avoid a desync that would break the other
+ # tests in this file.
+ gdb_test "end" \
+ "This command cannot be used at the top level.*" \
+ "additional end command"
+
+ gdb_test "info break \$bpnum" \
+ [multi_line \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*" \
+ "\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*" \
+ "\[\t \]+echo.*"] \
+ "info break shows echo command"
+}
+
+
# Verify that the command parser doesn't require a space after an 'while'
# command in a user defined function.
#
gdb_test "target testsuite" "one\r\nhello\r\ntwo" "target testsuite with hooks"
+# Save the GDB prompt so it can be restored to the original value later.
+set prior_prompt ""
+gdb_test_multiple "show prompt" "save gdb_prompt" {
+ -re "Gdb's prompt is \"($gdb_prompt) \"\.\[\r\n\]*$gdb_prompt $" {
+ set prior_prompt $expect_out(1,string)
+ pass "save gdb_prompt"
+ }
+}
+
# This is a quasi-define command: Verify that the user can redefine
# GDB's gdb_prompt.
#
}
}
-gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" {
- -re "$gdb_prompt $" {
+gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" {
+ -re "\r\n$gdb_prompt $" {
pass "reset gdb_prompt"
}
}
+gdb_test_multiple "define do-define" "" {
+ -re "Type commands for definition of \"do-define\".\r\nEnd with a line saying just \"end\".\r\n>$" {
+ gdb_test "define do-printit\necho here\\n\nend\nend" "" "define do-define"
+ }
+}
+gdb_test_no_output "do-define" "invoke do-define"
+gdb_test "do-printit" "here" "invoke do-printit"
+
gdb_exit
return 0