msdevcon.ru#msdevcon
ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer, Microsoft
Agenda Diagnostics in Production Remote Debugger IntelliTrace Dump Debugger Diagnostics of Client Applications First Chance Exceptions in C++ Mixed-language Contracts Background tasks Installed apps without VS project
Challenges in Production Can’t reproduce the issue in a development environment Can’t run Visual Studio on the production machine Possibly very limited developer access to production machines Want to minimize impact to the server Performance Availability Security
Remote Debugger: The Big Hammer Advantages Often the fastest way to resolve an issue Easy installation Remote Tools Xcopy deployable (%ProgramFiles%\Microsoft Visual Studio\Common7\IDE\Remote Debugger) Configurable Authentication Disadvantages Your service becomes unresponsive if you are stopped in the debugger Requires some firewall configuration
Remote Debugger TCP/IP
DEMO Remote Debugger
Improvements in Visual Studio 2012 Single Firewall Configuration (Remote Debugger Side) Can connect across different domains Symbols load from the Visual Studio side No need to copy symbol files to your production machine Faster No need to choose between x86 and x64
IntelliTrace A “Back-in-Time” debugger Configurable logging to trace the state of an application through its execution history Integrated with the Visual Studio Debugger UI for analysis Can be run either locally or via command line
IntelliTrace Collection Plans 2 Default Levels Events Calls Custom? Can turn individual events on/off Can include/exclude modules Change max log file size Requires Editing XML lintellitrace/ lintellitrace/
IntelliTrace in Production Download the IntelliTrace Collector Run it on your production machine Pick a collection plan Target the application Reproduce the issue Bring the IntelliTrace log back to your development machine Analyze in Visual Studio to find the bug
DEMO IntelliTrace In production
Impact on Server Performance Depends on a number of factors Number of events collected Number of modules included in application (startup jitting costs) Calls data collection IO
Dump Files Snapshots of the application at a single point in time Two major types With Heap – allows full inspection of the state of the app at that point in time Without Heap – only allows for inspection of the call stacks across all threads Can be opened directly in VS and debugged just like a regular application Except no stepping…
Creating Dump Files in Production Several tools available, including Visual Studio ProcDump has many qualities that make it ideal for production use Command line Xcopy deployable Provides triggers for dump collection CPU usage, Memory usage, Exceptions (with filters) Low impact on system performance Available through Microsoft SysInternals: us/sysinternals/dd aspxhttp://technet.microsoft.com/en- us/sysinternals/dd aspx
DEMO ProcDump In production
Symbols (PDBs) The debugger and IntelliTrace all need symbols to function properly Symbols provide a mapping between the binaries you are analyzing and the source code that produced them Also provide information for determining the local variables for a function Symbol files must exactly match the build that you are diagnosing It is easy for your development environment to get out of sync with what is in production
Agenda Diagnostics in Production Remote Debugger IntelliTrace Dump Debugger Diagnostics of Client Applications First Chance Exceptions in C++ Mixed-language Contracts Background tasks Installed apps without VS project
First Chance Exception Tough to find your real error in XAML apps Turning on first chance exceptions can create a lot of noise that can slow you down Async patterns can make this worse
DEMO FIRST CHANCE EXCEPTION
First Chance Exception Stop on Originate Error Exceptions for C++ Use the memory window on the third parameter to decode the secret message
Native/Managed Debugging for Store Apps Remote Debugging Native Visualization Reliable Stepping Shipped in Update 1
Mixed-language I have options for “Native Only” and “Script Only” debugging. What if I want to do both?
DEMO DEBUGGING NATIVE AND JAVASCRIPT
Debugging Native and JavaScript No Mixed Mode Debugging Support Use Multiple VS Instances Instead Launch the app under the script debugger Attach with the native debugger from a second instance of VS Visual Studio naturally gives focus to the correct instance Cannot Debug JavaScript when stopped in the native debugger
Contract Debugging Windows 8 contracts provide a new entry point for applications It’s not the same code as just launching under the debugger Simply attaching is not quick enough as you may have missed the code that you wanted to debug
DEMO CONTRACT DEBUGGING
Contract Debugging Configure the app to debug without launch in the project properties F5 the app Invoke your application manually through the contract
Background Tasks Your app can register to run background tasks when certain events happen Some background tasks are straight forward to test and debug because you can trigger them manually Others can be a much bigger pain Like a maintenance trigger that fires after 8 hours
DEMO BACKGROUND TASK DEBUGGING
Background Tasks Trigger background tasks from the Debug Location Toolbar Can trigger tasks on apps that are not running Set them to debug without launching first Can trigger tasks that do not require a payload
No Projects There are several reasons why you may not have a VS project, but still want to debug Permissions Convenience Normally build/deploy outside of VS Attach to process is a pain for WWAs Especially if you need to debug startup code!
DEMO NO PROJECT DEBUGGING
No Projects Use the “Debug Installed App Package Feature” Works both local and remote Can automatically stop at the first line of JavaScript Code
Agenda Diagnostics in Production Remote Debugger IntelliTrace Dump Debugger Diagnostics of Client Applications First Chance Exceptions in C++ Mixed-language Contracts Background tasks Installed apps without VS project
More Info, Request Features Maxim Goldin : ALM Team Blog: Uservoice site:
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.