threadname support in KDevelop 4

Niko Sams niko.sams at gmail.com
Mon Dec 21 12:37:23 UTC 2009


On Mon, Dec 21, 2009 at 12:00, Vladimir Prus <ghost at cs.msu.su> wrote:
> On Monday 21 December 2009 12:30:58 Niko Sams wrote:
>
>> >> >        std::map<pthread_t, const char*> names;
>> >> >        void set_thread_name(const char *name)
>> >> >        { names[pthread_self()] = strdup (name); };
>> >> >    void thread_name(pthread_t t) { return names[t]; }
>> >>
>> >> Imho this should be implemented on gdb side.
>> >> Vladimir, do you think this would be realistic?
>> >>
>> >> Perhaps using python that finds out the names without the need for
>> >> this special function to the application?
>> >
>> > IIUC, the problem is that in a typical pthread program, there are *no* names
>> > of the threads, and pthreads do not provide an interface to set the name,
>> > even.
>> It could be done similar to pretty printers. Usually a thread stores *somewhere*
>> the information what it does, and library or application specific
>> "pretty thread name"-scripts
>> could determine that.
>
> That sounds fine -- provided we can actually get at the thread name. E.g. QThread
> might have an objectName, but I don't know how to map from pthread_t to QThread.
> Is is possible?
QThread::start calls pthread_create with this as arg. Does that help?

Albert, what do you think about all this?

Niko




More information about the KDevelop-devel mailing list