From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix build on macOS
Date: Wed, 11 Dec 2019 01:37:00 -0000 [thread overview]
Message-ID: <0aa60cb1-2138-6568-f99a-a9f54fa39f45@simark.ca> (raw)
In-Reply-To: <20191210214717.25680-1-tromey@adacore.com>
On 2019-12-10 4:47 p.m., Tom Tromey wrote:
> PR build/25268 points out that the build fails on macOS, because on
> macOS the "pthread_setname_np" function takes a single argument.
>
> This patch fixes the problem, by introducing a new template adapter
> function that handles both styles of pthread_setname_np. This is a
> technique I learned from Alexandre Oliva, and avoids the need for a
> complicated autoconf check.
>
> This change also meant moving the pthread_setname_np call to the
> thread function, because macOS only permits setting the name of the
> current thread. This means that there can be a brief window when gdb
> will see the wrong name; but I think this is a minor concern.
>
> Tested by rebuilding on x86-64 Fedora 30, and on macOS High Sierra.
> On Linux I also debugged gdb to ensure that the thread names are still
> set correctly.
I think a version without templates would make it a bit simpler to understand:
void
set_thread_name (int (*set_name) (pthread_t, const char *), const char *name)
{
set_name (pthread_self (), name);
}
void
set_thread_name (int (*set_name) (const char *), const char *name)
{
set_name (name);
}
Also, they should probably be static, disabling -Wunused-functions, if necessary,
like in:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blobdiff;f=gdb/gdbsupport/safe-strerror.c;h=9973fa678577c3ff1d9188a6679a0c8cecfd5d26;hp=7425af590f789c1625013c9dc51b505a324ad7fd;hb=cb51113052d534b628c635ac7b86b95fe436d60d;hpb=ab7d13f07027e6232a21448ef51f0a52a96738a9
Simon
next prev parent reply other threads:[~2019-12-11 1:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-10 21:47 Tom Tromey
2019-12-11 1:37 ` Simon Marchi [this message]
2019-12-11 13:52 ` Tom Tromey
2019-12-11 14:07 ` Simon Marchi
2020-01-31 14:43 ` Kevin Buettner
2020-01-31 16:52 ` Tom Tromey
2020-01-31 21:40 ` Kevin Buettner
2020-02-05 18:37 ` Christian Biesinger 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=0aa60cb1-2138-6568-f99a-a9f54fa39f45@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.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