Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
To: Christian Biesinger <cbiesinger@google.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH][gdb/build] Fix build with undefined CXX_STD_THREAD
Date: Wed, 8 Sep 2021 09:02:10 +0200	[thread overview]
Message-ID: <8c09dea9-6a28-d838-842c-72876db50697@suse.de> (raw)
In-Reply-To: <CAPTJ0XEcGG-z-jToDFpUCEryGGaejEOo_Ac7ee-i6XFkeoVZ3g@mail.gmail.com>

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

On 9/7/21 6:12 PM, Christian Biesinger wrote:
> BTW, it seems https://sourceware.org/bugzilla/show_bug.cgi?id=28312
> was filed for this.
> 

Thanks, I've added a Bug tag.

Pushed as attached.  I've rewritten it a bit to avoid introducing a 3rd
printf.

Thanks,
- Tom


[-- Attachment #2: 0001-gdb-build-Fix-build-with-undefined-CXX_STD_THREAD.patch --]
[-- Type: text/x-patch, Size: 1970 bytes --]

[gdb/build] Fix build with undefined CXX_STD_THREAD

When building gdb on openSUSE Leap 42.3, we trigger the case that
CXX_STD_THREAD is undefined, and run into:
...
gdb/maint.c: In function 'void maintenance_show_worker_threads \
  (ui_file*, int, cmd_list_element*, const char*)':
gdb/maint.c:877:14: error: 'gdb::thread_pool' has not been declared
         gdb::thread_pool::g_thread_pool->thread_count ());
              ^
Makefile:1647: recipe for target 'maint.o' failed
make[1]: *** [maint.o] Error 1
...

Fix this by handling the undefined CXX_STD_THREAD case in
maintenance_show_worker_threads, such that we get:
...
$ gdb -q -batch -ex "maint show worker-thread"
The number of worker threads GDB can use is 0.
...

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28312

---
 gdb/maint.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/gdb/maint.c b/gdb/maint.c
index cbd7d4ed47b..8f8bdc87be8 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -871,14 +871,23 @@ maintenance_show_worker_threads (struct ui_file *file, int from_tty,
 				 struct cmd_list_element *c,
 				 const char *value)
 {
+#if CXX_STD_THREAD
   if (n_worker_threads == -1)
-    fprintf_filtered (file, _("The number of worker threads GDB "
-			      "can use is unlimited (currently %zu).\n"),
-		      gdb::thread_pool::g_thread_pool->thread_count ());
-  else
-    fprintf_filtered (file, _("The number of worker threads GDB "
-			      "can use is %d.\n"),
-		      n_worker_threads);
+    {
+      fprintf_filtered (file, _("The number of worker threads GDB "
+				"can use is unlimited (currently %zu).\n"),
+			gdb::thread_pool::g_thread_pool->thread_count ());
+      return;
+    }
+#endif
+
+  int report_threads = 0;
+#if CXX_STD_THREAD
+  report_threads = n_worker_threads;
+#endif
+  fprintf_filtered (file, _("The number of worker threads GDB "
+			    "can use is %d.\n"),
+		    report_threads);
 }
 
 \f

  reply	other threads:[~2021-09-08  7:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 14:50 Tom de Vries via Gdb-patches
2021-09-07 15:19 ` Tom de Vries via Gdb-patches
2021-09-07 16:12   ` Christian Biesinger via Gdb-patches
2021-09-08  7:02     ` Tom de Vries via Gdb-patches [this message]
2021-09-08  8:06   ` Tom de Vries via Gdb-patches

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=8c09dea9-6a28-d838-842c-72876db50697@suse.de \
    --to=gdb-patches@sourceware.org \
    --cc=cbiesinger@google.com \
    --cc=tdevries@suse.de \
    --cc=tom@tromey.com \
    /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