Re: [PATCH v5 08/24] util: add API to fetch the current thread name

Daniel P. Berrangé <[email protected]>
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-devel
Message-ID <[email protected]>
On Fri, Jan 09, 2026 at 12:49:20PM +0100, Paolo Bonzini wrote:
> On 1/8/26 18:03, Daniel P. Berrangé wrote:
> > +static __thread char namebuf[PTHREAD_MAX_NAMELEN_NP];
> 
> ... you can instead of the previous patch, add a constructor here that just
> sets namebuf to "main" with strcpy.

How about just a static initializer

  static __thread char namebuf[PTHREAD_MAX_NAMELEN_NP] = { 'm', 'a', 'i', 'n', '\0' };

or is there some interaction with __thread that makes that undesirable ?

The downside is that I wanted the nice thread names to appear in GDB
too, but I guess we can live with the main thread being unnamed in
GDB.

> 
> For Windows on the other hand it should be okay to call SetThreadDescription
> if available.
> 
> Paolo
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.