From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5357 invoked by alias); 26 Nov 2019 19:38:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5342 invoked by uid 89); 26 Nov 2019 19:38:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=evolve, blocker X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 19:38:10 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 87491203AC; Tue, 26 Nov 2019 14:38:08 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 61280202D0; Tue, 26 Nov 2019 14:38:07 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 3741E20AF6; Tue, 26 Nov 2019 14:38:07 -0500 (EST) X-Gerrit-PatchSet: 4 Date: Tue, 26 Nov 2019 19:38:00 -0000 From: "Pedro Alves (Code Review)" To: Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review v4] Set names of worker threads X-Gerrit-Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35 X-Gerrit-Change-Number: 176 X-Gerrit-ChangeURL: X-Gerrit-Commit: f5ffec7ecbf5b18a0a4962f9ff73a138aadd0367 In-Reply-To: References: X-Gerrit-Comment-Date: Tue, 26 Nov 2019 14:38:06 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191126193807.3741E20AF6@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-11/txt/msg00916.txt.bz2 Pedro Alves has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176 ...................................................................... Patch Set 4: (3 comments) Some comments below. Nothing major. | --- gdb/gdbsupport/thread-pool.c | +++ gdb/gdbsupport/thread-pool.c | @@ -22,15 +22,24 @@ #include "common-defs.h" | #if CXX_STD_THREAD | | #include "gdbsupport/thread-pool.h" | #include "gdbsupport/alt-stack.h" | #include "gdbsupport/block-signals.h" | #include | | +/* On the off chance that we have the pthread library on a Windows | + host, but std::thread is not using it, avoid calling | + pthread_setname_np on Windows. */ PS4, Line 31: Meh. Judging from , I think this could be solved. But yeah, we really don't have to bend backwards in this initial patch. | +#ifndef _WIN32 | +#ifdef HAVE_PTHREAD_SETNAME_NP | +#include | +#endif | +#endif PS4, Line 36: I'd rather this was: #ifndef _WIN32 # ifdef HAVE_PTHREAD_SETNAME_NP # define USE_PTHREAD_SETNAME_NP # endif #endif #ifdef USE_PTHREAD_SETNAME_NP # include #endif so that below we don't duplicate the checks, and we'd have a single place to edit in the future if the checks evolve. See below... | + | namespace gdb | { | | /* The thread pool detach()s its threads, so that the threads will not | prevent the process from exiting. However, it was discovered that | if any detached threads were still waiting on a condition variable, | then the condition variable's destructor would wait for the threads | to exit -- defeating the purpose. ... | @@ -57,14 +66,19 @@ thread_pool::set_thread_count (size_t num_threads) | if (m_thread_count < num_threads) | { | /* Ensure that signals used by gdb are blocked in the new | threads. */ | block_signals blocker; | for (size_t i = m_thread_count; i < num_threads; ++i) | { | std::thread thread (&thread_pool::thread_function, this); | +#ifndef _WIN32 /* See the comment at the top of the file. */ | +#ifdef HAVE_PTHREAD_SETNAME_NP PS4, Line 75: ... here, we'd do: #ifdef USE_PTHREAD_SETNAME_NP | + pthread_setname_np (thread.native_handle (), "gdb worker"); | +#endif | +#endif | thread.detach (); | } | } | /* If the new size is smaller, terminate some existing threads. */ | if (num_threads < m_thread_count) | { -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35 Gerrit-Change-Number: 176 Gerrit-PatchSet: 4 Gerrit-Owner: Tom Tromey Gerrit-CC: Pedro Alves Gerrit-Comment-Date: Tue, 26 Nov 2019 19:38:06 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment