From patchwork Sat Mar 1 10:39:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Heytings X-Patchwork-Id: 107266 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1415F3858C51 for ; Sat, 1 Mar 2025 10:40:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1415F3858C51 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=heytings.org header.i=@heytings.org header.a=rsa-sha256 header.s=20220101 header.b=Ca3dH8+d X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from heytings.org (heytings.org [95.142.160.155]) by sourceware.org (Postfix) with ESMTPS id 19E443858D20 for ; Sat, 1 Mar 2025 10:39:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19E443858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=heytings.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=heytings.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 19E443858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=95.142.160.155 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740825549; cv=none; b=dQ4VvninpvmArwW1YHirmLSIxIQQB1MzAPbIrmz7M47QEYZdGCMpXlK2irTN0TwlFOrjlN8r/wfJAGfCXHyAndsr7Wp6XdjxhWSuI3PkBxMn3DMUdu2rWr9M65rGuXeEGI1dGZqijtvU0Vw8HFP8rRim0VIpoIvaTEQoLrTw4yM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1740825549; c=relaxed/simple; bh=jvueBZzwGpNGrYnsp1sUlzs4NRLjd45Cdi5aWmOKxAM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ikhkMZX7mTIVjvB38cp918CJAayIXhBoiHHDYtV3g0zVfFq2/SVw/0EnWVF0GCSU2JsKTkob4PV2EUe/qsKbzRDpLakWQ2e1ovemqZaaVhCHiLr15wV9TIyALAo9C2Kmgx9bweHwNOzVs0EWzEKASoNEJrN8qz6iNBVL5iZ9E5M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19E443858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1740825547; bh=Wf11QU6IY+CMT2UY5W7rpGpTIoTX0vIEZbwahyCJhsQ=; h=Date:From:To:Subject:Message-ID:From; b=Ca3dH8+dr/0Eu1joji3Bk2zMMycTYNuHq5PDaxbxntueGPbv0jvcthpNZWB7fU4dL BpvGCmVhUxlSKCchqpi9yXZbax8wc2Z+yu75CQ4viF4/TxcFlRGtmxMfX2gD8HE3ce xSjInsXADOCf9BH+KXXXKr6BOAYw43guCcnGP0woRAN+eMGWCapILNO55RrqI1Wuht x5LODXw1xpLl6kfSqROZukMiJ6e2GL2SOFBWknM215yAdX/KVqBYO9lAnTlmav3ZXK SEW3QqNKzZJK371fjjbJCp1/ZVJV1pwg9gn1eLfVRCajN63QTrRE8kUOL8phJ1Sytv bmNee9okIsTyA== Date: Sat, 01 Mar 2025 10:39:06 +0000 From: Gregory Heytings To: gdb-patches@sourceware.org Subject: [PATCH] gdb: add load-libthread-db-quietly option Message-ID: MIME-Version: 1.0 Content-ID: X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org In line with the Unix tradition in which no messages are displayed when no error happens, I suggest the attached patch, with which users could "set load-libthread-db-quietly off" in their .gdbinit file. Thanks. Reviewed-By: Eli Zaretskii Reviewed-By: Eli Zaretskii From 472624cf3044b1351f164c308eb9cea5b7351333 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Sat, 1 Mar 2025 10:27:18 +0000 Subject: [PATCH] gdb: add load-libthread-db-quietly option Setting that option disables the "Thread debugging using libthread_db enabled" and "Using host libthread_db library..." messages. --- gdb/doc/gdb.texinfo | 7 +++++++ gdb/linux-thread-db.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 29c0118dda2..036150e423e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4073,6 +4073,13 @@ only on some platforms. @item show libthread-db-search-path Display current libthread_db search path. +@kindex set load-libthread-db-quietly +@kindex show load-libthread-db-quietly +@item set load-libthread-db-quietly +@itemx show load-libthread-db-quietly +Turns on or off display of messages when @code{libthread_db} is loaded. +The default is @code{off}. + @kindex set debug libthread-db @kindex show debug libthread-db @cindex debugging @code{libthread_db} diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 9d84187a9ad..d042d51c5fd 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -120,6 +120,9 @@ static bool auto_load_thread_db = true; by the "maintenance set check-libthread-db" command. */ static bool check_thread_db_on_load = false; +/* Set to true if loading libthread_db happens quietly. */ +static bool load_libthread_db_quiet = false; + /* "show" command for the auto_load_thread_db configuration variable. */ static void @@ -150,6 +153,15 @@ show_libthread_db_debug (struct ui_file *file, int from_tty, gdb_printf (file, _("libthread-db debugging is %s.\n"), value); } +/* "show" command for the load_libthread_db_quiet configuration variable. */ + +static void +show_load_libthread_db_quiet (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char* value) +{ + gdb_printf (file, _("Loading libthread_db quietly is %s.\n"), value); +} + /* If we're running on GNU/Linux, we must explicitly attach to any new threads. */ @@ -936,7 +948,8 @@ try_thread_db_load_1 (struct thread_db_info *info) return false; } - gdb_printf (_("[Thread debugging using libthread_db enabled]\n")); + if (!load_libthread_db_quiet) + gdb_printf (_("[Thread debugging using libthread_db enabled]\n")); if (!libthread_db_search_path.empty () || libthread_db_debug) { @@ -946,8 +959,9 @@ try_thread_db_load_1 (struct thread_db_info *info) if (library == NULL) library = LIBTHREAD_DB_SO; - gdb_printf (_("Using host libthread_db library \"%ps\".\n"), - styled_string (file_name_style.style (), library)); + if (!load_libthread_db_quiet) + gdb_printf (_("Using host libthread_db library \"%ps\".\n"), + styled_string (file_name_style.style (), library)); } /* The thread library was detected. Activate the thread_db target @@ -2050,6 +2064,15 @@ as they are loaded."), &maintenance_set_cmdlist, &maintenance_show_cmdlist); + add_setshow_boolean_cmd ("load-libthread-db-quietly", class_support, + &load_libthread_db_quiet, _("\ +Set whether GDB should load libthread_db quietly."), _("\ +Show whether GDB should start load libthread_db quietly."), _("\ +If enabled, GDB will load libthread_db without printing messages."), + NULL, + show_load_libthread_db_quiet, + &setlist, &showlist); + /* Add ourselves to objfile event chain. */ gdb::observers::new_objfile.attach (thread_db_new_objfile, "linux-thread-db"); -- 2.39.2