Thursday, September 25, 2008

Walkthrough EQATEC Tracer

1: Create application in .NET

I have written a simple test application, TestEqatecTracer, to play with the new tool EQATEC .NET Tracer (which I mentioned in the previous post). In the TestEqatecTracer application,

- names are populated in a list structure,
- list is then sorted using the List.Sort() ,
- finally, the list is sorted by the last character using SortByLastCharacter Comparer class.


using System;

using System.Collections.Generic;

using System.Text;

 

namespace TestEqatecTracer

{

   public class SortByLastCharacter : IComparer<string>

   {

        #region IComparer<string> Members

 

        public int Compare(string x, string y)

        {

            if (string.IsNullOrEmpty(x) || string.IsNullOrEmpty(y))

               return 0;

            else

               return x[x.Length - 1].CompareTo(y[y.Length - 1]);

        }

 

        #endregion

   }

 

   public class Program

   {

        static void Main(string[] args)

        {

            List<string> names = new List<string>();

            names.Add("John");

            names.Add("Frank");

            names.Add("Andy");

            names.Add("Brain");

 

            Console.WriteLine("Initial names: ");

            PrintNames(names);

            Console.WriteLine();

 

            Console.WriteLine("Names sorted: ");

            names.Sort();

            PrintNames(names);

            Console.WriteLine();

 

            Console.WriteLine("Names sorted by last character: ");

            names.Sort(new SortByLastCharacter());

            PrintNames(names);

            Console.WriteLine();

 

            Console.ReadLine();

        }

 

        private static void PrintNames(List<string> names)

        {

            if (names != null)

            {

               foreach (string name in names)

                    Console.WriteLine(name);

            }

        }

   }

}



2. Instrumentation Process

Now open the EQATEC Tracer tool. In the Instrumentor tab, browse and locate the assemblies of the application. The drag and drop feature can also be used.

The list of all assemblies in the selected folder will be shown in the Assembly List.

Select the assemblies that will be analysed in the list shown, and start the instrumentation process by selecting the "Instrument currently selected assemblies" button and a modified version of the assemblies will be then generated. The instrumentation process injects trace statements in the assemblies.




3. Select methods to trace

Click the flash icon to launch the modified application. The application view will then change to the Viewer tab.

After connecting to the application, the Control tree is populated with the classes and methods of the assemblies. Select ones that needs to be traced by checking the boxes.

The LocalHost represents the local machine. If the application is a device application, then the IP address of the device should be entered.



4. View trace results

Now connect to the application using the "Play" button.

And the trace will be shown in the Trace Viewer.



25/09/2008 15:51:18 (1) enter Program.Main ( String[], )
25/09/2008 15:51:18 (1) enter+leave Program.PrintNames ( List`1[System.String], )
25/09/2008 15:51:18 (1) enter+leave Program.PrintNames ( List`1[System.String], )
25/09/2008 15:51:18 (1) enter+leave SortByLastCharacter..ctor ()
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Andy", "Brain", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 11, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "John", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 0, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Andy", "John", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 11, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "John", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 0, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "John", "Andy", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( -11, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "John", "Frank", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 3, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "John", "John", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 0, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "John", "John", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 0, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "Andy", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( -11, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "Andy", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( -11, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "Brain", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 0, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "Andy", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( -11, )
25/09/2008 15:51:18 (1) enter SortByLastCharacter.Compare ( "Brain", "Brain", )
25/09/2008 15:51:18 (1) leave SortByLastCharacter.Compare ( 0, )
25/09/2008 15:51:18 (1) enter+leave Program.PrintNames ( List`1[System.String], )

No comments: