From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UTxNK5lx2GqeGgEAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 04:02:33 -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=gy9vEL/X; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=CfB1o4G5; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WT01ctE3; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=db/dZli5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 95CF01E051; Wed, 21 Oct 2026 04:02:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 74E351E047 for ; Wed, 21 Oct 2026 04:02:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C4C04BA2E27 for ; Wed, 21 Oct 2026 08:02:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C4C04BA2E27 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=gy9vEL/X; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=CfB1o4G5; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WT01ctE3; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=db/dZli5 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 1EE604BA2E22 for ; Wed, 21 Oct 2026 08:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EE604BA2E22 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 1EE604BA2E22 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792569692; cv=none; b=GYRs+Ip4Y3Z3DTB/rNFUbGY9xQqJO6Vwama/iG5THU1dz2aAhRy4uYWlHdSym05mC+2vjFI7Y4rnfnbygDBS46KeHCkoyygKYGcZ42SyKb8OHZ8oZjhJq6evvSwA0R1EQGnKyfgTUKr4x88aM80iU2GtRlODxbGw30G2B9AHNio= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792569692; c=relaxed/simple; bh=swegJdhEsnKze1HEtoh89NWE1d8x/uTl7CWz+QrFaC8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=vzUbuolFRXn+pJ/qNCVE4bD4PUCQFObd507KiJ9b/snZ81Zk9VO2u/c7c5yCLPVGHerkp95uYX+ViEEIVEaPjzv4I80xxFlmQrkJWv01kXCIEqxPPKfUnCm53R8iIm8d6zWgN0oTpCLag2Xgc203EgUtVDqfNh28yhjNup7MsGQ= 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=gy9vEL/X; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=CfB1o4G5; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WT01ctE3; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=db/dZli5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EE604BA2E22 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 EFD3C1F7C5 for ; Wed, 21 Oct 2026 08:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792569686; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qSyyB8Tq4Qx8v303H7tUROaIhN7nzDDc8YpwopyDMog=; b=gy9vEL/XkxS4tx1Mojm0OhcHjQpMkuA9HkxQNKZGJ9xjG1KLGp7+mFPgqCohRVFuWETIk0 Ywc4uaAvrYfmiNUn3MX0AUaevih0Dw/+WKJCGqG7yNYSHc92WOBPqLOtqIs0nCxyjI1yQN pCxnObnyoGuauV9HGSIhYN4Wq6oftY0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792569686; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qSyyB8Tq4Qx8v303H7tUROaIhN7nzDDc8YpwopyDMog=; b=CfB1o4G50FdKIZTk0/OYy55FP6LEF3iishLhjN3SfSlepvb40Cp2BSvEJLCreY2XVYzmAi XmKJ4ELPrDnDorAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1792569680; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qSyyB8Tq4Qx8v303H7tUROaIhN7nzDDc8YpwopyDMog=; b=WT01ctE3DS0c8qLpzeMHArWD3BL5VG40KAmi6NBfYMyin/G06n8IS60TcW6Gn/ECT/Aaow nTJiHmgz2Zno+/VFoQuiNR0mQ8P2Uo3QFX09J5xKRxwlZuKxw9XgE7qZLijty5CnWm/hL/ 5SyTssARFXhtGX600YoOWTGVnoiYoMQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1792569680; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qSyyB8Tq4Qx8v303H7tUROaIhN7nzDDc8YpwopyDMog=; b=db/dZli5oQFREy9vKTA1OLNEoRCN5mOZd3yO+GOq4x3UWew/gJbwouqZuVVImpLesJqZh7 zbmEUB9TaMa7TwAQ== 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 BB48613518 for ; Wed, 21 Oct 2026 08:01:20 +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 ZNGOHVBx2GpjNwAAD6G6ig:T2 (envelope-from ) for ; Wed, 21 Oct 2026 08:01:20 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/4] [gdb] Add logging_file::fd Date: Wed, 21 Oct 2026 10:01:17 +0200 Message-ID: <20261021080120.349861-2-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261021080120.349861-1-tdevries@suse.de> References: <20261021080120.349861-1-tdevries@suse.de> 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]; RSPAMD_URIBL_FAIL(0.00)[gnu.org:query timed out]; 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)[gnu.org:url,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 Logging_file is derived from ui_file, which defines a virtual fd member function: ... /* If this object has an underlying file descriptor, then return it. Otherwise, return -1. */ virtual int fd () const { return -1; } ... Logging_file doesn't define its own fd, so it defaults to -1. Consequently, when logging is enabled and we do "maint internal-error", the backtrace is printed but not recorded in the log file. Fix this by adding logging_file::fd that defers to the wrapped file, like other logging_file member functions. Add a new test-case gdb.base/logging-internal-error.exp. --- gdb/logging-file.h | 6 ++ .../gdb.base/logging-internal-error.exp | 75 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 gdb/testsuite/gdb.base/logging-internal-error.exp diff --git a/gdb/logging-file.h b/gdb/logging-file.h index 5dfe1118494..95ff421d485 100644 --- a/gdb/logging-file.h +++ b/gdb/logging-file.h @@ -66,6 +66,12 @@ class logging_file : public ui_file return m_out->can_emit_style_escape (); } + int fd () const override + { + /* Defer to the wrapped file. */ + return m_out->fd (); + } + private: /* A helper function that returns true if output should go to M_OUT. */ diff --git a/gdb/testsuite/gdb.base/logging-internal-error.exp b/gdb/testsuite/gdb.base/logging-internal-error.exp new file mode 100644 index 00000000000..b121ca42612 --- /dev/null +++ b/gdb/testsuite/gdb.base/logging-internal-error.exp @@ -0,0 +1,75 @@ +# Copyright 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that the backtrace generated by "maint internal-error", if any, also +# ends up in the log file. + +require {!isremote host} + +# Do not run if gdb debug is enabled as it will interfere with logging. +require !gdb_debug_enabled + +clean_restart + +# Don't quit, don't produce a core file. +gdb_test_no_output "maint set internal-error corefile no" +gdb_test_no_output "maint set internal-error quit no" + +set log_name [standard_output_file log.txt] +gdb_test_no_output "set logging file $log_name" \ + "set logging filename" +gdb_test_no_output "set logging overwrite on" +gdb_test "set logging enabled on" "Copying output to .*" + +set seen_bt 0 +set re_bt [string_to_regexp "----- Backtrace -----"] + +set cmd "maint internal-error" +send_gdb "$cmd\n" +set re \ + [multi_line \ + [string_to_regexp "Command aborted."] \ + "$gdb_prompt $"] +gdb_expect { + -re $re_bt { + set seen_bt 1 + exp_continue + } + -re $re { + pass $cmd + } + -re "$gdb_prompt $" { + fail $cmd + } + timeout { + fail "$cmd (timeout)" + } + eof { + fail "$cmd (eof)" + } +} + +gdb_test "set logging enabled off" "Done logging to .*" + +set fd [open $log_name] +set data [read -nonewline $fd] +close $fd + +set test "Logged backtrace" +if {$seen_bt} { + gdb_assert {[regexp $re_bt $data]} $test +} else { + unsupported $test +} -- 2.51.0