public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH] gdb: change thread_info::name to unique_xmalloc_ptr, add helper function
Date: Thu, 23 Sep 2021 12:15:14 -0600	[thread overview]
Message-ID: <875yur5fbh.fsf@tromey.com> (raw)
In-Reply-To: <20210903022914.2026102-1-simon.marchi@efficios.com> (Simon Marchi via Gdb-patches's message of "Thu, 2 Sep 2021 22:29:14 -0400")

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> This started out as changing thread_info::name to a unique_xmalloc_ptr.
Simon> That showed that almost all users of that field had the same logic to
Simon> get a thread's name: use thread_info::name if non-nullptr, else ask the
Simon> target.  Factor out this logic in a new thread_name free function.  Make
Simon> the field private (rename to m_name) and add some accessors.

Thank you.

Simon> +  /* The user-give name of the thread.

Missing an "n" on "given".

Simon> +/* Return THREAD's name.
Simon> +
Simon> +   If THREAD has a user-given name, return it.  Otherwise, query the thread's
Simon> +   target to get the name.  May return nullptr.  */
Simon> +extern const char *thread_name (thread_info *thread);

It seems to me that this should probably be the only caller of
target_thread_name.  So, what about putting the extra logic into
target_thread_name instead of having a new function?

One idea here may be to keep target_thread_name as a simple wrapper for
the target method.  But in that case, I think target_thread_name's
declaration should be updated to say something like "don't call this,
use thread_name instead".

Other than this issue, this all looks great to me.

Tom

  reply	other threads:[~2021-09-23 18:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  2:29 Simon Marchi
2021-09-23 18:15 ` Tom Tromey [this message]
2021-09-24 21:24   ` 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=875yur5fbh.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).