From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47075 invoked by alias); 23 Nov 2017 14:41:56 -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 47066 invoked by uid 89); 23 Nov 2017 14:41:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Therefore, Including X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Nov 2017 14:41:53 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CB5E7CBA6; Thu, 23 Nov 2017 14:41:52 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CD065D9C8; Thu, 23 Nov 2017 14:41:51 +0000 (UTC) Subject: Re: [PATCH 3/4] Create private_thread_info hierarchy To: Simon Marchi , gdb-patches@sourceware.org References: <1511368867-19365-1-git-send-email-simon.marchi@ericsson.com> <1511368867-19365-4-git-send-email-simon.marchi@ericsson.com> Cc: Simon Marchi From: Pedro Alves Message-ID: <845f4008-78ed-f188-0506-c67f9e20f531@redhat.com> Date: Thu, 23 Nov 2017 14:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1511368867-19365-4-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-11/txt/msg00539.txt.bz2 On 11/22/2017 04:41 PM, Simon Marchi wrote: > From: Simon Marchi > Including gdbthread.h from darwin-nat.h gave these errors: > > /Users/simark/src/binutils-gdb/gdb/gdbthread.h:609:3: error: must use 'class' tag to refer to type 'thread_info' in this scope > thread_info *m_thread; > ^ > class > /usr/include/mach/thread_act.h:240:15: note: class 'thread_info' is hidden by a non-type declaration of 'thread_info' here > kern_return_t thread_info > ^ > > It turns out that there is a thread_info function in the Darwin/XNU/mach API: > > http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_info.html > > Therefore, I had to add the class keyword at a couple of places in gdbthread.h, > I don't really see a way around it. The way around it is to move all of gdb under "namespace gdb", and then references to thread_info hit gdb::thread_info instead. :-) > private: > - thread_info *m_thread; > + /* Use the "class" keyword here, because of a class with a "thread_info" > + function in the Darwin API. */ > + class thread_info *m_thread; This comment sounds incorrect. A a "thread_info" function/method inside some class couldn't possibly interfere, right? The issue is that there's a _free-function_ called thread_info, right? Some nits below. > @@ -776,8 +779,10 @@ sync_threadlists (void) > > if (cmp_result == 0) > { > - gbuf[gi]->priv->pdtid = pdtid; > - gbuf[gi]->priv->tid = tid; > + aix_thread_info *priv = (aix_thread_info *) gbuf[gi]->priv.get (); ... > @@ -808,8 +815,9 @@ static int > iter_tid (struct thread_info *thread, void *tidp) > { > const pthdb_tid_t tid = *(pthdb_tid_t *)tidp; > + aix_thread_info *priv = (aix_thread_info *) thread->priv.get (); This seems to scream for a "get_aix_thread_info (thread_info *);" function. > > - return (thread->priv->tid == tid); > + return priv->tid == tid; > } > > @@ -1381,11 +1379,11 @@ thread_db_pid_to_str (struct target_ops *ops, ptid_t ptid) > if (thread_info != NULL && thread_info->priv != NULL) > { > static char buf[64]; > - thread_t tid; > + thread_db_thread_info *priv > + = (thread_db_thread_info *) thread_info->priv.get (); ... > - if (info->priv->dying) > + thread_db_thread_info *priv = (thread_db_thread_info *) info->priv.get (); > + > + if (priv->dying) > return "Exiting"; > ... > return NULL; > @@ -1434,7 +1434,9 @@ thread_db_thread_handle_to_thread_info (struct target_ops *ops, > > ALL_NON_EXITED_THREADS (tp) > { > - if (tp->inf == inf && tp->priv != NULL && handle_tid == tp->priv->tid) > + thread_db_thread_info *priv = (thread_db_thread_info *) tp->priv.get (); You know what I'll say, right? :-) > + > + if (tp->inf == inf && priv != NULL && handle_tid == priv->tid) > return tp; > } > > diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c > index 1da1a98..5906eb6 100644 > --- a/gdb/nto-procfs.c > +++ b/gdb/nto-procfs.c > @@ -248,38 +248,24 @@ static void > update_thread_private_data_name (struct thread_info *new_thread, > const char *newname) > { > - int newnamelen; > - struct private_thread_info *pti; > + nto_thread_info *pti = (nto_thread_info *) new_thread->priv.get (); The comment really applies to all ports. > -/* Private data that we'll store in (struct thread_info)->private. */ > -struct private_thread_info > +/* Private data that we'll store in (struct thread_info)->priv. */ > +struct remote_thread_info : public private_thread_info > { > - char *extra; > - char *name; > - int core; > + std::string extra; > + std::string name; > + int core = -1; > > /* Thread handle, perhaps a pthread_t or thread_t value, stored as a > sequence of bytes. */ > - gdb::byte_vector *thread_handle; > + gdb::byte_vector thread_handle; Ah, OK, you did the pointer->value thing here. Great. :-) Thanks, Pedro Alves