[gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (3)

There's a pattern:
...
gdb_test <command> <pattern> <command>
...
that can be written shorter as:
...
gdb_test <command> <pattern>
...

Detect this pattern in proc gdb_test:
...
     global gdb_prompt
     upvar timeout timeout

     if [llength $args]>2 then {
        set message [lindex $args 2]
+       if { $message == [lindex $args 0] && [llength $args] == 3 } {
+           error "HERE"
+       }
     } else {
         set message [lindex $args 0]
     }
...
and fix all occurrences in the testsuite/gdb.cp subdir.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-11-02  Tom de Vries  <tdevries@suse.de>

	* gdb.cp/anon-union.exp: Drop superfluous 3rd argument to gdb_test.
	* gdb.cp/cpexprs.exp: Same.
	* gdb.cp/except-multi-location.exp: Same.
	* gdb.cp/exceptprint.exp: Same.
	* gdb.cp/gdb2384.exp: Same.
	* gdb.cp/inherit.exp: Same.
	* gdb.cp/m-static.exp: Same.
	* gdb.cp/meth-typedefs.exp: Same.
	* gdb.cp/misc.exp: Same.
	* gdb.cp/namespace.exp: Same.
	* gdb.cp/non-trivial-retval.exp: Same.
	* gdb.cp/overload.exp: Same.
	* gdb.cp/pr17132.exp: Same.
	* gdb.cp/re-set-overloaded.exp: Same.
	* gdb.cp/rvalue-ref-types.exp: Same.
	* gdb.cp/templates.exp: Same.

Change-Id: I0254d0cea71e7376aedb078166188a8010eeaebe
This commit is contained in:
Tom de Vries
2019-11-02 06:55:10 +01:00
parent a1dc3a23d0
commit e96ec2bab7
17 changed files with 67 additions and 69 deletions

@ -1,3 +1,22 @@
2019-11-02 Tom de Vries <tdevries@suse.de>
* gdb.cp/anon-union.exp: Drop superfluous 3rd argument to gdb_test.
* gdb.cp/cpexprs.exp: Same.
* gdb.cp/except-multi-location.exp: Same.
* gdb.cp/exceptprint.exp: Same.
* gdb.cp/gdb2384.exp: Same.
* gdb.cp/inherit.exp: Same.
* gdb.cp/m-static.exp: Same.
* gdb.cp/meth-typedefs.exp: Same.
* gdb.cp/misc.exp: Same.
* gdb.cp/namespace.exp: Same.
* gdb.cp/non-trivial-retval.exp: Same.
* gdb.cp/overload.exp: Same.
* gdb.cp/pr17132.exp: Same.
* gdb.cp/re-set-overloaded.exp: Same.
* gdb.cp/rvalue-ref-types.exp: Same.
* gdb.cp/templates.exp: Same.
2019-11-01 Luis Machado <luis.machado@linaro.org> 2019-11-01 Luis Machado <luis.machado@linaro.org>
PR gdb/25124 PR gdb/25124

@ -134,7 +134,7 @@ gdb_test "print foo" \
"print foo 9" "print foo 9"
# Step over next four assignments # Step over next four assignments
gdb_test "next 4" "53\[ \t\]*w = 45;" "next 4" gdb_test "next 4" "53\[ \t\]*w = 45;"
# Tests for anon unions that are not members of a class or struct # Tests for anon unions that are not members of a class or struct

@ -705,12 +705,12 @@ gdb_test "set listsize 1"
# "print METHOD" # "print METHOD"
foreach name [get_functions print] { foreach name [get_functions print] {
gdb_test "print $name" [get $name print] "print $name" gdb_test "print $name" [get $name print]
} }
# "list METHOD" # "list METHOD"
foreach name [get_functions list] { foreach name [get_functions list] {
gdb_test "list $name" [get $name list] "list $name" gdb_test "list $name" [get $name list]
} }
# Running to breakpoint -- use any function we can "list" # Running to breakpoint -- use any function we can "list"

@ -64,12 +64,9 @@ proc test_multi_libstdcpp {static_bin static_lib} {
return 0 return 0
} }
gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \ gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
"catch catch" gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)"
gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \ gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)"
"catch throw"
gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" \
"catch rethrow"
set ws "\[ \t\]*" set ws "\[ \t\]*"
gdb_test "info breakpoints" \ gdb_test "info breakpoints" \

@ -60,12 +60,9 @@ proc do_exceptprint_tests {prefix output} {
} }
} }
gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \ gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
"catch catch" gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)"
gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \ gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)"
"catch throw"
gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" \
"catch rethrow"
do_exceptprint_tests string "$hex \"hi bob\"" do_exceptprint_tests string "$hex \"hi bob\""
do_exceptprint_tests int 23 do_exceptprint_tests int 23

@ -53,8 +53,7 @@ gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
gdb_continue_to_breakpoint "set breakpoint here" gdb_continue_to_breakpoint "set breakpoint here"
gdb_test "print d1.meth ()" \ gdb_test "print d1.meth ()" \
".*42.*" \ ".*42.*"
"print d1.meth ()"
# Now try again. gdb's without the fix will hopefully segv here # Now try again. gdb's without the fix will hopefully segv here

@ -479,9 +479,9 @@ proc test_print_svi_members { } {
gdb_test "print g_vC.vC::vx" "$vhn = 10" gdb_test "print g_vC.vC::vx" "$vhn = 10"
# Print members of g_vC using compact form. # Print members of g_vC using compact form.
gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va" gdb_test "print g_vC.va" "$vhn = 7"
gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc" gdb_test "print g_vC.vc" "$vhn = 9"
gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx" gdb_test "print g_vC.vx" "$vhn = 10"
} }
# Single virtual inheritance, print complete classes. # Single virtual inheritance, print complete classes.

@ -179,7 +179,7 @@ gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo
# Also make sure static const members can be found via "info var". # Also make sure static const members can be found via "info var".
if { $non_dwarf } { setup_xfail *-*-* } if { $non_dwarf } { setup_xfail *-*-* }
gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" "info variable everywhere" gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;"
# Perhaps at some point test4 should also include a test for a static # Perhaps at some point test4 should also include a test for a static
# const int that was initialized in the header file. But I'm not sure # const int that was initialized in the header file. But I'm not sure

@ -181,8 +181,7 @@ foreach f [list "$func" "'$func'"] {
"file: \".*$srcfile\", line number: $line2, symbol: \"B::$func_re\"" \ "file: \".*$srcfile\", line number: $line2, symbol: \"B::$func_re\"" \
"$line2${any}B::test${any}" \ "$line2${any}B::test${any}" \
"file: \".*$srcfile\", line number: $line3, symbol: \"$func_re\"" \ "file: \".*$srcfile\", line number: $line3, symbol: \"$func_re\"" \
"$line3${any}// test${any}"] \ "$line3${any}// test${any}"]
"list $f"
delete_breakpoints delete_breakpoints
gdb_test "break $f" "\\(3 locations\\)" gdb_test "break $f" "\\(3 locations\\)"

@ -93,8 +93,8 @@ test_expr "set variable v_bool_array\[1\] = true" \
"set a bool array elem" "set a bool array elem"
# bool constants # bool constants
gdb_test "print true" "\\$\[0-9\]* = true" "print true" gdb_test "print true" "\\$\[0-9\]* = true"
gdb_test "print false" "\\$\[0-9\]* = false" "print false" gdb_test "print false" "\\$\[0-9\]* = false"
# arithmetic conversions # arithmetic conversions
gdb_test "print 1 + true" "\\$\[0-9\]* = 2" "1 + true" gdb_test "print 1 + true" "\\$\[0-9\]* = 2" "1 + true"

@ -71,12 +71,10 @@ gdb_test "up" ".*main.*" "up from marker1"
# shouldn't work with quotes, I'm only including one version. # shouldn't work with quotes, I'm only including one version.
gdb_test "print 'AAA::c'" \ gdb_test "print 'AAA::c'" \
"\\$\[0-9\]* = 0 '\\\\(0|000)'" \ "\\$\[0-9\]* = 0 '\\\\(0|000)'"
"print 'AAA::c'"
gdb_test "print AAA::c" \ gdb_test "print AAA::c" \
"\\$\[0-9\]* = 0 '\\\\(0|000)'" \ "\\$\[0-9\]* = 0 '\\\\(0|000)'"
"print AAA::c"
# An object declared using "using". # An object declared using "using".
@ -106,13 +104,11 @@ gdb_test_multiple "info func xyzq" "info func xyzq" {
# Call a function in a namespace # Call a function in a namespace
gdb_test "print 'AAA::xyzq'('x')" \ gdb_test "print 'AAA::xyzq'('x')" \
"\\$\[0-9\]* = 97 'a'" \ "\\$\[0-9\]* = 97 'a'"
"print 'AAA::xyzq'('x')"
gdb_test "print AAA::xyzq('x')" \ gdb_test "print AAA::xyzq('x')" \
"\\$\[0-9\]* = 97 'a'" \ "\\$\[0-9\]* = 97 'a'"
"print AAA::xyzq('x')"
# Break on a function in a namespace # Break on a function in a namespace
gdb_test "break AAA::xyzq" \ gdb_test "break AAA::xyzq" \
@ -126,12 +122,10 @@ gdb_test "break -qualified ::ensureOtherRefs" \
# Call a function in a nested namespace # Call a function in a nested namespace
gdb_test "print 'BBB::CCC::xyzq'('x')" \ gdb_test "print 'BBB::CCC::xyzq'('x')" \
"\\$\[0-9\]* = 122 'z'" \ "\\$\[0-9\]* = 122 'z'"
"print 'BBB::CCC::xyzq'('x')"
gdb_test "print BBB::CCC::xyzq('x')" \ gdb_test "print BBB::CCC::xyzq('x')" \
"\\$\[0-9\]* = 122 'z'" \ "\\$\[0-9\]* = 122 'z'"
"print BBB::CCC::xyzq('x')"
# Break on a function in a nested namespace # Break on a function in a nested namespace
@ -146,12 +140,10 @@ gdb_test "break ::BBB::CCC::xyzq" \
# Print address of a function in a class in a namespace # Print address of a function in a class in a namespace
gdb_test "print 'BBB::Class::xyzq'" \ gdb_test "print 'BBB::Class::xyzq'" \
"\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>" \ "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>"
"print 'BBB::Class::xyzq'"
gdb_test "print BBB::Class::xyzq" \ gdb_test "print BBB::Class::xyzq" \
"\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>" \ "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>"
"print BBB::Class::xyzq"
# Break on a function in a class in a namespace # Break on a function in a class in a namespace

@ -30,8 +30,8 @@ if {![runto_main]} {
gdb_breakpoint [gdb_get_line_number "Break here"] gdb_breakpoint [gdb_get_line_number "Break here"]
gdb_continue_to_breakpoint "Break here" gdb_continue_to_breakpoint "Break here"
gdb_test "p f1 (i1, i2)" ".* = {a = 123}" "p f1 (i1, i2)" gdb_test "p f1 (i1, i2)" ".* = {a = 123}"
gdb_test "p f2 (i1, i2)" ".* = {b = 123}" "p f2 (i1, i2)" gdb_test "p f2 (i1, i2)" ".* = {b = 123}"
gdb_test "p f22 (i1, i2)" ".* = {b1 = 123}" "p f22 (i1, i2)" gdb_test "p f22 (i1, i2)" ".* = {b1 = 123}"
gdb_test "p f3 (i1, i2)" ".* = {.* c = 123}" "p f3 (i1, i2)" gdb_test "p f3 (i1, i2)" ".* = {.* c = 123}"
gdb_test "p f4 (i1, i2)" ".* = {.* e = 123}" "p f4 (i1, i2)" gdb_test "p f4 (i1, i2)" ".* = {.* e = 123}"

@ -372,21 +372,17 @@ gdb_test "print intToChar(1)" "\\$\[0-9\]+ = 297"
# Test expression evaluation with overloaded methods # Test expression evaluation with overloaded methods
gdb_test "print foo::overload1arg" \ gdb_test "print foo::overload1arg" \
"non-unique member `overload1arg' requires type instantiation" \ "non-unique member `overload1arg' requires type instantiation"
"print foo::overload1arg"
gdb_test "print foo::overload1arg(char***)" \ gdb_test "print foo::overload1arg(char***)" \
"no member function matches that type instantiation" \ "no member function matches that type instantiation"
"print foo::overload1arg(char***)"
gdb_test "print foo::overload1arg(void)" \ gdb_test "print foo::overload1arg(void)" \
"\\$$decimal = {int \\(foo \\*( const|)\\)} $hex <foo::overload1arg\\(\\)>" \ "\\$$decimal = {int \\(foo \\*( const|)\\)} $hex <foo::overload1arg\\(\\)>"
"print foo::overload1arg(void)"
foreach t [list char "signed char" "unsigned char" "short" \ foreach t [list char "signed char" "unsigned char" "short" \
"unsigned short" int "unsigned int" long "unsigned long" \ "unsigned short" int "unsigned int" long "unsigned long" \
float double] { float double] {
gdb_test "print foo::overload1arg($t)" \ gdb_test "print foo::overload1arg($t)" \
"\\$$decimal = {int \\(foo \\*( const|), $t\\)} $hex <foo::overload1arg\\($t\\)>" \ "\\$$decimal = {int \\(foo \\*( const|), $t\\)} $hex <foo::overload1arg\\($t\\)>"
"print foo::overload1arg($t)"
} }

@ -30,11 +30,11 @@ if {![runto_main]} {
gdb_breakpoint [gdb_get_line_number "Break here"] gdb_breakpoint [gdb_get_line_number "Break here"]
gdb_continue_to_breakpoint "Break here" gdb_continue_to_breakpoint "Break here"
gdb_test "ptype a_ptr->func ()" ".* = int" "ptype a_ptr->func ()" gdb_test "ptype a_ptr->func ()" ".* = int"
gdb_test "ptype a->func ()" ".* = int" "ptype a->func ()" gdb_test "ptype a->func ()" ".* = int"
gdb_test "p sizeof (a_ptr->func()) == sizeof (int)" ".* = true" \ gdb_test "p sizeof (a_ptr->func()) == sizeof (int)" ".* = true" \
"p sizeof (a_ptr->func())" "p sizeof (a_ptr->func())"
gdb_test "p sizeof (a->func()) == sizeof (int)" ".* = true" \ gdb_test "p sizeof (a->func()) == sizeof (int)" ".* = true" \
"p sizeof (a->func())" "p sizeof (a->func())"
gdb_test "p 1 && a->func()" ".* = true" "p 1 && a->func()" gdb_test "p 1 && a->func()" ".* = true"
gdb_test "p 0 || a->func()" ".* = true" "p 0 || a->func()" gdb_test "p 0 || a->func()" ".* = true"

@ -36,7 +36,7 @@ clean_restart $testfile
gdb_load_shlib ${sofile} gdb_load_shlib ${sofile}
gdb_test_no_output "set breakpoint pending yes" gdb_test_no_output "set breakpoint pending yes"
gdb_test "break C::C" {Breakpoint [0-9]+ \(C::C\) pending\.} "break C::C" gdb_test "break C::C" {Breakpoint [0-9]+ \(C::C\) pending\.}
gdb_test_no_output {set variable $brk = $bpnum} gdb_test_no_output {set variable $brk = $bpnum}
# runto or runto_main would call delete_breakpoints. # runto or runto_main would call delete_breakpoints.

@ -42,7 +42,7 @@ gdb_test "up" ".*main.*" "up from marker1 1"
gdb_test "print rrt" " = \\(short( int)? &&\\) @$hex: -1" "print value of rrt" gdb_test "print rrt" " = \\(short( int)? &&\\) @$hex: -1" "print value of rrt"
gdb_test "ptype rrt" "type = short( int)? &&" "ptype rrt" gdb_test "ptype rrt" "type = short( int)? &&"
gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt" gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt"
@ -52,11 +52,11 @@ gdb_test "print *rrpt" ".$decimal = -1" "print value of *rrpt"
gdb_test "x /hd rrpt" "$hex:\[ \t\]*-1" "examine value at rrpt" gdb_test "x /hd rrpt" "$hex:\[ \t\]*-1" "examine value at rrpt"
gdb_test "ptype rrpt" "type = short( int)? \\*&&" "ptype rrpt" gdb_test "ptype rrpt" "type = short( int)? \\*&&"
gdb_test "print rrat\[0\]" ".$decimal = 0" "print value of rrat\[0\]" gdb_test "print rrat\[0\]" ".$decimal = 0" "print value of rrat\[0\]"
gdb_test "ptype rrat" "type = short( int)? \\\(&&\\\)\\\[4\\\]" "ptype rrat" gdb_test "ptype rrat" "type = short( int)? \\\(&&\\\)\\\[4\\\]"
gdb_test "print rrat\[1\]" ".$decimal = 1" "print value of rrat\[1\]" gdb_test "print rrat\[1\]" ".$decimal = 1" "print value of rrat\[1\]"
gdb_test "print rrat\[2\]" ".$decimal = 2" "print value of rrat\[2\]" gdb_test "print rrat\[2\]" ".$decimal = 2" "print value of rrat\[2\]"
@ -74,17 +74,17 @@ gdb_test "ptype rrC" "type = char &&"
gdb_test "ptype rrUC" "type = unsigned char &&" gdb_test "ptype rrUC" "type = unsigned char &&"
gdb_test "ptype rrS" "type = short( int)? &&" "ptype rrS" gdb_test "ptype rrS" "type = short( int)? &&"
gdb_test "ptype rrUS" "type = unsigned short( int)? &&" "ptype rrUS" gdb_test "ptype rrUS" "type = unsigned short( int)? &&"
gdb_test "ptype rrI" "type = int &&" gdb_test "ptype rrI" "type = int &&"
gdb_test "ptype rrUI" "type = unsigned int &&" gdb_test "ptype rrUI" "type = unsigned int &&"
gdb_test "ptype rrL" "type = long( int)? &&" "ptype rrL" gdb_test "ptype rrL" "type = long( int)? &&"
gdb_test "ptype rrUL" "type = unsigned long( int)? &&" "ptype rrUL" gdb_test "ptype rrUL" "type = unsigned long( int)? &&"
gdb_test "ptype rrF" "type = float &&" gdb_test "ptype rrF" "type = float &&"

@ -577,8 +577,7 @@ gdb_test_multiple "ptype/r Garply<Garply<char> >" "ptype Garply<Garply<char> >"
# print out a function from a nested template name # print out a function from a nested template name
gdb_test "print Garply<Garply<char> >::garply" \ gdb_test "print Garply<Garply<char> >::garply" \
"\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>" \ "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>"
"print Garply<Garply<char> >::garply"
# djb - 06-03-2000 # djb - 06-03-2000
# Now should work fine # Now should work fine