Sdílet prostřednictvím


Implementing GetProgramID and GetThreadID

The process debug manager (PDM) supplied TextInterpreter with a program ID when the program was attached to the debug engine. This ID is used to uniquely identify the program, and IDebugProgram2::GetProgramId is called by the session debug manager (SDM) to retrieve that ID.

IDebugThread2::GetThreadId is called by the SDM to retrieve the ID of the currently running thread in the program being debugged. In the case of TextInterpreter, this is the thread ID of the debug engine itself. In other implementations of interpreted programs, the thread ID could be the ID of the thread that is interpreting the code (which may or may not be the same thread the debug engine is running on: it depends on how it is implemented). For compiled programs being debugged, the thread ID would be for the currently active thread in the program being debugged.

To implement GetProgramID and GetThreadID

  1. Open the Program.cpp file, find CProgram::GetProgramId, and replace the line //TODO: RETURN PROGRAM GUID as well as the following return statement with the following:

        *pguidProgramId = m_guidProgId; 
        return S_OK; 
    
  2. Find CProgram::GetThreadId and replace the line //TODO: RETURN THREAD ID as well as the following return statement with the following:

        *pdwThreadId = GetCurrentThreadId(); 
        return S_OK; 
    
  3. Build the project to make sure there are no errors.

See Also

Concepts

Sending the Startup Events