CVCollectionCmd: Collecting Concurrency Visualizer Traces where Visual Studio 11 is not Installed

The Concurrency Visualizer in Visual Studio 11 comes with a standalone collection utility that allows you to collect traces on machines where Visual Studio 11 is not installed.  This may come in handy when you need to visualize the behavior of an application, but cannot install Visual Studio 11 on the machine where you intend to run the application.  In this entry, I will provide an overview of CVCollectionCmd.

Collecting a Trace

There are a few different ways to collect a trace.  If you are interested in visualizing data associated with a single process, you can either launch an executable under the Concurrency Visualizer or attach to a running process on the system.  You can also collect a system-wide trace if you want to choose a process to investigate after collection.

Launching an Executable Under CVCollectionCmd

To launch an executable under the CVCollectionCmd, use the Launch command.  For example,

CVCollectionCmd.exe /Launch “C:\Users\MyName\Documents\ConsoleApplication1.exe”

When I am finished collecting the trace, I need to detach:

CVCollectionCmd.exe /Detach 

Attaching to a Running Process

In this example, suppose I want to collect a trace on cmd.exe.  In my case cmd.exe is running under process ID (PID) 5520.  I can attach the Concurrency Visualizer to this process using the Attach command.  In this case, I need to supply the Attach command with the process I want to attach to (for this, use the /Process option).  I can either supply the name (if the name uniquely identifies the process) or the PID.  Therefore, I can type the following:

CVCollectionCmd.exe /Attach /Process cmd

Alternatively, I could refer to cmd.exe by its PID:

CVCollectionCmd.exe /Attach /Process 5520

Either way, I am now collecting data on this process.  When I am finished collecting the trace, I need to detach:

CVCollectionCmd.exe /Detach 

Collecting a System-Wide Trace

In some cases, you may prefer to trace all processes running on the system.  To do this, simply use the Attach command without specifying a single process:

CVCollectionCmd.exe /Attach

When you are finished collecting the trace, you need to detach:

CVCollectionCmd.exe /Detach

Analyzing a Trace

It is important to analyze the trace you collected on the same machine.  If you analyze on a different machine, you run the risk that the Concurrency Visualizer will not resolve some call stacks.  To analyze a trace you recently collected, first find the trace.  Typically, the trace is saved to the current directory of the command prompt you are using.  In my case, this happens to be c:/users/MyName.

When analyzing a trace, the Concurrency Visualizer processes raw trace data associated with a single process.  Therefore, you need to specify the process you want to analyze if you collected a system-wide trace.  If the trace is not system-wide, the process of interest is already known to the Concurrency Visualizer, so one need not specify it.

To analyze a trace, use the Analyze command and specify the location of the CVTrace file that was generated during collection.  For a system-wide trace, you also need to specify the process of interest.  In my case, I want to analyze data associated with the cmd process that was running on my system during system-wide collection.  Therefore, I type the following:

CVCollectionCmd.exe /Analyze “c:/users/MyName/SystemWideCollection_2011_11_14_141211.CVTrace” /process cmd

I also collected a non-system-wide trace associated with this process.  To analyze this trace, I do not need to specify the process of interest.  Thus, I need only specify the location of the CVTrace file:

CVCollectionCmd.exe /Analyze "C:\Users\MyName\cmd_2011-11-14_131049.CvTrace"

Once analyzed, you can open the trace in Visual Studio 11 to view the results.

See also: The MSDN documentation for CVCollectionCmd.  It describes the full list of commands.

James Rapp – Parallel Computing Platform