From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9Q/cKMvvvmeHPT4AWB0awg (envelope-from ) for ; Wed, 26 Feb 2025 05:41:15 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VAv6bxqm; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=dyFvx/Bw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VAv6bxqm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=dyFvx/Bw; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8C0D51E105; Wed, 26 Feb 2025 05:41:15 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AA6C81E08E for ; Wed, 26 Feb 2025 05:41:14 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3832D3858C98 for ; Wed, 26 Feb 2025 10:41:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3832D3858C98 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VAv6bxqm; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=dyFvx/Bw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=VAv6bxqm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=dyFvx/Bw Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 0673A3858D28 for ; Wed, 26 Feb 2025 10:40:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0673A3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0673A3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740566441; cv=none; b=TJdfj8CAbuVqLVFdfDpmHhMvWA6NtD2tEFqoE4sMrccZf+PcvE4dAaTbN1oh70la5kyaugtjpMDgadq4H8zu+lcwm1dNEY3QgrbpUEuqISr9HvKBsjv8qyPgTNWvf1TK4y4W+90nreQhtKqzE0LO+CPsOasRsrcz58kj3nsrzVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740566441; c=relaxed/simple; bh=MXB29pGWq62IeX0zUl1ArcxTJFXAFrK4T/epJkRbCKw=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=SmwgLR1vd+M/K+UYpyn36khGhDnyfYvck3CrNeecBl4vXNwUnNUqmADiwl0vESbvjTaGe5s8S/T3Lgqaotwuv9i261OrYf3ZaCp0Jf85rSy/SDEZm5+6FheLzoMjL75uSEB1kjxiaSrY2EefHteYbcuwV1wvjgUc1Xf6iPjdb40= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0673A3858D28 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 13DD12119C for ; Wed, 26 Feb 2025 10:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1740566440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eaF90U1nUEOtK1uHBQ6+grkNDUVaP5/a8daDxF75rfY=; b=VAv6bxqmgFVG4M2LasbUg7+r11dfTvx+qmlMuJyoZ0nltiaAJWc9CAxuWQU7LtDhNCFfU0 pzOuJSdxxiNmne4aDkWomeckG5BAPhcdlYq5AfV3arwUig/ILnsed0Bxl9cha3QgiXyQkN vkbhfKfxSK/Ld6WywL1yW4YnrRNo8yA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1740566440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eaF90U1nUEOtK1uHBQ6+grkNDUVaP5/a8daDxF75rfY=; b=dyFvx/BwvoT9UxxvHsZ7y8asldRcopIcht1ZO3XTRxOUe29wsfP3lV2W+qRBC4Y2zkBtw3 5usrznUedAbQ9CBQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1740566440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eaF90U1nUEOtK1uHBQ6+grkNDUVaP5/a8daDxF75rfY=; b=VAv6bxqmgFVG4M2LasbUg7+r11dfTvx+qmlMuJyoZ0nltiaAJWc9CAxuWQU7LtDhNCFfU0 pzOuJSdxxiNmne4aDkWomeckG5BAPhcdlYq5AfV3arwUig/ILnsed0Bxl9cha3QgiXyQkN vkbhfKfxSK/Ld6WywL1yW4YnrRNo8yA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1740566440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eaF90U1nUEOtK1uHBQ6+grkNDUVaP5/a8daDxF75rfY=; b=dyFvx/BwvoT9UxxvHsZ7y8asldRcopIcht1ZO3XTRxOUe29wsfP3lV2W+qRBC4Y2zkBtw3 5usrznUedAbQ9CBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F17471377F for ; Wed, 26 Feb 2025 10:40:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id R457Oafvvmf3cgAAD6G6ig (envelope-from ) for ; Wed, 26 Feb 2025 10:40:39 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix gdb.base/nostdlib.exp on aarch64 Date: Wed, 26 Feb 2025 11:41:06 +0100 Message-ID: <20250226104106.6061-1-tdevries@suse.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On aarch64-linux, in test-case gdb.base/nostdlib.exp I run into: ... (gdb) continue^M Continuing.^M warning: Temporarily disabling breakpoints for unloaded shared library \ "/lib/ld-linux-aarch64.so.1"^M ^M Breakpoint 2, _start () at nostdlib.c:20^M 20 {^M (gdb) FAIL: gdb.base/nostdlib.exp: pie=pie: continue to marker ... This happens as follows: - the test-case sets a breakpoint on *_start, - the breakpoint resolves to *_start in the executable, - the executable is started, and the breakpoint resolves to *_start in the dynamic linker, - execution stops at *_start in the dynamic linker, - the test-case issues a continue, expecting to continue to the breakpoint on marker, - while continuing, the dynamic linker is reported as unloaded, - the breakpoint again resolves to *_start in the executable, - execution stops at *_start in the executable, and - the test-case concludes that it failed to "continue to marker". This doesn't happen on x86_64-linux. There, after the executable is started, the breakpoint again resolves to *_start in the exec. This is similar to what happens when printing _start. On aarch64-linux, we print the _start in the dynamic linker: ... $ gdb -q -batch outputs/gdb.base/nostdlib/nostdlib-pie \ -ex "b _start" \ -ex run \ -ex "print _start" \ -ex "info break" Breakpoint 1 at 0x2bc: file nostdlib.c, line 23. Breakpoint 1.2, _start () at ../sysdeps/aarch64/dl-start.S:22 22 ENTRY (_start) $1 = {void (void)} 0xfffff7fd6ac0 <_start> Num Type Disp Enb Address What 1 breakpoint keep y breakpoint already hit 1 time 1.1 y 0x0000aaaaaaaa02bc in _start at nostdlib.c:23 1.2 y 0x0000fffff7fd6ac0 in _start at dl-start.S:22 ... On x86_64-linux, we print the _start in the exec: ... Breakpoint 1 at 0x2c5: file nostdlib.c, line 23. Breakpoint 1.2, 0x00007ffff7fe4f00 in _start () from \ /lib64/ld-linux-x86-64.so.2 $1 = {void (void)} 0x5555555542c1 <_start> Num Type Disp Enb Address What 1 breakpoint keep y breakpoint already hit 1 time 1.1 y 0x00005555555542c5 in _start at nostdlib.c:23 1.2 y 0x00007ffff7fe4f00 <_start> ... The difference may be down to the availability of debug info for the _start in the dynamic linker. Finally, the described scenarion on aarch64-linux is not deterministic. The behaviour depends on the dynamic linker being reported as unloaded, which has been classified as a GLIBC bug, so that might get fixed. Ideally this test-case would stop at both *_start in the executable and the dynamic linker, but in absense of a way to specify this reliably (see PR32748), fix this by making this a temporary breakpoint, ensuring that the breakpoint will only trigger once. PR testsuite/32743 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32743 --- gdb/testsuite/gdb.base/nostdlib.exp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/nostdlib.exp b/gdb/testsuite/gdb.base/nostdlib.exp index 7c32e87ebdb..be63d0871ef 100644 --- a/gdb/testsuite/gdb.base/nostdlib.exp +++ b/gdb/testsuite/gdb.base/nostdlib.exp @@ -52,13 +52,33 @@ foreach_with_prefix pie { "nopie" "pie" } { clean_restart $binfile gdb_breakpoint "*marker" - gdb_breakpoint "*_start" + + # Say we set a permanent breakpoint on *_start. When setting the + # breakpoint, it will resolve to _start in the exec. + # After starting to run, that may stay the same, and consequently + # execution will stop there. + # OTOH, after starting to run, that may change to *_start in the dynamic + # linker, and consequently execution will stop there. + # There's currently no way to enforce one or the other (PR32748). + # + # Say we run into a stop in *_start in the dynamic linker. Continuing + # from this situation, the dynamic linker is reported as unloaded, which + # make the breakpoint resolve again to *_start in the exec, and + # consequently execution will stop there as well. + # + # However, we cannot rely on this behavior either. Reporting the dynamic + # linker as unloaded is a GLIBC bug, which may get fixed eventually. + # + # Instead of trying to cater for all these possibilities in a controlled + # fashion, make the breakpoint temporary, ensuring that there will just be + # one stop. + gdb_breakpoint "*_start" temporary gdb_run_cmd # Breakpoint 2, Stopped due to shared library event # _start () at ./gdb.base/nostdlib.c:20 - gdb_test "" {Breakpoint [0-9]+, .*_start .*} "stop at run" + gdb_test "" {Temporary breakpoint [0-9]+, .*_start .*} "stop at run" gdb_test "continue" {Breakpoint [0-9]+, marker .*} "continue to marker" base-commit: 5e0032993ab22f52fc66a26260ce0b489c1976b3 -- 2.43.0