From: Gregory Heytings <gregory@heytings.org>
To: Simon Marchi <simark@simark.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: add load-libthread-db-quietly option
Date: Mon, 03 Mar 2025 15:58:11 +0000 [thread overview]
Message-ID: <121e13947654b970dad8@heytings.org> (raw)
In-Reply-To: <6adc8d6d-eb2c-41b5-af60-ee3191720ee2@simark.ca>
[-- Attachment #1: Type: text/plain, Size: 171 bytes --]
>
> So, unless there is a better place for this type of commands that I
> don't know about, I think "set print" would be fine.
>
Okay, thanks. Updated patch attached.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: add-set-print-libthread-db-loading-option.patch --]
[-- Type: text/x-diff; name=add-set-print-libthread-db-loading-option.patch, Size: 4313 bytes --]
From 15d44eae87d2026262dadb124f1afa14211d71da Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Mon, 3 Mar 2025 15:49:01 +0000
Subject: [PATCH] gdb: add 'set print libthread-db-loading' option
Setting that option enables or disables the "Thread debugging using
libthread_db enabled" and "Using host libthread_db library..." messages.
---
gdb/NEWS | 3 +++
gdb/doc/gdb.texinfo | 7 +++++++
gdb/linux-thread-db.c | 30 +++++++++++++++++++++++++++---
3 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index f5dbf5c3350..ddd34f354af 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -40,6 +40,9 @@ show riscv numeric-register-names
(e.g 'x1') or their abi names (e.g. 'ra').
Defaults to 'off', matching the old behaviour (abi names).
+set print libthread-db-loading on|off
+ Controls whether GDB displays messages when loading libthread_db.
+
* Python API
** New class gdb.Color for dealing with colors.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 29c0118dda2..788a7cced59 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 print libthread-db-loading
+@kindex show print libthread-db-loading
+@item set print libthread-db-loading
+@itemx show print libthread-db-loading
+Turns on or off printing messages when loading @code{libthread_db}.
+The default is @code{on}.
+
@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..5cd518c216a 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 prints notices. */
+static bool print_libthread_db_loading = true;
+
/* "show" command for the auto_load_thread_db configuration variable. */
static void
@@ -150,6 +153,16 @@ 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 print_libthread_db_loading configuration variable. */
+
+static void
+show_print_libthread_db_loading (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c,
+ const char* value)
+{
+ gdb_printf (file, _("Printing of libthread_db loading messages is %s.\n"), value);
+}
+
/* If we're running on GNU/Linux, we must explicitly attach to any new
threads. */
@@ -936,7 +949,8 @@ try_thread_db_load_1 (struct thread_db_info *info)
return false;
}
- gdb_printf (_("[Thread debugging using libthread_db enabled]\n"));
+ if (print_libthread_db_loading)
+ gdb_printf (_("[Thread debugging using libthread_db enabled]\n"));
if (!libthread_db_search_path.empty () || libthread_db_debug)
{
@@ -946,8 +960,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 (print_libthread_db_loading)
+ 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 +2065,15 @@ as they are loaded."),
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+ add_setshow_boolean_cmd ("libthread-db-loading", no_class,
+ &print_libthread_db_loading, _("\
+Set printing of libthread_db loading messages."), _("\
+Show printing of libthread_db loading messages."), _("\
+If disabled, GDB will load libthread_db without printing messages."),
+ NULL,
+ show_print_libthread_db_loading,
+ &setprintlist, &showprintlist);
+
/* Add ourselves to objfile event chain. */
gdb::observers::new_objfile.attach (thread_db_new_objfile, "linux-thread-db");
--
2.39.2
next prev parent reply other threads:[~2025-03-03 15:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 10:39 Gregory Heytings
2025-03-01 11:46 ` Eli Zaretskii
2025-03-01 12:00 ` Gregory Heytings
2025-03-01 14:10 ` Eli Zaretskii
2025-03-03 14:59 ` Simon Marchi
2025-03-03 15:04 ` Gregory Heytings
2025-03-03 15:26 ` Simon Marchi
2025-03-03 15:58 ` Gregory Heytings [this message]
2025-03-26 16:15 ` Tom Tromey
2025-03-26 16:38 ` Gregory Heytings
2025-03-03 15:40 ` Eli Zaretskii
2025-03-03 16:31 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=121e13947654b970dad8@heytings.org \
--to=gregory@heytings.org \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox