[gst-devel] thread id in debugging

Benjamin Otte in7y118 at public.uni-hamburg.de
Thu Jul 8 12:42:02 CEST 2004


On Thu, 8 Jul 2004, Thomas Vander Stichele wrote:

> Hi all,
>
> I had to debug some threading issues, and the lack of having something
> in the debug log that could tell me what thread it was from was
> painful.  I put a print of g_thread_self in the debug handler.
>
> I took a look at g_thread_self and it seems to me that, with a global
> variable for the total thread count, and thread-specific data with
> g_private_get/set for the current thread counter, I can easily implement
> something like we used to have that prints process and thread id, where
> thread id starts at 0 (for main thread) and each new thread
> automatically gets a thread id from the debug handler if it didn't have
> one yet.
>
> What do you think ?
>
I think it would be best if we had a way to mimic the gdb thread ids. I'm
not sure how gdb does that though.
I don't like a way of using GPrivate because the debugging stuff is
intended to be generally useful and not just in the gst thread case and
such a solution would not work if an app ran its own threads (like rb
does for example).
So if getpid() doesn't work with NPTL anymore, I think the best
idea for now is to use g_print ("%p", g_thread_self()) for now.

Benjamin





More information about the gstreamer-devel mailing list