Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Thread debug

Thread debug

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RichardS
    wrote on last edited by
    #1

    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

    B 1 Reply Last reply
    0
    • R RichardS

      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

      B Offline
      B Offline
      BadKarma
      wrote on last edited by
      #2

      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

      R L 2 Replies Last reply
      0
      • B BadKarma

        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

        R Offline
        R Offline
        RichardS
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • B BadKarma

          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

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          That's good but you could have just given him the link[^] to the documentation you got that from.

          B 1 Reply Last reply
          0
          • L led mike

            That's good but you could have just given him the link[^] to the documentation you got that from.

            B Offline
            B Offline
            BadKarma
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups