diff options
author | David Hoyt <dhoyt@llnl.gov> | 2010-10-20 10:18:18 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-12-02 19:02:08 +0100 |
commit | 7199a4f1ff71c422cb682fb5d78b6cc1a5f11e91 (patch) | |
tree | d9aa54fbdd266ca2f7e1af0ee6bf4378a3499302 /gst | |
parent | a797b9f22bf548ff5caa70d670d26aaaade6540e (diff) |
gsttask: Set thread names on Windows with MSVC if a debugger is attached
Fixes bug #632168.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/gsttask.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gst/gsttask.c b/gst/gsttask.c index 18f8869f86..21cadbc538 100644 --- a/gst/gsttask.c +++ b/gst/gsttask.c @@ -103,6 +103,36 @@ struct _GstTaskPrivate GstTaskPool *pool_id; }; +#ifdef _MSC_VER +#include <windows.h> + +struct _THREADNAME_INFO +{ + DWORD dwType; // must be 0x1000 + LPCSTR szName; // pointer to name (in user addr space) + DWORD dwThreadID; // thread ID (-1=caller thread) + DWORD dwFlags; // reserved for future use, must be zero +}; +typedef struct _THREADNAME_INFO THREADNAME_INFO; + +void +SetThreadName (DWORD dwThreadID, LPCSTR szThreadName) +{ + THREADNAME_INFO info; + info.dwType = 0x1000; + info.szName = szThreadName; + info.dwThreadID = dwThreadID; + info.dwFlags = 0; + + __try { + RaiseException (0x406D1388, 0, sizeof (info) / sizeof (DWORD), + (DWORD *) & info); + } + __except (EXCEPTION_CONTINUE_EXECUTION) { + } +} +#endif + static void gst_task_finalize (GObject * object); static void gst_task_func (GstTask * task); @@ -207,6 +237,14 @@ gst_task_configure_name (GstTask * task) GST_DEBUG_OBJECT (task, "Failed to set thread name"); } #endif +#ifdef _MSC_VER + const gchar *name; + name = GST_OBJECT_NAME (task); + + /* set the thread name to something easily identifiable */ + GST_DEBUG_OBJECT (task, "Setting thread name to '%s'", name); + SetThreadName (-1, name); +#endif } static void |