From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 7F1203959CA7; Thu, 2 Jun 2022 18:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F1203959CA7 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 0c8cd1de90b97f12b27b40c2922a03a68932eea1 X-Git-Newrev: bb785a92a88b538831d72e36f2d0fce76e0a32b1 Message-Id: <20220602184010.7F1203959CA7@sourceware.org> Date: Thu, 2 Jun 2022 18:40:10 +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: Thu, 02 Jun 2022 18:40:10 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dbb785a92a88b= 538831d72e36f2d0fce76e0a32b1 commit bb785a92a88b538831d72e36f2d0fce76e0a32b1 Author: Tom de Vries Date: Thu Jun 2 20:40:06 2022 +0200 [gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp =20 On openSUSE Tumbleweed with target board unix/-m32, I run into: ... PASS: gdb.mi/mi-var-block.exp: step at do_block_test 2 Expecting: ^(-var-update \*[^M ]+)?(\^done,changelist=3D\[{name=3D"foo",in_scope=3D"true",type_changed= =3D"false",has_more=3D"0"}, {name=3D"cb",in_scope=3D"true",type_changed=3D"false",has_more=3D"0"}\]= [^M ]+[(]gdb[)] ^M [ ]*) -var-update *^M ^done,changelist=3D[{name=3D"foo",in_scope=3D"true",type_changed=3D"fal= se",has_more=3D"0"}]^M (gdb) ^M FAIL: gdb.mi/mi-var-block.exp: update all vars: cb foo changed (unexpec= ted output) ... =20 The problem is that the test-case attempts to detect a change in the cb variable caused by this initialization: ... void do_block_tests () { int cb =3D 12; ... but that only works if the stack location happens to be unequal to 12 b= efore the initialization. =20 Fix this by first initializing to 0, and then changing the value to 12: ... - int cb =3D 12; + int cb =3D 0; + cb =3D 12; ... and detecting that change. =20 Tested on x86_64-linux. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29195 Diff: --- gdb/testsuite/gdb.mi/mi-var-block.exp | 5 +++++ gdb/testsuite/gdb.mi/var-cmd.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.mi/mi-var-block.exp b/gdb/testsuite/gdb.mi/m= i-var-block.exp index 2f8d39a6acd..a1ef2d1ad52 100644 --- a/gdb/testsuite/gdb.mi/mi-var-block.exp +++ b/gdb/testsuite/gdb.mi/mi-var-block.exp @@ -40,6 +40,11 @@ mi_gdb_load ${binfile} =20 mi_runto do_block_tests =20 +# step to "cb =3D 12;" +mi_step_to "do_block_tests" "" "var-cmd.c" \ + [gdb_get_line_number "cb =3D 12;"] \ + "step at do_block_test 0" + # Test: c_variable-3.2 # Desc: create cb and foo mi_create_varobj "cb" "cb" "create local variable cb" diff --git a/gdb/testsuite/gdb.mi/var-cmd.c b/gdb/testsuite/gdb.mi/var-cmd.c index fddb0d39a5e..f3312788a80 100644 --- a/gdb/testsuite/gdb.mi/var-cmd.c +++ b/gdb/testsuite/gdb.mi/var-cmd.c @@ -207,7 +207,8 @@ subroutine1 (int i, long *l) void do_block_tests () { - int cb =3D 12; + int cb =3D 0; + cb =3D 12; =20 { int foo;