From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id E3B0738400A7; Mon, 28 Nov 2022 14:41:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3B0738400A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669646469; bh=qhKXu0c0iqr+41kQMvjjRdKphGI7VQjayMSQTSH+xQ8=; h=From:To:Subject:Date:From; b=s2p8N/Yuej5i2ezvPcV0MIWGOEeOVNHlOxPhWzasTK8eby/uOjMxzz8DGZy+to9lg VP/YeX5s3uY0S0AkfNQtWbr2sd49Us2auWp+ld4TNYI9f5JpkZzhSwS6rL+bcRRuur NYTAbsi7rtTm7jTy9DS6jhKK9Ucw8tJSdwI7878w= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: fail if gdb_start_cmd fails X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 912b12ad84adf32af5827511af5afecedb108c63 X-Git-Newrev: 4a6bdfb9baa27e29151c7e97ae2abbe902f53638 Message-Id: <20221128144109.E3B0738400A7@sourceware.org> Date: Mon, 28 Nov 2022 14:41:09 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4a6bdfb9baa2= 7e29151c7e97ae2abbe902f53638 commit 4a6bdfb9baa27e29151c7e97ae2abbe902f53638 Author: Simon Marchi Date: Fri Nov 18 11:06:47 2022 -0500 gdb/testsuite: fail if gdb_start_cmd fails =20 I broke gdb.ada/start.exp, and did not notice it, because it outputs an UNTESTED if gdb_start_cmd fails. I don't really see when start would fail and it's not a problem that should be looked at. Change all spots that call untested after a gdb_start_cmd failure, use fail instead. =20 Doing so caused some failures with the native-gdbserver board. Some tests that use "start" were relying on the fact that start would fail with that board to just return with "untested". Change them to add an early return if use_gdb_stub returns true. =20 Some gdb.pascal tests also failed with native-gdbserver, because they did use gdb_start_cmd to start the inferior, for no good reason. Convert them to use runto_main instead, which does the right thing if the target is a stub. =20 A further refactoring could be to make gdb_start_cmd match the expected breakpoint hit and the prompt, which it doesn't do currently (it leaves that to the callers, but not all of them do). =20 Change-Id: I097370851213e798ff29fb6cf8ba25ef7d2be007 Reviewed-By: Bruno Larsen Approved-By: Andrew Burgess Diff: --- gdb/testsuite/gdb.ada/exec_changed.exp | 2 +- gdb/testsuite/gdb.ada/start.exp | 2 +- gdb/testsuite/gdb.base/start-cpp.exp | 7 ++++++- gdb/testsuite/gdb.base/start.exp | 6 +++++- gdb/testsuite/gdb.base/watchpoint-hw.exp | 6 +++++- gdb/testsuite/gdb.dwarf2/main-subprogram.exp | 7 ++++++- gdb/testsuite/gdb.pascal/floats.exp | 12 ++++-------- gdb/testsuite/gdb.pascal/gdb11492.exp | 12 +++++------- gdb/testsuite/gdb.pascal/hello.exp | 18 +++++------------- gdb/testsuite/gdb.pascal/integers.exp | 13 +++++-------- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/gdb/testsuite/gdb.ada/exec_changed.exp b/gdb/testsuite/gdb.ada= /exec_changed.exp index 52868f61c89..e09f59e5269 100644 --- a/gdb/testsuite/gdb.ada/exec_changed.exp +++ b/gdb/testsuite/gdb.ada/exec_changed.exp @@ -54,7 +54,7 @@ gdb_load ${common_binfile} =20 # Start the program, we should land in the program main procedure if { [gdb_start_cmd] < 0 } { - untested start + fail start return -1 } =20 diff --git a/gdb/testsuite/gdb.ada/start.exp b/gdb/testsuite/gdb.ada/start.= exp index de080711f7b..63dcc619f1f 100644 --- a/gdb/testsuite/gdb.ada/start.exp +++ b/gdb/testsuite/gdb.ada/start.exp @@ -34,7 +34,7 @@ clean_restart ${testfile} =20 # Verify that "start" lands inside the right procedure. if { [gdb_start_cmd] < 0 } { - untested "start failed to land inside the right procedure" + fail "start failed to land inside the right procedure" return -1 } =20 diff --git a/gdb/testsuite/gdb.base/start-cpp.exp b/gdb/testsuite/gdb.base/= start-cpp.exp index 9fabab4fe64..63b6ec006ca 100644 --- a/gdb/testsuite/gdb.base/start-cpp.exp +++ b/gdb/testsuite/gdb.base/start-cpp.exp @@ -13,6 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . =20 +if { [use_gdb_stub] } { + unsupported "test requires running" + return +} + standard_testfile .cc =20 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { @@ -28,7 +33,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $s= rcfile debug]} { =20 # For C++ programs, "start" should stop in main(). if { [gdb_start_cmd] < 0 } { - untested start + fail start return -1 } =20 diff --git a/gdb/testsuite/gdb.base/start.exp b/gdb/testsuite/gdb.base/star= t.exp index 9de3db31469..a0c8c8c41c1 100644 --- a/gdb/testsuite/gdb.base/start.exp +++ b/gdb/testsuite/gdb.base/start.exp @@ -13,6 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . =20 +if { [use_gdb_stub] } { + unsupported "test requires running" + return +} =20 standard_testfile =20 @@ -25,7 +29,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $s= rcfile debug]} { =20 # For C programs, "start" should stop in main(). if { [gdb_start_cmd] < 0 } { - untested start + fail start return -1 } =20 diff --git a/gdb/testsuite/gdb.base/watchpoint-hw.exp b/gdb/testsuite/gdb.b= ase/watchpoint-hw.exp index 23de0c3a91e..d0fd1621efe 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw.exp +++ b/gdb/testsuite/gdb.base/watchpoint-hw.exp @@ -13,6 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . =20 +if { [use_gdb_stub] } { + unsupported "test requires running" + return +} =20 if {[skip_hw_watchpoint_tests]} { return 0 @@ -33,7 +37,7 @@ gdb_test "watch watchee" "atchpoint 1: watchee" # `runto_main' or `runto main' would delete the watchpoint created above. =20 if { [gdb_start_cmd] < 0 } { - untested start + fail start return -1 } gdb_test "" "main .* at .*" "start" diff --git a/gdb/testsuite/gdb.dwarf2/main-subprogram.exp b/gdb/testsuite/g= db.dwarf2/main-subprogram.exp index df302ff9428..14adf66fba9 100644 --- a/gdb/testsuite/gdb.dwarf2/main-subprogram.exp +++ b/gdb/testsuite/gdb.dwarf2/main-subprogram.exp @@ -19,6 +19,11 @@ if {![dwarf2_support]} { return 0 } =20 +if { [use_gdb_stub] } { + unsupported "test requires running" + return +} + standard_testfile .c -dw.S =20 # Make some DWARF for the test. @@ -62,7 +67,7 @@ set have_index [exec_has_index_section $binfile] # that this was the real "main". =20 if {[gdb_start_cmd] < 0} { - untested "could not start ${testfile}" + fail "could not start ${testfile}" return -1 } =20 diff --git a/gdb/testsuite/gdb.pascal/floats.exp b/gdb/testsuite/gdb.pascal= /floats.exp index 32a8ea4352d..1804597e902 100644 --- a/gdb/testsuite/gdb.pascal/floats.exp +++ b/gdb/testsuite/gdb.pascal/floats.exp @@ -24,6 +24,10 @@ if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}"= "${binfile}" executable =20 clean_restart ${testfile} =20 +if { ![runto_main] } { + return +} + set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] =20 @@ -34,14 +38,6 @@ if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { pass "setting breakpoint 2" } =20 -# Verify that "start" lands inside the right procedure. -if { [gdb_start_cmd] < 0 } { - untested start - return -1 -} - -gdb_test "" ".* at .*${srcfile}.*" "start" - gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoi= nt" gdb_test "print r" ".* =3D 0" "print r before assigned to 1.25" =20 diff --git a/gdb/testsuite/gdb.pascal/gdb11492.exp b/gdb/testsuite/gdb.pasc= al/gdb11492.exp index 66c2de1c4a2..84dcca75ae2 100644 --- a/gdb/testsuite/gdb.pascal/gdb11492.exp +++ b/gdb/testsuite/gdb.pascal/gdb11492.exp @@ -23,19 +23,17 @@ if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}= " "${binfile}" executable } =20 clean_restart ${testfile} + +if { ![runto_main] } { + return +} + set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] =20 if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { pass "setting breakpoint 1" } =20 -# Verify that "start" lands inside the right procedure. -if { [gdb_start_cmd] < 0 } { - untested start - return -1 -} - -gdb_test "" ".* at .*${srcfile}.*" "start" gdb_test "continue" "" =20 gdb_test "print integer_array" { =3D \{50, 51, 52, 53, 54, 55, 56, 57\}} diff --git a/gdb/testsuite/gdb.pascal/hello.exp b/gdb/testsuite/gdb.pascal/= hello.exp index f7ae8ed89d0..e744045ac4f 100644 --- a/gdb/testsuite/gdb.pascal/hello.exp +++ b/gdb/testsuite/gdb.pascal/hello.exp @@ -22,6 +22,11 @@ if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}"= "${binfile}" executable } =20 clean_restart ${testfile} + +if { ![runto_main] } { + return +} + set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] =20 @@ -32,19 +37,6 @@ if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { pass "setting breakpoint 2" } =20 -# Verify that "start" lands inside the right procedure. -if { [gdb_start_cmd] < 0 } { - untested start - return -1 -} - -# This test fails for gpc -# because debug information for 'main' -# is in some -gdb_test "" \ - ".* at .*hello.pas.*" \ - "start" - gdb_test "cont" \ "Breakpoint .*:${bp_location1}.*" \ "Going to first breakpoint" diff --git a/gdb/testsuite/gdb.pascal/integers.exp b/gdb/testsuite/gdb.pasc= al/integers.exp index e11335a5fae..8a2f517c673 100644 --- a/gdb/testsuite/gdb.pascal/integers.exp +++ b/gdb/testsuite/gdb.pascal/integers.exp @@ -22,6 +22,11 @@ if {[gdb_compile_pascal "${srcdir}/${subdir}/${srcfile}"= "${binfile}" executable } =20 clean_restart ${testfile} + +if { ![runto_main] } { + return +} + set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] =20 @@ -32,14 +37,6 @@ if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { pass "setting breakpoint 2" } =20 -# Verify that "start" lands inside the right procedure. -if { [gdb_start_cmd] < 0 } { - untested start - return -1 -} - -gdb_test "" ".* at .*${srcfile}.*" "start" - gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoi= nt" =20 gdb_test "print i" ".* =3D 0" "print i before assigned to 1"