locked
How to generate Execution Trace from a C project ? RRS feed

  • Question

  • Hi,

    My intention is to generate execution log that contains a sequence of method calls along with method signature, parameter values etc. So whenever a method is invoked I want to know what are the parameter values and other interesting pieces of information regarding that method. I generally use aspect-oriented language to do that. For of C/C++ code I tried to use aspectc++ compiler to instrument all methods of interest. So that it prints desired information regarding a method invocation before and after a method is called.

    Question:

    Is there any option (or tool) in visual studio to do this kind of job?

    Just for the record: 

    There is a visual studio Add-in for aspectc++. Unfortunately, they stopped the development and support for that Add-in a decade ago. Yet I installed that Add-in in VS2005 but it requires a license file though it was free for a month. I also managed to get one license file from aspectc.org mailing list but it doesn't work, unfortunately. So, I cannot use that add-in. If I could get that then this task could be lot easier.

    Thanks.





    • Edited by ArefinSami Tuesday, January 19, 2016 5:25 AM typo
    • Moved by May Wang - MSFT Wednesday, January 20, 2016 6:45 AM for better support
    Tuesday, January 19, 2016 5:05 AM

Answers

All replies

  • Hi ArefinSami ,

    >> My intention is to generate execution log that contains a sequence of method calls along with method signature, parameter values etc .

    Are you trying to accomplish something like the call stack mapping ? here is an article about the method of debugging : https://msdn.microsoft.com/en-us/library/dn194476.aspx?f=255&MSPPError=-2147217396

    The method can make notes on the map to track what the code is doing which is helpful to  find bugs .

    >> Yet I installed that Add-in in VS2005 but it requires a license file though it was free for a month.

    VS2005 is quite an old version, Microsoft does not support VS2005 anymore.

    >> There is a visual studio Add-in for aspectc++. Unfortunately, they stopped the development and support for that Add-in a decade ago .

    What is the plugin for Add-in ?  Could you please tell us so we can find an usable one for you.

    Best regards,

    Hart

    Tuesday, January 19, 2016 8:36 AM
  • Google for code coverage tools. See this one for example.

    Tuesday, January 19, 2016 10:58 AM
  • Hi Cheng,

    I am doing some research on specification mining. I don't want to find bug. Instead, I want to collect execution trace data (i.e., the exact sequence of method calls with all parameter values.) from which I will generate a model that states the requirement of the program. The mined specification will be in the form of Finite State Machine rather than a call stack graph. 

    aspectc++ is an aspect-oriented language for c/c++ which can be included in c/c++ project. During the compile time, it instruments all methods of interest with some aspect code. Using this, I create an aspect which is invoked before and after of all method call in the program. In the before aspect I just print method signature, parameter values, file name and in after aspect I print the return value. This is how I generate execution trace.

    The plugin enables aspect-oriented programming in visual c/c++ projects. But, its no longer usable since 2006.

    I tried to look at IntelliTrace but I am not quite sure if it is doable or not. Actually, I don't know much about IntelliTrace.

    So, do you think there is any other way to generate the execution trace?

    Thanks for your reply.

    Wednesday, January 20, 2016 6:19 AM
  • Hi ArefinSami ,

                    Thank you back ,in order to better support . I will move the case to the  Visual Studio Diagnostics (Debugger, Profiler, IntelliTrace)  forum .

    Best regards ,

    Hart



    • Edited by Hart Wang Wednesday, January 20, 2016 7:51 AM
    Wednesday, January 20, 2016 7:08 AM
  • I have a big Visual C project. I would like to instrument all the methods in a way that it will print the method signature, argument values and file name before it executes the method and return value after it executes. For example, if I execute the code below after instrumentation

    int m2(float value1, int value2)
    {
        printf("M2\n");
        return value1+value2;
    }
    
    int m1(int value)
    {
        printf("M1\n");
        m2(9.67,20);
        return value;
    }
    
    int m3(float value1, float value2, float value3)
    {
        printf("M3\n");
    return value1+value2+value3;
    }
    void m4()
    {
        printf("M4\n");
    }
    int main()
    {
        m1(10);
        m3(8.34,8.98,6.21);
        m4();
    return 0;
    }

    It should give me the output below

    Enter -> int main() Depth:0 ARGS 0 ()
    Enter -> int m1(int) Depth:1 ARGS 1 (10 )
    M1
    Enter -> int m2(float,int) Depth:2 ARGS 2 (9.67 20 )
    M2
    Exit <- int m2(float,int) Depth: 2 RET 29
    Exit <- int m1(int) Depth: 1 RET 10
    Enter -> int m3(float,float,float) Depth:1 ARGS 3 (8.34 8.98 6.21 )
    M3
    Exit <- int m3(float,float,float) Depth: 1 RET 23
    Enter -> void m4() Depth:1 ARGS 0 ()
    M4
    Exit <- void m4() Depth: 1 RET void
    Exit <- int main() Depth: 0 RET 0

    I can do that using aspectc++ in gcc. But I cannot do that in Visual C project since it doesn't support aspectc++. Any solution or suggestion ? Thanks.


    • Edited by ArefinSami Friday, January 22, 2016 1:16 AM Formatting
    • Merged by May Wang - MSFT Monday, February 1, 2016 9:04 AM duplicate
    Friday, January 22, 2016 1:15 AM
  • Hi ArefinSami,

    >>I tried to look at IntelliTrace but I am not quite sure if it is doable or not. Actually, I don't know much about IntelliTrace.

    For IntelliTrace, you could get the detailed information about this tool here:

    https://msdn.microsoft.com/en-us/library/dd264915.aspx

    Generally we use it to collect the Even information or Exception messages.

    This blog also shared us more information about this tool:

    http://blogs.msdn.com/b/visualstudioalm/archive/2015/01/16/intellitrace-in-visual-studio-ultimate-2015.aspx

    So you could check that whether it meets your requirement.

    For the old VS2005 and the tool for it, it is hard for us to get them, I also find no latest version in the latest VS version.

    In addition, as far as I know the VS has the profiler tool which could help us to collect the performance of the code, maybe you could check it in your side.

    https://msdn.microsoft.com/en-us/library/ms182372.aspx

    If I have misunderstood this issue, please feel free to let me know.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 22, 2016 9:47 AM
  • Is there any way to save IntelliTrace data in plain text file ?
    Friday, January 22, 2016 10:15 PM
  • Hi ArefinSami,

    It is the IntelliTrace log (.iTrace) file in default.

    I didn't find any tools which could change the format directly, maybe you would write the extension with the API.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/5b6416ef-8151-490f-b53e-ac7399502090/convert-intellitracelogfileitrace-into-some-other-format-using-c-code-or-any-tool?forum=vsdebug

    Thanks,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, January 23, 2016 4:16 AM