From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 6095238582B1; Wed, 29 Jun 2022 09:57:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6095238582B1 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: fix gdb.base/break-idempotent.exp on ppc X-Act-Checkin: binutils-gdb X-Git-Author: Carl Love X-Git-Refname: refs/heads/master X-Git-Oldrev: 96016a2f00cf86c3e32487724eb747cc20098bc6 X-Git-Newrev: 13f72372413400410aaa94b7f0e2ff7de663fdcb Message-Id: <20220629095749.6095238582B1@sourceware.org> Date: Wed, 29 Jun 2022 09:57:49 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 09:57:49 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D13f723724134= 00410aaa94b7f0e2ff7de663fdcb commit 13f72372413400410aaa94b7f0e2ff7de663fdcb Author: Carl Love Date: Wed Jun 22 16:14:20 2022 +0100 gdb/testsuite: fix gdb.base/break-idempotent.exp on ppc =20 When running the gdb.base/break-idempotent.exp test on ppc, I was seeing some test failures (or rather errors), that looked like this: =20 (gdb) watch local Hardware watchpoint 2: local =20 has_hw_wp_support: Hardware watchpoint detected ERROR: no fileid for gcc2-power8 ERROR: Couldn't send delete breakpoints to GDB. ERROR OCCURED: can't read "gdb_spawn_id": no such variable while executing "expect { -i 1000 -timeout 100 -re ".*A problem internal to GDB has been detected" { fail "$message (GDB internal error)" gdb_internal_erro..." ("uplevel" body line 1) invoked from within =20 What happens is that in break-idempotent.exp we basically do this: =20 if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opt= s]} { continue } =20 # .... =20 if {![skip_hw_watchpoint_tests]} { test_break $always_inserted "watch" } =20 The problem with this is that skip_hw_watchpoint_tests, includes this: =20 if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] || [istarget "ia64-*-*"] || [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] || ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support]) || [istarget "s390*-*-*"] } { return 0 } =20 For powerpc only we call has_hw_wp_support. This is a caching proc that runs a test within GDB to detect if we have hardware watchpoint support or not. =20 Unfortunately, to run this test we restart GDB, and when the test has completed, we exit GDB. This means that in break-idempotent.exp, when we call skip_hw_watchpoint_tests for the first time on powerpc, GDB will unexpectedly be exited. When we later call delete_breakpoints we see the errors I reported above. =20 The fix is to call skip_hw_watchpoint_tests early, before we start GDB as part of the break-idempotent.exp script, and store the result in a variable, we can then check this variable in the script as needed. =20 After this change break-idempotent.exp runs fine on powerpc. =20 Co-authored-by: Andrew Burgess Diff: --- gdb/testsuite/gdb.base/break-idempotent.exp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp b/gdb/testsuite/gd= b.base/break-idempotent.exp index 29002f103a8..837ac000b57 100644 --- a/gdb/testsuite/gdb.base/break-idempotent.exp +++ b/gdb/testsuite/gdb.base/break-idempotent.exp @@ -36,6 +36,12 @@ =20 standard_testfile =20 +# The skip_hw_watchpoint_tests starts GDB on a small test program to +# check if HW watchpoints are supported. We do not want to restart +# GDB after this test script has itself started GDB, so call +# skip_hw_watchpoint_tests first and cache the result. +set skip_hw_watchpoint_tests_p [skip_hw_watchpoint_tests] + # Force a breakpoint re-set in GDB. Currently this is done by # reloading symbols with the "file" command. =20 @@ -174,7 +180,7 @@ foreach_with_prefix pie { "nopie" "pie" } { test_break $always_inserted "hbreak" } =20 - if {![skip_hw_watchpoint_tests]} { + if {!$skip_hw_watchpoint_tests_p} { test_break $always_inserted "watch" }