src/os/windows/vm/os_windows.cpp

changeset 9676
bf1c9a3312a4
parent 9628
04cb6ac03887
child 9703
2fdf635bcf28
child 9711
0f2fe7d37d8c
     1.1 --- a/src/os/windows/vm/os_windows.cpp	Fri May 17 07:44:31 2019 +0100
     1.2 +++ b/src/os/windows/vm/os_windows.cpp	Mon Oct 13 22:11:39 2014 +0200
     1.3 @@ -744,8 +744,29 @@
     1.4  }
     1.5  
     1.6  void os::set_native_thread_name(const char *name) {
     1.7 -  // Not yet implemented.
     1.8 -  return;
     1.9 +
    1.10 +  // See: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
    1.11 +  //
    1.12 +  // Note that unfortunately this only works if the process
    1.13 +  // is already attached to a debugger; debugger must observe
    1.14 +  // the exception below to show the correct name.
    1.15 +
    1.16 +  const DWORD MS_VC_EXCEPTION = 0x406D1388;
    1.17 +  struct {
    1.18 +    DWORD dwType;     // must be 0x1000
    1.19 +    LPCSTR szName;    // pointer to name (in user addr space)
    1.20 +    DWORD dwThreadID; // thread ID (-1=caller thread)
    1.21 +    DWORD dwFlags;    // reserved for future use, must be zero
    1.22 +  } info;
    1.23 +
    1.24 +  info.dwType = 0x1000;
    1.25 +  info.szName = name;
    1.26 +  info.dwThreadID = -1;
    1.27 +  info.dwFlags = 0;
    1.28 +
    1.29 +  __try {
    1.30 +    RaiseException (MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info );
    1.31 +  } __except(EXCEPTION_CONTINUE_EXECUTION) {}
    1.32  }
    1.33  
    1.34  bool os::distribute_processes(uint length, uint* distribution) {

mercurial