msdevcon.ru #msdevcon
ИЗ ПЕРВЫХ РУК:ДИАГНОСТИКА ПРИЛОЖЕНИЙС ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012MAXIM GOLDIN
Senior Developer, Microsoft
AgendaDiagnostics 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 ProductionCan’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 HammerAdvantages
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
Client Side Server Side
Visual Studio
msvsmon.exe
TCP/IP
YourApp.exe
TCP/IP
DEMO
Remote Debugger
Improvements in Visual Studio 2012Single 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
IntelliTraceA “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 Plans2 Default Levels
Events
Calls
Custom? Can turn individual events on/off
Can include/exclude modules
Change max log file size
Requires Editing XML http
://blog.qetza.net/en/2010/03/08/vs-2010-personnalisation-des-vnements-de-lintellitrace/
IntelliTrace in ProductionDownload the IntelliTrace Collector
http://www.microsoft.com/en-us/download/details.aspx?id=30665
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
IntelliTraceIn production
Impact on Server PerformanceDepends on a number of factors
Number of events collected
Number of modules included in application (startup jitting costs)
Calls data collection
IO
Dump FilesSnapshots 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 ProductionSeveral 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: http://technet.microsoft.com/en-us/sysinternals/dd996900.aspx
DEMO
ProcDumpIn 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
AgendaDiagnostics 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 AppsRemote Debugging
Native Visualization
Reliable Stepping
Shipped in Update 1
Mixed-languageI have options for “Native Only” and “Script Only” debugging.
What if I want to do both?
DEMO
DEBUGGINGNATIVE AND JAVASCRIPT
Debugging Native and JavaScriptNo 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 DebuggingWindows 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 DebuggingConfigure the app to debug without launch in the project properties
F5 the app
Invoke your application manually through the contract
Background TasksYour 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 TasksTrigger 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 ProjectsThere 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 ProjectsUse the “Debug Installed App Package Feature”
Works both local and remote
Can automatically stop at the first line of JavaScript Code
AgendaDiagnostics 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 : [email protected]
ALM Team Blog: http://blogs.msdn.com/b/visualstudioalm
Uservoice site: http://visualstudio.uservoice.com
© 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.