Thread debug
-
Hi All, Our programmes use a generic thread creation and destruction so it makes it easy to create and control threads in the system without everybody having to re-implement the creation code. The problem however is that in debug mode we get: The thread '___thread_callback' (0x8ec) has exited with code 0 (0x0). ___thread_callback is repeated a number of times equivilant to the number of threads created. Is there any way of changing this debug output in VS2005 to indicate which thread exited? thanks, Rich
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook
-
Hi All, Our programmes use a generic thread creation and destruction so it makes it easy to create and control threads in the system without everybody having to re-implement the creation code. The problem however is that in debug mode we get: The thread '___thread_callback' (0x8ec) has exited with code 0 (0x0). ___thread_callback is repeated a number of times equivilant to the number of threads created. Is there any way of changing this debug output in VS2005 to indicate which thread exited? thanks, Rich
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook
I think so, you could give your thread a meaningful name. Use the following code snippit.
{ // // internal type // 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; // // internal const // const DWORD MS_VC_EXCEPTION = 0x406D1388; THREADNAME_INFO thrdInfo; thrdInfo.dwType = 0x1000; thrdInfo.szName = "The Name"; thrdInfo.dwThreadID = 0xffffffff; thrdInfo.dwFlags = 0; __try { RaiseException( MS_VC_EXCEPTION, 0, sizeof(thrdInfo)/sizeof(DWORD), (DWORD*)&thrdInfo ); } __except(EXCEPTION_CONTINUE_EXECUTION) { } }
I use this technique to simplify the debugging for My CWinThread derived, but i'm confident that it should work for Worker threads as well. At low lever there isn't a difference. Hope that this helps.
codito ergo sum
-
I think so, you could give your thread a meaningful name. Use the following code snippit.
{ // // internal type // 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; // // internal const // const DWORD MS_VC_EXCEPTION = 0x406D1388; THREADNAME_INFO thrdInfo; thrdInfo.dwType = 0x1000; thrdInfo.szName = "The Name"; thrdInfo.dwThreadID = 0xffffffff; thrdInfo.dwFlags = 0; __try { RaiseException( MS_VC_EXCEPTION, 0, sizeof(thrdInfo)/sizeof(DWORD), (DWORD*)&thrdInfo ); } __except(EXCEPTION_CONTINUE_EXECUTION) { } }
I use this technique to simplify the debugging for My CWinThread derived, but i'm confident that it should work for Worker threads as well. At low lever there isn't a difference. Hope that this helps.
codito ergo sum
That is an interresting way round the problem :) Thanks.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook
-
I think so, you could give your thread a meaningful name. Use the following code snippit.
{ // // internal type // 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; // // internal const // const DWORD MS_VC_EXCEPTION = 0x406D1388; THREADNAME_INFO thrdInfo; thrdInfo.dwType = 0x1000; thrdInfo.szName = "The Name"; thrdInfo.dwThreadID = 0xffffffff; thrdInfo.dwFlags = 0; __try { RaiseException( MS_VC_EXCEPTION, 0, sizeof(thrdInfo)/sizeof(DWORD), (DWORD*)&thrdInfo ); } __except(EXCEPTION_CONTINUE_EXECUTION) { } }
I use this technique to simplify the debugging for My CWinThread derived, but i'm confident that it should work for Worker threads as well. At low lever there isn't a difference. Hope that this helps.
codito ergo sum
-
I' guess I could have done that but then I would be forced to google for it. Since I didn't remember the link where I first found it. :doh: So I thought that whilst i'm in my project containing this little piece of code, maybe i could just could copy/paste it. :-D Don't worry won't happen again ...
codito ergo sum