From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (vps-42846194.vps.ovh.net [IPv6:2001:41d0:801:2000::2400]) by sourceware.org (Postfix) with ESMTPS id 8F0D23856242 for ; Tue, 2 Aug 2022 12:47:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F0D23856242 Received: from octopus.. (unknown [IPv6:2a01:e0a:535:2750:1299:7061:a63:c92]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 525DC8980E; Tue, 2 Aug 2022 12:47:46 +0000 (UTC) From: Lancelot SIX To: gdb-patches@sourceware.org Cc: tdevries@suse.de, lsix@lancelotsix.com, Lancelot SIX Subject: [PATCH 2/2] gdb/testsuite: Accept PIE/noPIE programs in gdb.mi/mi-var-invalidate-shlib.exp Date: Tue, 2 Aug 2022 13:47:24 +0100 Message-Id: <20220802124724.284096-3-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220802124724.284096-1-lancelot.six@amd.com> References: <20220802124724.284096-1-lancelot.six@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Tue, 02 Aug 2022 12:47:46 +0000 (UTC) X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP 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, 02 Aug 2022 12:47:50 -0000 PR/29426 shows failures when running the gdb.mi/mi-var-invalidate-shlib test when using a compiler which does not produce a PIE executable by default. In the testcase, a varobj is created to track a global variable, and then the main binary is reloaded in GDB (using the file command). During the load of the new binary, GDB tries to recreate the varobj to track the global in the new binary (varobj_invalidate_iter). At this point, the old process is still in flight. So when we try to access to the value of the global, in a PIE executable we only have access to the unrelocated address (the objfile's text_section_offset () is 0). As a consequence down the line read_value_memory fails to read the unrelated address, so cannot evaluate the value of the global. Note that the expression used to access to the global’s value is valid, so the varobj can be created. When using a non PIE executable, the address of the global GDB knows about at this point does not need relocation, so read_value_memory can access the (old binary’s) value. So at this point, in the case of a non-PIE executable the value field is set, while it is cleared in the case of PIE executable. Later when the test issues a "-var-update global_var", the command sees no change in the case of the non-PIE executable, while in the case of the PIE executable install_new_value sees that value changes, leading to a different output. This patch changes the testcase to accept both behaviors. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29426 --- gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp index 87d1d4a6a9d..d44b492ae6b 100644 --- a/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp +++ b/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp @@ -103,7 +103,7 @@ proc do_test { separate_debuginfo } { # When reloading the symbol file, only the var for the global in the main # executable is re-created. mi_gdb_test "-var-update global_var" \ - "\\^done,changelist=\\\[{name=\"global_var\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"}\\\]" \ + "\\^done,changelist=\\\[({name=\"global_var\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"})?\\\]" \ "global_var recreated" mi_gdb_test "-var-update global_shlib_var" \ "\\^done,changelist=\\\[{name=\"global_shlib_var\",in_scope=\"invalid\",has_more=\"0\"}\\\]" \ -- 2.34.1