 Chromium Code Reviews
 Chromium Code Reviews Issue 2713773002:
  ShowThreadNames tool to get thread ID/name pairs in a Chrome process  (Closed)
    
  
    Issue 2713773002:
  ShowThreadNames tool to get thread ID/name pairs in a Chrome process  (Closed) 
  | Index: tools/win/ShowThreadNames/ReadMe.txt | 
| diff --git a/tools/win/ShowThreadNames/ReadMe.txt b/tools/win/ShowThreadNames/ReadMe.txt | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..402800a6275b7dc91bea5167f2f79163204b75a5 | 
| --- /dev/null | 
| +++ b/tools/win/ShowThreadNames/ReadMe.txt | 
| @@ -0,0 +1,66 @@ | 
| +[Motivation] | 
| +This tool is designed to test the usage of the SetThreadDescription WinAPI in | 
| +Chrome. In Chrome, the SetThreadDescription API has been enabled to set thread | 
| +names. However, since there is no tool support to retrieve thread names set by | 
| +GetThreadDescription, we will still rely on SetNameInternal function in | 
| +platform_thread_win.cc to set thread names. Despite this, we need a tool to | 
| +demo the SetThreadDescription API works, even without the debugger to be present. | 
| 
brucedawson
2017/02/23 01:57:26
One character too long... There are a few others t
 
chengx
2017/02/23 03:26:03
Done.
 | 
| + | 
| +The problem setting can be referred to | 
| +https://bugs.chromium.org/p/chromium/issues/detail?id=684203 | 
| + | 
| +This tool incorporates the GetThreadDescription API trying to get names of all | 
| +threads in a process specified by its ID. If the thread names have been set by | 
| +SetThreadDescription API call like in Chrome, all thread ID/name pairs are | 
| +returned. | 
| + | 
| +[Requirement] | 
| +Since SetThreadDescription/GetThreadDescription APIs are brought in Windows 10, | 
| +version 1607, this tool can only be effective if running in this version or | 
| +later ones. | 
| + | 
| +[Complie the code] | 
| 
brucedawson
2017/02/23 01:57:26
Typo
 
chengx
2017/02/23 03:26:03
Done.
 | 
| +When compiling the code after downloading the files (.cc, .sln, .vcxproj). You | 
| +may get compile error like "Cannot convert argument 1 from const wchar_t to | 
| +LPCSTR". If this happens, right click project "ShowThreadNames", go to | 
| +"Properties", then go to "General". In panel "Project Defaults", change to "Use | 
| +Unicode Character Set" in "Character Set" section. | 
| 
brucedawson
2017/02/23 01:57:26
This should be stored in the project file so this
 
chengx
2017/02/23 03:26:03
Done.
 | 
| + | 
| +[How to use it] | 
| +Run "ShowThreadNames.exe" either from the build direcotory or from Visual Studio. | 
| 
brucedawson
2017/02/23 01:57:26
directory
 
chengx
2017/02/23 03:26:03
Done.
 | 
| +No parameters are needed. This tool allows interaction with users. Once launched, | 
| +it will show "Please enter the process Id, or "quit" to end the program :" on the | 
| +terminal. Simply type in the ID of any Chrome process you are interested in, and | 
| +you will get output like below: | 
| + | 
| +thread_ID thread_name | 
| +12116 | 
| +10292 | 
| +6532 | 
| +6928 | 
| +2488 | 
| +11304 | 
| +2256 AudioThread | 
| +9308 BrokerEvent | 
| +5668 BrowserWatchdog | 
| +4352 Chrome_CacheThread | 
| +12268 Chrome_DBThread | 
| +8616 Chrome_FileThread | 
| +1072 Chrome_FileUserBlockingThread | 
| +8280 Chrome_HistoryThread | 
| +7472 Chrome_IOThread | 
| +6336 Chrome_ProcessLauncherThread | 
| +12212 CompositorTileWorker1/12212 | 
| +3628 CrBrowserMain | 
| +6472 DnsConfigService | 
| +1980 IndexedDB | 
| +10560 TaskSchedulerBackgroundBlockingWorker0 | 
| +11464 TaskSchedulerBackgroundWorker0 | 
| +3156 TaskSchedulerForegroundBlockingWorker5 | 
| +7660 TaskSchedulerForegroundWorker0 | 
| +8216 TaskSchedulerServiceThread | 
| +11088 VideoCaptureThread | 
| + | 
| +The threads have been sorted by their names. Note that some threads have | 
| +no names. If double checking them using Visual Studio debugger, it is | 
| +found that they are ntdll.dll thread in this example. |