From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 2CF873857BB1 for ; Tue, 31 May 2022 14:03:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2CF873857BB1 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 358CA21BE3 for ; Tue, 31 May 2022 14:03:03 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2265B132F9 for ; Tue, 31 May 2022 14:03:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id q302BxcglmLGIQAAMHmgww (envelope-from ) for ; Tue, 31 May 2022 14:03:03 +0000 Date: Tue, 31 May 2022 16:03:01 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp Message-ID: <20220531140300.GA2627@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2022 14:03:07 -0000 Hi, 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=\[{name="foo",in_scope="true",type_changed="false",has_more="0"}, {name="cb",in_scope="true",type_changed="false",has_more="0"}\][^M ]+[(]gdb[)] ^M [ ]*) -var-update *^M ^done,changelist=[{name="foo",in_scope="true",type_changed="false",has_more="0"}]^M (gdb) ^M FAIL: gdb.mi/mi-var-block.exp: update all vars: cb foo changed (unexpected output) ... 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 = 12; ... but that only works if the stack location happens to be unequal to 12 before the initialization. Fix this by first initializing to 0, and then changing the value to 12: ... - int cb = 12; + int cb = 0; + cb = 12; ... and detecting that change. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29195 Any comments? Thanks, - Tom [gdb/testsuite] Detect change instead of init in gdb.mi/mi-var-block.exp --- 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/mi-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} mi_runto do_block_tests +# step to "cb = 12;" +mi_step_to "do_block_tests" "" "var-cmd.c" \ + [gdb_get_line_number "cb = 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 = 12; + int cb = 0; + cb = 12; { int foo;