37
msdevcon.ru #msdevcon

Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

Embed Size (px)

Citation preview

Page 1: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

msdevcon.ru #msdevcon

Page 2: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

ИЗ ПЕРВЫХ РУК:ДИАГНОСТИКА ПРИЛОЖЕНИЙС ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012MAXIM GOLDIN

Senior Developer, Microsoft

Page 3: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 4: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 5: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 6: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

Remote Debugger

Client Side Server Side

Visual Studio

msvsmon.exe

TCP/IP

YourApp.exe

TCP/IP

Page 7: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

Remote Debugger

Page 8: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 9: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 10: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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/

Page 11: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 12: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

IntelliTraceIn production

Page 13: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 14: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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…

Page 15: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 16: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

ProcDumpIn production

Page 17: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 18: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 19: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 20: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

FIRST CHANCE EXCEPTION

Page 21: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

First Chance Exception• Stop on Originate Error Exceptions for C++

• Use the memory window on the third parameter to decode the secret message

Page 22: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

Native/Managed Debugging for Store AppsRemote Debugging

Native Visualization

Reliable Stepping

Shipped in Update 1

Page 23: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

Mixed-languageI have options for “Native Only” and “Script Only” debugging.

What if I want to do both?

Page 24: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

DEBUGGINGNATIVE AND JAVASCRIPT

Page 25: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 26: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 27: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

CONTRACT DEBUGGING

Page 28: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

Contract DebuggingConfigure the app to debug without launch in the project properties

F5 the app

Invoke your application manually through the contract

Page 29: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 30: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

BACKGROUND TASK DEBUGGING

Page 31: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 32: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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!

Page 33: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

DEMO

NO PROJECT DEBUGGING

Page 34: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

No ProjectsUse the “Debug Installed App Package Feature”

Works both local and remote

Can automatically stop at the first line of JavaScript Code

Page 35: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

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

Page 36: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

More Info, Request Features

Maxim Goldin : [email protected]

ALM Team Blog: http://blogs.msdn.com/b/visualstudioalm

Uservoice site: http://visualstudio.uservoice.com

Page 37: Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer,

© 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.