IDE Debugging Function Calls Takes More Time RRS feed

  • Question

  • Hi,

    I am trying to extend the debugging functionality of IDE through C# Add-In. Basically during Break Mode(Debugging), I will evaluate the expressions on the current stack frame and gives the User some useful information.

    On every break point, I need to call Debugger.GetExpression() and parse the DataMembers returned by it and generated useful info out of it.

    Since our application data structures are huge, the parsing takes a huge time(visibily noticed by the user). Even for some data structure it takes 4 to 5 minutes. At each break point (F5), user has to wait for a huge time to get the useful data which is annoying.

    I need to know, how we can optimise the evaluation and parsing of the expression?

    I tried the porting the code in VSPackage and Macro, still no improvement in the timing.

    Then I tried porting the code in VC++ Add-In (thinking native code  will boost the performance) but still it takes huge time for the Debugger method calls.

    Any Suggestions / Solutions for the above issue?

    Tuesday, March 23, 2010 1:49 PM

All replies

  • Is bulk of the time spent in Debugger.GetExpression() or in your code that is doing the parsing? If it is your code, is it making calls back into the Debugger code and is it that code that is taking bulk of the time? If it is really code that you control that is taking the time, then changing languages or extension type is not going to help. You need to profile your code and figure out if some sort of caching may help you.
    Tuesday, March 23, 2010 9:16 PM
  • Thanks for the feedback.

    Please see the below block of code which takes huge time,

    Basically what I am doing is , I have a vector of class objects(The Class Object has 10 data members of basic types like int, double), which I am getting from the current stack frame using GetExpression() and then enumerating the datamembers of each object in the vector.

    GetExpression() takes little time , only the enumeration of the vector objects taking more time. And as the Vector Size increases the enumeration time also increases.

    //SAMPLE C# Add-In Code START {{

    //The below call takes approx 50 to 100 milliseconds
    EnvDTE.Expression exp = _applicationObject.Debugger.GetExpression("m_Data", false, -1);//m_Data is a Vector of Class Objects

    DateTime Start22 = DateTime.Now;//Profiling Code

    //The below enumeration block taking nearly 600 to 800 milliseconds (for Size = 30), which increases when "Size" increases
    if (exp != null && exp.IsValidValue)


         EnvDTE.Expressions expsDM = exp.DataMembers;
         EnvDTE.Expression myexp = ((EnvDTE.Expression)(expsDM.Item(1)));
         int Size = Convert.ToInt16(myexp.Value);//No Of Objects in the Vector

        for (int idx = 1; idx <= Size; idx++) //Enumerate the data-members of each Object in the vector
            EnvDTE.Expression data = ((EnvDTE.Expression)(expsDM.Item(idx + 2)));
            EnvDTE.Expressions dataMembers = data.DataMembers;
            EnvDTE.Expression attributes = ((EnvDTE.Expression)(dataMembers.Item(1)));
            EnvDTE.Expressions attributeMembers = attributes.DataMembers;
            int I1 = Convert.ToInt16(((EnvDTE.Expression)(attributeMembers.Item(1))).Value);
            int I2 = Convert.ToInt16(((EnvDTE.Expression)(attributeMembers.Item(2))).Value);
            int I3 = Convert.ToInt16(((EnvDTE.Expression)(attributeMembers.Item(3))).Value);
            int I4 = Convert.ToInt16(((EnvDTE.Expression)(attributeMembers.Item(4))).Value);
            int I5 = Convert.ToInt16(((EnvDTE.Expression)(attributeMembers.Item(5))).Value);
            double X1 = Convert.ToDouble(((EnvDTE.Expression)(dataMembers.Item(2))).Value);
            double X2 = Convert.ToDouble(((EnvDTE.Expression)(dataMembers.Item(3))).Value);
            double X3 = Convert.ToDouble(((EnvDTE.Expression)(dataMembers.Item(4))).Value);
            double X4 = Convert.ToDouble(((EnvDTE.Expression)(dataMembers.Item(5))).Value);


    DateTime End22 = DateTime.Now;//Profiling Code
    TimeSpan CallTime22 = End22 - Start22;//Profiling Code
    sw.Write("Step22 : " + CallTime22.Milliseconds.ToString());//Profiling Code

     //SAMPLE C# Add-In Code END }}

    In the normal user scenario, the "Size" value can start from 100 and can go upto 1000+... In such cases , the debugging user can visibly notice the lag.

    Is there any problem in my enumeration code?

    Anything can be done inorder to improve the enumeration time?

    The source code being debugged is a C++ Native Code. Does it have any effect on it?.


    Wednesday, March 24, 2010 4:46 AM