Share via


Starting the Text Interpreter Program

There are two basic ways in which a debug engine (DE) is invoked for a particular program type: it is attached to an already running program, or it is invoked when the program to be debugged is launched. When it is attaching to a running program, the user is given a list of debuggers to use; this includes any custom DEs. This list is supplied by Visual Studio (or the associated just-in-time exception handler) and is derived from all the registered DEs.

However, Visual Studio does not supply a simple means to select a DE to launch when a program is launched from within Visual Studio. That is, there is no place in the IDE to say, "Run this DE whenever this project is started." The only way to tell Visual Studio what DE to use for a particular project is to create a custom project type and implement the IVsDebuggableProjectCfg interface.

Since implementing a project type is a nontrivial affair, in this part of the tutorial you will make a couple of modifications to an existing project type in order to invoke TextInterpreter. Specifically, the existing project type that will be changed is the MyC project type, which is part of the MyCPkgs solution supplied with the VSIP Environment SDK.

Warning

Since you are going to modify the current version of MyC, you may want to create a copy of it before making any changes to the original.

Note

It is very important to perform the following procedure using the installed registry tree for Visual Studio. That is, to modify the MyC project type, launch Visual Studio with no command-line options, especially without the “/rootsuffix” option that changes the installed registry tree to use. The procedure as given here creates an experimental registry tree for Visual Studio so that you can install and test with the MyC project type without affecting the original registry tree.

To remove the MyC project type from the registry, open a Command Prompt, navigate to the VSIP EnvSDK tools folder (by default, this is C:\Program Files\VSIP 8.0\EnvSdk\tools\bin), and type the following command line:

vsregex GetOrig 8.0 exp

To launch the text interpreter program

  1. Open the TextInterpreter project and then open the TextInterpreter.idl file.

  2. Locate the GUID for the Engine class; it will look something like this (the value may be different):

    [
        uuid(A4201905-D146-4143-BEE0-961E1B546B07)
        helpstring("Engine Class")
    ]
    coclass Engine;
    
  3. Copy the GUID value (everything between the parentheses) to a safe place such as Notepad.

  4. Close the TextInterpreter solution.

  5. Open the MyCPkgs solution in the VSIP Environment SDK (by default, this is C:\Program Files\VSIP 8.0\EnvSDK\MyCPkgs\mycpkgs.sln).

  6. In Solution Explorer, expand the MyCPrj project and then expand the Source Files list.

  7. Open the projcfg.cpp file, find CMyProjectCfg::SetExeLaunchTgts, and insert the following before the method itself. Make sure the GUID you actually enter is the same as the value saved from the TextInterpreter.h file, appropriately formatted for the macro.

     #include <initguid.h> 
     DEFINE_GUID(guidTIEng, 0xA4201905, 0xD146, 0x4143, 0xBE, 0xE0, 0x96, 0x1E, 0x1B, 0x54, 0x6B, 0x07); 
    
    HRESULT CMyProjectCfg::SetExeLaunchTgts()
    {
    
  8. In CMyProjectCfg::SetExeLaunchTgts itself, comment out the line m_pTargetExe->clsidCustom = guidCOMPlusNativeEng; and add the following bold line:

       else
        {
            m_pTargetExe->dlo = DLO_CreateProcess;
            //m_pTargetExe->clsidCustom = guidCOMPlusNativeEng;
            m_pTargetExe->clsidCustom = GUID_NULL; 
        }
    
  9. At the end of CMyProjectCfg::SetExeLaunchTgts, insert the following before the line hr = S_OK;:

        m_pTargetExe->pClsidList = new GUID[1]; 
        (m_pTargetExe->pClsidList)[0] = guidTIEng; 
        m_pTargetExe->dwClsidCount = 1; 
    
    hr = S_OK;
    
  10. Build the MyCPrj project.

  11. Close Visual Studio and open a command prompt.

  12. Navigate to the Visual Studio IDE common files folder (by default, C:\Program Files\Microsoft Visual Studio 8\Common7\IDE).

  13. Type the following command and press ENTER. This will create an experimental registry tree for Visual Studio with the MyC project type registered.

     devenv /setup /rootsuffix exp 
    
  14. Open Visual Studio using the command-line switch /rootsuffix exp. This can be done two ways: 1) from the command line with devenv /rootsuffix exp or 2) by creating a new shortcut on the desktop and modifying the target (in the Shortcut properties) to include /rootsuffix exp at the end of the target (and outside any quotes).

    Note

    This shortcut should already be available after installing the VSIP package. As Visual Studio Exp loads, you should see the MyC project type on the splash screen (among the other project types), indicating that the MyC project has been successfully registered with Visual Studio. You can also look in the Visual Studio About box to see if the MyC Project type has been registered with Visual Studio.

  15. From the File menu, click New Project.

  16. Expand the Other Project Types category on the left and then click the MyC Projects subcategory.

  17. On the right, click MyC Project, type TITest as the name of the project, and click OK. You can choose whatever name you want here; the rest of this procedure will assume TITest, however.

  18. In Solution Explorer, right-click the TITest project and click Properties.

  19. Select the Debug category on the left.

  20. On the right, change the Debug Mode property to Program.

  21. For the Start Application property, type the full path to the TextInterpreter executable.

  22. Click OK.

  23. In Solution Explorer, right-click the TITest project and click Add New Item.

  24. On the left, click the Utility category, and on the right, click Text File (.txt).

  25. Type MyText.txt for the filename and click OK. You can choose whatever name you wish here.

  26. Type several lines of text in the new file. This can be anything you want. For example:

     This is a line of text.
     And this is another line of text.
     This is the third line of text.
    
  27. Place a breakpoint on the second line of text.

  28. Press F5 (or click Start from the Debug menu). Answer No if asked to rebuild the project and answer Yes if asked to run the last successful build; TextInterpreter will be launched anyway.

  29. Shortly, the Visual Studio debugger should stop on the breakpoint set on the second line.

  30. Press SHIFT+F5 or click Stop Debugging from the Debug menu to terminate the debugging process.

See Also

Tasks

Tutorial: Building a Debug Engine Using ATL COM