| Index: src/platform-win32.cc
|
| diff --git a/src/platform-win32.cc b/src/platform-win32.cc
|
| index fe84bcd3fff234bd69b2e834f8bda105f29f148b..52b616d35177369f81a27a74c693d50e2b89d2d3 100644
|
| --- a/src/platform-win32.cc
|
| +++ b/src/platform-win32.cc
|
| @@ -1423,12 +1423,38 @@ bool VirtualMemory::HasLazyCommits() {
|
| // Definition of invalid thread handle and id.
|
| static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
|
|
|
| +static void SetCurrentThreadName(const char* name) {
|
| + // Reference: http://msdn2.microsoft.com/en-us/library/xcb2z8hs.aspx
|
| + // https://code.google.com/p/chromium/codesearch#chromium/src/base/threading/platform_thread_win.cc
|
| +
|
| + typedef struct tagTHREADNAME_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.
|
| + } THREADNAME_INFO;
|
| +
|
| + THREADNAME_INFO info;
|
| + info.dwType = 0x1000;
|
| + info.szName = name;
|
| + info.dwThreadID = static_cast<DWORD>(-1);
|
| + info.dwFlags = 0;
|
| +
|
| + __try {
|
| + RaiseException(
|
| + 0x406D1388 /* MSVC EXCEPTION */, 0,
|
| + sizeof(info)/sizeof(ULONG_PTR), reinterpret_cast<ULONG_PTR*>(&info));
|
| + }
|
| + __except(EXCEPTION_CONTINUE_EXECUTION) {}
|
| +}
|
| +
|
| // Entry point for threads. The supplied argument is a pointer to the thread
|
| // object. The entry function dispatches to the run method in the thread
|
| // object. It is important that this function has __stdcall calling
|
| // convention.
|
| static unsigned int __stdcall ThreadEntry(void* arg) {
|
| Thread* thread = reinterpret_cast<Thread*>(arg);
|
| + SetCurrentThreadName(thread->name());
|
| thread->NotifyStartedAndRun();
|
| return 0;
|
| }
|
|
|