From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pky8K68U22q3MQ8AWB0awg (envelope-from ) for ; Fri, 23 Oct 2026 04:02:55 -0400 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=tULpqEVG; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JIdi/8+9; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xZn+2Huj; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bcEukYYO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8CF6C378003; Fri, 23 Oct 2026 04:02:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 951B5378002 for ; Fri, 23 Oct 2026 04:02:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C742E4BA9003 for ; Fri, 23 Oct 2026 08:02:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C742E4BA9003 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=tULpqEVG; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JIdi/8+9; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xZn+2Huj; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bcEukYYO Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 2F5304BA23F3 for ; Fri, 23 Oct 2026 08:02:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F5304BA23F3 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 2F5304BA23F3 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792742545; cv=none; b=x8QAeE/FZ0fDl2/iJ0/HdXgvBWufhLSDxBqzwrOV0m+TbgQk0tqxAHBr+2HntpHhjBOLxhX7aGo7D0d7Zg9GR6z8k0AJDk/sFkiDdWRe2oXpwwSOVm5jGRqiBBZpzLgKGag5T6iTl4WrdSJT1WJDrD4/cKefAVE90nJRAcyDWPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792742545; c=relaxed/simple; bh=mqE8TPcWislhmWL0u+Kcbec7XFDWwUIlUGl5AEtDlyU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=MH+b2K/QPUuARKiB6H6xmzJ69uvT468/8i1HMUxF/qkUgh+dnQdYCRmiN4if24x3ZU/tfZ5R+A5TiD/d/gB+Hn7ABcWI9mrsBYZu+I2YAgoKHh2vM69WITmysjoaWPLJWtbYBmYVLgELMitQ0YiKhNDXN9mjc+1QpzLN9K58t8g= ARC-Authentication-Results: i=1; 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=tULpqEVG; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JIdi/8+9; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=xZn+2Huj; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bcEukYYO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F5304BA23F3 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-out2.suse.de (Postfix) with ESMTPS id EBB041F7BC; Fri, 23 Oct 2026 08:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792742544; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3cpbFUSJH4g3L2uvS06X2v9X2QYlwKIYopxpY46f+1U=; b=tULpqEVGw8MGEeoj5j6mRmCLZQiNAxxCeIa6cOYq/OCkEEYXUI5ZN0mzvwYf40tPJdUvte VzagIH/XkX0P/ehXhWzJpUCVme4UFQdtYFcYGtkXT9OS4JBlUvwH5HapTSys9BW9A9ZfTE bhDMgKSRdtyLvFVfsonvx2CgrSj6qZE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792742544; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3cpbFUSJH4g3L2uvS06X2v9X2QYlwKIYopxpY46f+1U=; b=JIdi/8+9pyy6LqIrRhpYltuEFw0Qti/6jNAxl2YDnEQZ9CZmUUyLR/B77Y96FtO/5NtkZ0 JmDJPPlbtwliABAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792742543; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3cpbFUSJH4g3L2uvS06X2v9X2QYlwKIYopxpY46f+1U=; b=xZn+2HujgHu8Qj2CFEjETlDomVbTDYZpLFmUqzvgxprc0SGIpSmZujK2jal1k2V3CuBx0v N8pOELk8hAAvI+LWspY0OkUCh+uAjwbtLddZDAMOtLAe0gCAyMJfLPw3KSJ2JCt1Ydk0ci 1VyYZ3EuJraA5BPsAtWtGuxIqcPkpSc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792742543; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3cpbFUSJH4g3L2uvS06X2v9X2QYlwKIYopxpY46f+1U=; b=bcEukYYOGP6KNDi8brN/5eqPBqGE7r2tnLabn31ny6e/uX7DbZy4K1HhuZ5s8p7t+QyLIS eOVEyTq6PSDSpqAg== 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 B387C133F6; Fri, 23 Oct 2026 08:02:23 +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 +rCmII8U22qKaQAAD6G6ig (envelope-from ); Fri, 23 Oct 2026 08:02:23 +0000 Message-ID: Date: Fri, 23 Oct 2026 10:02:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] [gdb] Add logging_file::fd To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20261021080120.349861-1-tdevries@suse.de> <20261021080120.349861-2-tdevries@suse.de> <878q3ryoxx.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <878q3ryoxx.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-13.28 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-0.99)[-0.991]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email, sourceware.org:url, imap1.dmz-prg2.suse.org:helo] 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 10/21/26 6:54 PM, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > > Tom> Logging_file is derived from ui_file, which defines a virtual fd member > Tom> function: > Tom> ... > Tom> /* If this object has an underlying file descriptor, then return it. > Tom> Otherwise, return -1. */ > Tom> virtual int fd () const > Tom> { return -1; } > Tom> ... > > Tom> Logging_file doesn't define its own fd, so it defaults to -1. > > That test in bt-utils.c (and the other one in event-top.c) look weird to > me. It does this: > > if (gdb_stderr == nullptr || gdb_stderr->fd () == -1) > std::ignore = ::write (2, msg, strlen (msg)); > else > gdb_stderr->write_async_safe (msg, strlen (msg)); > > But why is that -1 check there? > > Is it because the default ui_file::write_async_safe aborts? > > Since if so then maybe that's the real issue: the API is kind of > incoherent here. > Hi Tom, thanks for the review. AFAIR, the -1 check is indeed there to make sure not to run into the default ui_file::write_async_safe, specifically when gdb_stderr is temporarily set to a string_file. > I wonder whether we could simply remove the fd() method entirely and > instead make the default write_async_safe do something sensible; or make > it pure virtual and require the subclasses to DTRT. Removing the fd () method doesn't seem possible due to the use in backtrace_symbols_fd (used when using execinfo instead of libbacktrace). I've submitted an alternative approach ( https://sourceware.org/pipermail/gdb-patches/2026-October/231353.html ): - make the default write_async_safe print to fd () - make it return true if the write was handled - use the return value to decide whether to call the stderr fd fallback. - add a new method for_each_fd to handle the execinfo case as well The code is somewhat cleaner, and there's no more direct testing of "fd () == -1" in the code, only in the ui_file classes. I'm not very familiar with this code, so I used two LLMs for review to get here. Unfortunately, they don't agree on what is correct behavior for the return value of logging_file::write_async_safe and logging_file::for_each_fd, so that probably requires some review attention. Thanks, - Tom