다음을 통해 공유


Debug your app by recording code execution with IntelliTrace

Spend less time debugging your app in Visual Studio Ultimate when you use IntelliTrace to record and trace your code's execution history. You can find bugs more easily without setting lots of breakpoints because IntelliTrace lets you:

  • Record specific events that happened in your app.

    You can examine related code, data that appears in the Locals window during debugger events, and function call information, if you choose to collect it.

  • Reduce restarting your app to recreate bugs or events.

  • Debug errors that are hard to reproduce or that happen in deployment.

Here's how recording events can help you find a bug in your code:

IntelliTrace events only - high level flow

What do you want to do?

Debug my app with IntelliTrace in Visual Studio:

  • Show me past events.

  • Show me call information with past events.

  • Save my IntelliTrace session.

  • Control the data that IntelliTrace collects.

Collect IntelliTrace data during a test session in Test Manager

Collect IntelliTrace data from apps in deployment

Start debugging from an IntelliTrace log file (.iTrace file).

FAQ

  • What apps can I debug with IntelliTrace?

  • Why debug with IntelliTrace?

  • What data does IntelliTrace collect?

  • Will IntelliTrace slow down my app?

What apps can I debug with IntelliTrace?

Supported

Limited support

  • F# apps on an experimental basis

  • Windows Store apps supported for events only

Not supported

  • C++, other languages, and script

  • Windows Services, Silverlight, Xbox, or Windows Mobile apps

Note

If you want to debug a process that is already running, you can’t use IntelliTrace. You must start IntelliTrace when the process starts.

Why debug with IntelliTrace?

Traditional or live debugging shows only your app's current state with limited data about past events. You either have to infer these events based on the app's current state, or you have to recreate these events by rerunning your app.

IntelliTrace expands this traditional debugging experience by recording specific events and data at these points in time. This lets you see what happened in your app without restarting it, especially if you step past where the bug is. IntelliTrace is turned on by default during traditional debugging and collects data automatically and invisibly. This lets you switch easily between traditional debugging and IntelliTrace debugging to see the recorded information. See Record code execution with IntelliTrace while debugging and What data does IntelliTrace collect?

IntelliTrace can also help you debug errors that are hard to reproduce or that happen in deployment. You can collect IntelliTrace data and save it to an IntelliTrace log file (.iTrace file). An .iTrace file contains details about exceptions, performance events, Web requests, test data, threads, modules, and other system information. You can open this file in Visual Studio Ultimate, select an item, and start debugging with IntelliTrace. This lets you go to any event in the file and see specific details about your app at that point in time.

You can save IntelliTrace data from these sources:

Here are some examples of how IntelliTrace can help you with debugging:

  • Your app has corrupted a data file, but you don't know where this event happened.

    Without IntelliTrace, you have to look through the code to find all possible file accesses, put breakpoints on those accesses, and rerun your app to find where the problem happened. With IntelliTrace, you can see all the collected file-access events and specific details about your app when each event happened.

  • An exception happens.

    Without IntelliTrace, you get a message about an exception but you don’t have much information about the events that led to the exception. You can examine the call stack to see the chain of calls that led to the exception, but you can’t see the sequence of events that happened during those calls. With IntelliTrace, you can examine the events that happened before the exception.

  • Your app crashes on a test computer but runs successfully on a development computer.

    You can collect IntelliTrace data from Microsoft Test Manager, save the data to an .iTrace file, and attach this file to a Team Foundation Server work item for later investigation. See Collect more diagnostic data in manual tests and Debug your app using saved IntelliTrace data.

  • A bug or crash happens in an app running in deployment.

    For Microsoft Azure-based apps, you can configure IntelliTrace data collection before you publish the app. While your app runs, IntelliTrace saves data to an .iTrace file. See Debugging a Published Cloud Service with IntelliTrace and Visual Studio.

    For ASP.NET web apps hosted on IIS 7.0, 7.5, and 8.0, and SharePoint 2010 or SharePoint 2013 applications, use Microsoft Monitoring Agent, either alone or with System Center 2012, to save IntelliTrace data to an .iTrace file.

    This is useful when you want to diagnose problems with apps in deployment. See Collect diagnostic data in production by using the IntelliTrace stand-alone collector.

What data does IntelliTrace collect?

Collecting event information

By default, IntelliTrace records only IntelliTrace events. These are debugger events, exceptions, .NET Framework events, and other system events that can help you with debugging. You can choose the kinds of IntelliTrace events that you want to collect, except for debugger events and exceptions, which are always collected. See Configure IntelliTrace to collect debugging information.

  • Debugger events

    IntelliTrace always records events that happen in the Visual Studio debugger. For example, starting your app is a debugger event. Other debugger events are stopping events, which cause your app to break execution. For example, your program hits a breakpoint, hits a tracepoint, or executes a Step command.

    To help with performance, IntelliTrace doesn't record every possible value for a debugger event. Instead, it records these values:

    • Values in the Locals window. Keep the Locals window open to see these values.

    • Values in the Autos window only if the Autos window is open

    • Values in DataTips that appear when you move the mouse pointer on top of a variable in the source window to see its value. IntelliTrace doesn't collect values in pinned DataTips.

  • Exceptions

    IntelliTrace records the exception type and message for these kinds of exceptions:

    • Handled exceptions where the exception is thrown and caught

    • Unhandled exceptions

  • .NET Framework events

    By default, IntelliTrace records the most common .NET Framework events. For example:

    • For a File Access event, IntelliTrace collects the file name.

    • For a Check Checkbox event, IntelliTrace collects the checkbox state and text.

  • SharePoint 2010 and SharePoint 2013 application events

    You can record user profile events and a subset of Unified Logging System (ULS) events for SharePoint 2010 and 2013 applications running outside Visual Studio. You can save these events to an .iTrace file. Requires either Visual Studio Ultimate 2013 or Microsoft Monitoring Agent running in Trace mode.

    When you open the .iTrace file, enter a SharePoint correlation ID to find its matching web request, view the recorded events, and start debugging from a specific event. If the file contains unhandled exceptions, you can choose a correlation ID to start debugging an exception.

    See:

Collecting function call information

You can configure IntelliTrace to collect call information for functions. This information lets you see a history of the call stack and lets you step backward and forward through calls in the code. For each function call, IntelliTrace records this data:

  • Function name

  • Values of primitive data types passed as parameters at function entry points and returned at function exit points

  • Values of automatic properties when they are read or changed

  • Pointers to first-level child objects, but not their values other than if they were null or not

Note

IntelliTrace collects only the first 256 objects in arrays and the first 256 characters for strings.

See Configure IntelliTrace to collect debugging information.

Collecting module information

To control how much call information that IntelliTrace collects, specify only those modules that you care about. This can help improve your app's performance during collection. See Configure IntelliTrace to collect debugging information.

Will IntelliTrace slow down my app?

By default, IntelliTrace collects data for selected IntelliTrace events only. This might or might not slow down your app, depending on the structure and organization of your code. For example, if IntelliTrace records an event often, this might slow down your app, but it might also prompt you to consider refactoring your app.

Collecting call information might slow down your app significantly. It might also increase the size of any IntelliTrace log files (.iTrace files) that you’re saving to disk. To minimize these effects, collect call information only for the modules you care about. To change the maximum size of your .iTrace files, go to Tools, Options, IntelliTrace, Advanced. See Configure IntelliTrace to collect debugging information.

Where can I get more information?

Record code execution with IntelliTrace while debugging

Configure IntelliTrace to collect debugging information

Including Diagnostic Trace Data with Bugs that are Difficult to Reproduce

Set up your release to diagnose problems after deployment

Debug your app using saved IntelliTrace data

Blogs

Visual Studio ALM + Team Foundation Server

Forums

Visual Studio Diagnostics

Guidance

Testing for Continuous Delivery with Visual Studio 2012 – Chapter 6: A Testing Toolbox