Skip to content
  • LRN's avatar
    Add g_system_thread_set_name() implementation for W32 threads · e1188564
    LRN authored
    This works by using semi-documented[1] exception to tell the debugger
    that a thread needs to have its name changed.
    
    If this exception is not caught and handled by something, it will crash
    the process, so we need to set up our own handler in case there's no
    debugger attached or the debugger can't handle this type of exception.
    
    Since SEH is not supported by gcc on i686 (at the moment), we need to use VEH
    instead. For completeness the MSVC-oriented code still uses SEH, although
    there is no reason why it shouldn't work with the VEH variant used by MinGW.
    
    VEH handler has to be set up somewhere (g_thread_win32_init () works nicely)
    and removed once it's not needed (g_thread_win32_process_detach () is added
    expressly for that purpose). Note that g_thread_win32_process_detach() is
    only called when glib is unloaded by FreeLibrary(), not when glib-using
    process is terminating.
    
    This exception is known to work with WinDbg, and adding support for it int...
    e1188564