Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: add load-libthread-db-quietly option
@ 2025-03-01 10:39 Gregory Heytings
  2025-03-01 11:46 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Gregory Heytings @ 2025-03-01 10:39 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]


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.

[-- Attachment #2: gdb-add-load-libthread-db-quietly-option.patch --]
[-- Type: text/x-diff, Size: 3786 bytes --]

From 472624cf3044b1351f164c308eb9cea5b7351333 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-01 10:39 [PATCH] gdb: add load-libthread-db-quietly option Gregory Heytings
@ 2025-03-01 11:46 ` Eli Zaretskii
  2025-03-01 12:00   ` Gregory Heytings
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2025-03-01 11:46 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: gdb-patches

> Date: Sat, 01 Mar 2025 10:39:06 +0000
> From: Gregory Heytings <gregory@heytings.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.

You mean, "on", right?  Because "off" is the default.

> 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(-)

There should be a NEWS entry about this new knob.

> +@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}.

This description seems to be backwards, no?  The option, when ON,
causes the messages NOT to be displayed, right?  So I suggest

  Turns on or off quiet loading of @code{libthread_db}.  When
  @code{on}, @value{GDBN} loads @code{libthread_db} quietly, without
  any messages.  The default is @code{off}.

Thanks.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-01 11:46 ` Eli Zaretskii
@ 2025-03-01 12:00   ` Gregory Heytings
  2025-03-01 14:10     ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Gregory Heytings @ 2025-03-01 12:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: Eli Zaretskii

[-- Attachment #1: Type: text/plain, Size: 734 bytes --]


Thanks for the review!  Updated patch attached.

>> 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.
>
> You mean, "on", right?  Because "off" is the default.
>

Correct.

>
> There should be a NEWS entry about this new knob.
>

Now done.

>
> This description seems to be backwards, no?  The option, when ON, causes 
> the messages NOT to be displayed, right?  So I suggest
>
>  Turns on or off quiet loading of @code{libthread_db}.  When @code{on},
>  @value{GDBN} loads @code{libthread_db} quietly, without any messages.
>  The default is @code{off}.
>

Also correct.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gdb-add-load-libthread-db-quietly-option.patch --]
[-- Type: text/x-diff; name=gdb-add-load-libthread-db-quietly-option.patch, Size: 4345 bytes --]

From 3713bf59d4d4ef43e528a8b6095a9bdca2fed734 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Sat, 1 Mar 2025 11:56:42 +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/NEWS              |  3 +++
 gdb/doc/gdb.texinfo   |  8 ++++++++
 gdb/linux-thread-db.c | 29 ++++++++++++++++++++++++++---
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index f5dbf5c3350..4e10d58642f 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 load-libthread-db-quietly 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..4b752a15c42 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4073,6 +4073,14 @@ 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 quiet loading of @code{libthread_db}.  When
+@code{on}, @value{GDBN} loads @code{libthread_db} quietly, without
+any messages.  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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-01 12:00   ` Gregory Heytings
@ 2025-03-01 14:10     ` Eli Zaretskii
  2025-03-03 14:59       ` Simon Marchi
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2025-03-01 14:10 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: gdb-patches

> Date: Sat, 01 Mar 2025 12:00:54 +0000
> From: Gregory Heytings <gregory@heytings.org>
> cc: Eli Zaretskii <eliz@gnu.org>
> 
> Thanks for the review!  Updated patch attached.
> 
> >> 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.
> >
> > You mean, "on", right?  Because "off" is the default.
> >
> 
> Correct.
> 
> >
> > There should be a NEWS entry about this new knob.
> >
> 
> Now done.
> 
> >
> > This description seems to be backwards, no?  The option, when ON, causes 
> > the messages NOT to be displayed, right?  So I suggest
> >
> >  Turns on or off quiet loading of @code{libthread_db}.  When @code{on},
> >  @value{GDBN} loads @code{libthread_db} quietly, without any messages.
> >  The default is @code{off}.
> >
> 
> Also correct.

Thanks, the documentation parts of this are approved.  Now let's see
if the Powers that Be agree to the code changes...

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  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:40         ` Eli Zaretskii
  0 siblings, 2 replies; 12+ messages in thread
From: Simon Marchi @ 2025-03-03 14:59 UTC (permalink / raw)
  To: Eli Zaretskii, Gregory Heytings; +Cc: gdb-patches

On 3/1/25 9:10 AM, Eli Zaretskii wrote:
>> Date: Sat, 01 Mar 2025 12:00:54 +0000
>> From: Gregory Heytings <gregory@heytings.org>
>> cc: Eli Zaretskii <eliz@gnu.org>
>>
>> Thanks for the review!  Updated patch attached.
>>
>>>> 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.
>>>
>>> You mean, "on", right?  Because "off" is the default.
>>>
>>
>> Correct.
>>
>>>
>>> There should be a NEWS entry about this new knob.
>>>
>>
>> Now done.
>>
>>>
>>> This description seems to be backwards, no?  The option, when ON, causes 
>>> the messages NOT to be displayed, right?  So I suggest
>>>
>>>  Turns on or off quiet loading of @code{libthread_db}.  When @code{on},
>>>  @value{GDBN} loads @code{libthread_db} quietly, without any messages.
>>>  The default is @code{off}.
>>>
>>
>> Also correct.
> 
> Thanks, the documentation parts of this are approved.  Now let's see
> if the Powers that Be agree to the code changes...
> 
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>

People ask us to make it possible to turn this or that message on and
off all the time.  The proposed command, "set
load-libthread-db-quietly", is very specific to that use case.  Could we
add perhaps a prefix command (or find an existing appropriate one) that
would allow us to easily add more such knobs?  I'm thinking of something
like (maybe not a good name, but just for the example):

  (gdb) set message load-libthread-db on/off

Simon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  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:40         ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Gregory Heytings @ 2025-03-03 15:04 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Eli Zaretskii, gdb-patches


>
> People ask us to make it possible to turn this or that message on and 
> off all the time.  The proposed command, "set 
> load-libthread-db-quietly", is very specific to that use case.
>

Indeed.

>
> Could we add perhaps a prefix command (or find an existing appropriate 
> one) that would allow us to easily add more such knobs?  I'm thinking of 
> something like (maybe not a good name, but just for the example):
>
>  (gdb) set message load-libthread-db on/off
>

Would

set print load-libthread-db on/off

be better?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-03 15:04         ` Gregory Heytings
@ 2025-03-03 15:26           ` Simon Marchi
  2025-03-03 15:58             ` Gregory Heytings
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Marchi @ 2025-03-03 15:26 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Eli Zaretskii, gdb-patches

On 3/3/25 10:04 AM, Gregory Heytings wrote:
> 
>>
>> People ask us to make it possible to turn this or that message on and off all the time.  The proposed command, "set load-libthread-db-quietly", is very specific to that use case.
>>
> 
> Indeed.
> 
>>
>> Could we add perhaps a prefix command (or find an existing appropriate one) that would allow us to easily add more such knobs?  I'm thinking of something like (maybe not a good name, but just for the example):
>>
>>  (gdb) set message load-libthread-db on/off
>>
> 
> Would
> 
> set print load-libthread-db on/off
> 
> be better?
> 

I initially thought it wouldn't be a good idea because I thought that
"set/show print" only contained options regarding the "print" command,
which is not the same thing as printing or not printing messages.  But
it is used for tweaking messages already.  I see:

set print symbol-loading -- Set printing of symbol loading messages.
set print thread-events -- Set printing of thread events (such as thread start and exit).
set print inferior-events -- Set printing of inferior events (such as inferior start and exit).

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.

Simon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-03 14:59       ` Simon Marchi
  2025-03-03 15:04         ` Gregory Heytings
@ 2025-03-03 15:40         ` Eli Zaretskii
  2025-03-03 16:31           ` Simon Marchi
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2025-03-03 15:40 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gregory, gdb-patches

> Date: Mon, 3 Mar 2025 09:59:25 -0500
> Cc: gdb-patches@sourceware.org
> From: Simon Marchi <simark@simark.ca>
> 
> People ask us to make it possible to turn this or that message on and
> off all the time.  The proposed command, "set
> load-libthread-db-quietly", is very specific to that use case.  Could we
> add perhaps a prefix command (or find an existing appropriate one) that
> would allow us to easily add more such knobs?  I'm thinking of something
> like (maybe not a good name, but just for the example):
> 
>   (gdb) set message load-libthread-db on/off

Sure, why not.  But we'd need some infrastructure for each command to
be able to determine whether it was asked to be quiet, won't we?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-03 15:26           ` Simon Marchi
@ 2025-03-03 15:58             ` Gregory Heytings
  2025-03-26 16:15               ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Gregory Heytings @ 2025-03-03 15:58 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Eli Zaretskii, gdb-patches

[-- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-03 15:40         ` Eli Zaretskii
@ 2025-03-03 16:31           ` Simon Marchi
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2025-03-03 16:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gregory, gdb-patches

On 3/3/25 10:40 AM, Eli Zaretskii wrote:
>> Date: Mon, 3 Mar 2025 09:59:25 -0500
>> Cc: gdb-patches@sourceware.org
>> From: Simon Marchi <simark@simark.ca>
>>
>> People ask us to make it possible to turn this or that message on and
>> off all the time.  The proposed command, "set
>> load-libthread-db-quietly", is very specific to that use case.  Could we
>> add perhaps a prefix command (or find an existing appropriate one) that
>> would allow us to easily add more such knobs?  I'm thinking of something
>> like (maybe not a good name, but just for the example):
>>
>>   (gdb) set message load-libthread-db on/off
> 
> Sure, why not.  But we'd need some infrastructure for each command to
> be able to determine whether it was asked to be quiet, won't we?

I'm not saying we need special infrastructure in the code to handle
this, but just to regroup similar settings under the same prefix, to
keep them together and consistent.

Simon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-03 15:58             ` Gregory Heytings
@ 2025-03-26 16:15               ` Tom Tromey
  2025-03-26 16:38                 ` Gregory Heytings
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2025-03-26 16:15 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Simon Marchi, Eli Zaretskii, gdb-patches

Gregory> Setting that option enables or disables the "Thread debugging using
Gregory> libthread_db enabled" and "Using host libthread_db library..." messages.

Hi.  Thanks for the patch.

Do you have a copyright assignment in place?  I think we'd need that
before checking this in.

The patch looks good to me, but normally it should come with a test
case.  Maybe gdb.threads/check-libthread-db.exp could be easily modified
to add one?

Tom

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] gdb: add load-libthread-db-quietly option
  2025-03-26 16:15               ` Tom Tromey
@ 2025-03-26 16:38                 ` Gregory Heytings
  0 siblings, 0 replies; 12+ messages in thread
From: Gregory Heytings @ 2025-03-26 16:38 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Simon Marchi, Eli Zaretskii, gdb-patches


> Gregory> Setting that option enables or disables the "Thread debugging using
> Gregory> libthread_db enabled" and "Using host libthread_db library..." messages.
>
> Hi.  Thanks for the patch.
>

Thanks for your reply!

>
> Do you have a copyright assignment in place?  I think we'd need that 
> before checking this in.
>

I don't have a copyright assignment for GDB, no.  Is that really necessary 
for such a trivial patch?  I thought copyright assignments were not needed 
for small enough patches?

> The patch looks good to me, but normally it should come with a test 
> case.  Maybe gdb.threads/check-libthread-db.exp could be easily modified 
> to add one?

Okay, I'll look into that.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-03-26 16:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-01 10:39 [PATCH] gdb: add load-libthread-db-quietly option 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox