A session at the Sela Developer Practice covering IntelliTrace, a powerful feature of Visual Studio Ultimate that can provide historical debugging information collected in development or production environments. IntelliTrace is a hybrid logger-profiler-debugger that can uncover super-difficult bugs by tracing through the history of the application's execution.
4. What Exactly Is Collected?
Method parameters
Method return values
Reference type local variables
For each referenced object, whether or not it was
there (but not its contents)
void ReadTweets(string account) {
List<Tweet> tweets = GetTweets(account, 10);
int count = 3;
for (int i = 0; i < count; ++i)
DisplayTweet(tweets[i]);
}
6. Collecting IntelliTrace Logs
Visual Studio can save logs from every run
under IntelliTrace
By default at C:ProgramDataMicrosoft Visual
Studio<VERSION>TraceDebugging
IntelliTraceSC.exe launch /cp:plan.xml app.exe
PowerShell cmdlets for ASP.NET/SharePoint
Microsoft Test Manager integration
Microsoft System Center integration
10. Extending IntelliTrace Events
Add your own events to CollectionPlan.xml
IntelliTrace can generate an event from any
method call in your code or framework code
Data queries
Declarative event formatting from method calls
Only basic types supported
12. Programmability Handlers
Custom code that formats event information
Consult
Microsoft.VisualStudio.DefaultDataQueries.dll
for inspiration (undocumented)
14. Programmable Handler
public class DiagnosticTextBoxDQ : IProgrammableDataQuery
{
public object[] EntryQuery(object thisArg, object[] args) {
return new object[] {
_nameProperty.GetValue(thisArg, null),
_textProperty.GetValue(thisArg, null) };
}
public object[] ExitQuery(object returnValue) {
return null;
}
public string FormatShortDescription(object[] results) {
return string.Format("Text changed for textbox {0}",
results[0].ToString());
}
//More methods to format and store the collected data
}
15. Summary
IntelliTrace is super-useful inside Visual Studio
while debugging
You can also collect IntelliTrace data from
QA, cloud, and production environments
http://msdn.microsoft.com/library/hh398365
You can extend IntelliTrace with your own
events
Run the JackCompiler console app example and show how we step through, step back, and view the various events.
1.Run JackCompiler.Tests (not in debug mode) and then show the failing test.In the test output, click the .iTrace file and then view the trace, get them to see the exception and then trace back through the call stack and the various calls to see that we had a “do” statement without a closing semicolon.2.Show the stand-alone collector (IntelliTraceSC.exe) to run SDPApp.WPF with IntelliTrace collection.:IntelliTraceSC.exe launch /cp:…trace.xml /f:foo.itrace SDPApp.WPF.exe(make sure that the collection plan collects information for item selection changes)3.Open the .iTrace file from the ready-made SDPApp.WPF run and explain that the user complained they got a message box saying “Invalid Operation Exception”.Find the MessageBox event in the Events View and then use the Calls View to show that it happened while still loading speaker data. (The user clicked Load and then immediately clicked a speaker in the list before the list was fully loaded.)
Go to sdpapp.cloudapp.net and view Sasha Goldshtein. An error page is displayed.Right-click the instance in Server Explorer and download the IntelliTrace logs.Find the culprit thread by looking at the request details, and then look at the Calls View until we can find the controller method that was invoked.For backup: C:\Users\Sasha\AppData\Local\Temp\Downloaded WAT Diagnostics Logs