From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH 3/4] Create private_thread_info hierarchy
Date: Thu, 23 Nov 2017 14:41:00 -0000 [thread overview]
Message-ID: <845f4008-78ed-f188-0506-c67f9e20f531@redhat.com> (raw)
In-Reply-To: <1511368867-19365-4-git-send-email-simon.marchi@ericsson.com>
On 11/22/2017 04:41 PM, Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
> 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
next prev parent reply other threads:[~2017-11-23 14:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 16:41 [PATCH 0/4] Poison XNEW and friends for non-POD types Simon Marchi
2017-11-22 16:41 ` [PATCH 1/4] Create private_inferior class hierarchy Simon Marchi
2017-11-22 22:20 ` Joel Brobecker
2017-11-24 15:46 ` Simon Marchi
2017-11-24 21:31 ` Joel Brobecker
2017-11-23 14:09 ` Pedro Alves
2017-11-23 16:17 ` Simon Marchi
2017-11-22 16:42 ` [PATCH 4/4] Poison XNEW and friends for types that should use new/delete Simon Marchi
2017-11-23 15:02 ` Pedro Alves
2017-11-23 17:27 ` Simon Marchi
2017-11-23 17:31 ` Pedro Alves
2017-11-22 16:42 ` [PATCH 2/4] remote: C++ify thread_item and threads_listing_context Simon Marchi
2017-11-23 14:22 ` Pedro Alves
2017-11-23 16:48 ` Simon Marchi
2017-11-23 16:52 ` Pedro Alves
2017-11-22 16:42 ` [PATCH 3/4] Create private_thread_info hierarchy Simon Marchi
2017-11-23 14:41 ` Pedro Alves [this message]
2017-11-23 16:54 ` Simon Marchi
2017-11-23 16:56 ` 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=845f4008-78ed-f188-0506-c67f9e20f531@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
--cc=simon.marchi@polymtl.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