From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id FkRNOg3vdGpYRA4AWB0awg (envelope-from ) for ; Thu, 06 Aug 2026 16:31:09 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ka/VIjXp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DC02A1E09B; Thu, 06 Aug 2026 16:31:09 -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 E7AB91E09B for ; Thu, 06 Aug 2026 16:31:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A3CE4BB5880 for ; Thu, 6 Aug 2026 20:31:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A3CE4BB5880 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ka/VIjXp Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id 19BED4BB5888 for ; Thu, 6 Aug 2026 20:30:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19BED4BB5888 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 19BED4BB5888 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786048243; cv=none; b=Un6SJVIBuG/THKaenKl1x8lwnhDl+sgz7IIj33zABJQqCWJFnsn403mMSOcbJ+epywQUYAdohpu+/+qLUJzh8I1WczU095NfBFRPIAYugfnrcUKkJ5/Fh7mo2vTlj5DyDnaV8h6VRTwMTAOe9HQSwRwjVZYbSGEK7NtRDRzRVeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786048243; c=relaxed/simple; bh=cTDYjbVcBBJMVTb1PEHba1plRgXKUw1GAM5H+D2sTZY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=A89HW1fDwQGMku/cXVAMJ22v2uculp3LEBnK7oN3O/FYqxJ1h4ElgpEPsdYzbsZU2EshkSg15uDPjGKX2J3FcCy21nN7m17oCwy1nvFokZBbpCNIFU/NDTLS2Sa87xuRP/2i73aHD4dhey1CYbkee+wQ0uxy9rg/M0o2gWNYkIY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ka/VIjXp DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19BED4BB5888 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-458de93b53fso1272397fac.2 for ; Thu, 06 Aug 2026 13:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1786048242; x=1786653042; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=yU5TP/M71vSdBe1MtbpKuYQHmTJRxYLTtZd9ZXMOSWM=; b=ka/VIjXp8ebuRk74mTvX7V4+3Z8fz/b6nUtJIS3Gr2eoGsm7jDwyGOzIUN++NNVVkV e6x0uxnyLEDx8F6nPEpvgE9dEwqQn8LypbwU4kpOuJgjwqmK+bPvb+HAmjLY/BE3KAq2 pDQHdnyQYZxv+dwhs3/r4QwLmthOWpWCunH1G227OCt9nS3FXed3XBuGgFrbP8CrMxeB MemurLjr5JdiZKOxOdm5P8GuEimQnVsYgDX6/XAzM2WPVRtKI1px2yY1IX2InIn2xNHN sGkrgj/b2CGk/VXpZfMgHa/LGJslzCEvjZEEJGGvNh9NFxqJ3RMS+4kL3B7vDwNlFi87 TZ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786048242; x=1786653042; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yU5TP/M71vSdBe1MtbpKuYQHmTJRxYLTtZd9ZXMOSWM=; b=Pv64pm9Kj8a/MbiRvuzKB5AtFUfgg1eW5LdXpSXLAW1G0qEADSJP2TRjvnuqwnUZH1 Mp4EzaFvS/OYIbtBUnG6YZyfkNL3r6xNdtpZ5lZkx0NhuJdONcQwV6F8y7OzUYfG7/oN uitb4WYKjamcmMfDn5nypAvqN0b8ZZsOrgdUk2UETzpNaW9HjhtBLey2eURxoz0CFMcB aXbjbKhW+aKdlBVFPnY8tm/Gb3gyhX5RzQt6jYZ372cNA8QSYrgKd+dgb0AGkeg7myE4 voWt0+jBsMoo1zEtAWXvgCjaHeAZNlV6ioe+nUDCCMRsH1s97ItpsCUPkqiD/GQ+YdeP GjaA== X-Gm-Message-State: AOJu0Yw4tew01LCpqEbGHly1DYPZcEzXaZaSeyHubKHUmqzoLQAd7ipE mNmrhyZNKVGsJolW+HnfAHX+4tyVwEdrx5WtS4ip4zUK/BKoMnF0OHB9zG3TECadV2bjK7aI9vk CO9Q= X-Gm-Gg: AR+sD13Z9DXuUHkbwTgzq9z3+Ssd0WNL2KZq44OhjjAIRVIKdT1zPsgH8mwmK/NO2oR W0l6VR0MtYctBbRfhj9YCsafYIuRK14QXFmKyoS3T5Z3wKdBS+oiNZNdDbg2vioN2gJNz78GHug zjKJtG93/+9lpI+3VWmOHpt6Ed5E3bElqCrti0Kvt3RG46Ip/qmf3hRa42/PbEavQWUkeAPLYKx nGK2uHk1hghnT72vGkQS4PV8ZfpQT/UEYFYUA6iDFByLmKXsCqkwE+jMfJBNMTPD6SgjrXH66o8 GBbVZGo7QlhP0O8uwtOqv1C6aWUW2Ee2BfWhfpvar/hx88Hlm96jIiEFCSAN/uKxjZxdgTbAC1i Z8H1+UFzgXJh58hrRpyGsn1OaLgquTcdjDTjIXUo6Wb8vF4D/vNOJ0CALy3HKFYE4gze3uHfuiL HcHp5xxHpfDHZHrBOSHUoOBz2xy8fHehl5qoxBTsHSGq5HlHnzfZAnfEGhtCsOOxwcIiEKcXb7B 94N9+81pugM6gwbWb/0 X-Received: by 2002:a05:6870:84c6:b0:451:d946:1dbc with SMTP id 586e51a60fabf-4599eb709d5mr9322053fac.7.1786048242240; Thu, 06 Aug 2026 13:30:42 -0700 (PDT) Received: from bapiya (75-166-225-82.hlrn.qwest.net. [75.166.225.82]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-459f1e21215sm421525fac.13.2026.08.06.13.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 13:30:41 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2] Minor 'debug_*' function improvements Date: Thu, 6 Aug 2026 14:30:39 -0600 Message-ID: <20260806203039.1140017-1-tromey@adacore.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 I wanted to get a summary of a type in gdb and then realized I had forgotten the function name, so I had to dig around to find it. This made me think that perhaps renaming the debug_* functions to all just be named 'debug' would be an improvement, since it's easier to remember. Then I noticed that debug_type and debug_val don't print a trailing newline. Finally, I needed to be able to see the contents of a gdb_mpz. v2 changes these functions to use ATTRIBUTE_USED rather than ATTRIBUTE_UNUSED, as the former indicates that these should not be deleted even if apparently unused. --- gdb/expprint.c | 4 ++-- gdb/gmp-utils.c | 12 ++++++++++++ gdb/typeprint.c | 7 ++++--- gdb/valprint.c | 7 ++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gdb/expprint.c b/gdb/expprint.c index bc1929b1a1b..4859d48f6a4 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -35,13 +35,13 @@ /* Meant to be used in debug sessions, so don't export it in a header file. */ -extern void ATTRIBUTE_USED debug_exp (struct expression *exp); +extern void ATTRIBUTE_USED debug (struct expression *exp); /* Print EXP. */ void ATTRIBUTE_USED -debug_exp (struct expression *exp) +debug (struct expression *exp) { exp->dump (gdb_stdlog); gdb_flush (gdb_stdlog); diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c index 168479c50df..b7fed9a82d1 100644 --- a/gdb/gmp-utils.c +++ b/gdb/gmp-utils.c @@ -39,6 +39,18 @@ gmp_string_printf (const char *fmt, ...) return str; } +/* Meant to be used in debug sessions, so don't export it in a header file. */ +extern void ATTRIBUTE_USED debug (const gdb_mpz &); + +/* Print VAL. */ + +void ATTRIBUTE_USED +debug (const gdb_mpz &val) +{ + gdb_printf (gdb_stdlog, "%s\n", val.str ().c_str ()); + gdb_flush (gdb_stdlog); +} + /* See gmp-utils.h. */ void diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 31a9c1814a3..7d1ebc6fdca 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -516,14 +516,15 @@ ptype_command (const char *type_name, int from_tty) } /* Meant to be used in debug sessions, so don't export it in a header file. */ -extern void ATTRIBUTE_UNUSED debug_type (struct type *type); +extern void ATTRIBUTE_USED debug (struct type *type); /* Print TYPE. */ -void ATTRIBUTE_UNUSED -debug_type (struct type *type) +void ATTRIBUTE_USED +debug (struct type *type) { type_print (type, "", gdb_stdlog, 1); + gdb_printf (gdb_stdlog, "\n"); gdb_flush (gdb_stdlog); } diff --git a/gdb/valprint.c b/gdb/valprint.c index 50a4663ca3b..3e7a37338b3 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1232,14 +1232,15 @@ value_print (struct value *val, struct ui_file *stream, } /* Meant to be used in debug sessions, so don't export it in a header file. */ -extern void ATTRIBUTE_UNUSED debug_val (struct value *val); +extern void ATTRIBUTE_USED debug (struct value *val); /* Print VAL. */ -void ATTRIBUTE_UNUSED -debug_val (struct value *val) +void ATTRIBUTE_USED +debug (struct value *val) { value_print (val, gdb_stdlog, &user_print_options); + gdb_printf (gdb_stdlog, "\n"); gdb_flush (gdb_stdlog); } base-commit: 035b2e70824ab51ec4d6754345456622c618b450 -- 2.55.0