Debugging your Way through .NET with Visual Studio 2015

Preview:

Citation preview

Debugging Your Way through .NET with Visual

Studio 2015Ido Flatow

Senior ArchitectMicrosoft MVP & RD

Sela Group

A Slide on Debugging

Start with the Basics?

Debug Windows (1)• Data Tips

• Locals / Auto

Debug Windows (2)• Quick Watch

• Watch

Debug Windows (3)• Call Stack

• Immediate

VISUAL STUDIO 2015 NEW DEBUGGING FEATURES

Breakpoint Settings Window• Two new icons appear with breakpoint

• Settings opens a Peek window

Lambda in Debug Windows• Watch & Immediate window support

lambda expressions• Rebuilt on top of the “Roslyn” compilers

PerfTips• Performance Information at-a-glance • Excludes major debugger related overhead

– Time stopped under debugger– Symbol loading

• Suitable for order of magnitude measurements

Diagnostics Tool Window• Just hit F5• Memory and CPU usage graphs• IntelliTrace UI is now part of the

window• Take memory snapshots and

profile CPU usage• Time sections of code with

PerfTips

Diagnostics Tool WindowCPU Usage

• Shows CPU utilization across all cores• Turn on CPU profiling while debugging to

get usage breakdown by function• Available after debugging

session has stopped

Diagnostics Tool Window Memory Usage• Monitors memory usage of your app• Can show native and managed heaps• Take snapshots of your memory• Ignores time spent in breakpoints• Informs you when GC was activated and why

Diagnostics Tool Window Memory Usage – Cntd.• Use memory snapshots to inspect the heap and to find memory leaks

– Watch which objects were added, and their size– Track object paths to its root

DEMOVisual Studio 2015 Debug Features

DIAGNOSTICS HUBPROFILERS

The Unified Diagnostics Hub• Shipped with VS 2013 (update 2)• Pick a target and choose the tools that work best• Runs without a debugger attached• Windows Desktop, Store, UWP. No ASP.NET

What’s on the Hub?• Breakdown of the UI thread performance• Windows desktop, Windows Store, UWPApplication Timeline

• HTTP usage and performance• UWP onlyNetwork Usage

• Which code uses the most CPU• Any managed code, except ASP.NETCPU Usage

• How the application makes use of the GPU• Windows desktop, Windows Store, UWPGPU Usage

• Monitor memory usage, and take snapshots• Any managed code, except ASP.NETMemory Usage

VS 2

015

VS 2

013

Diagnostic Hub Profilers

YE OLDE PROFILERS

Who Moved my Profilers?• Under the Analyze menu in VS 2010• Gone into hiding in VS 2013• Still in hiding in VS 2015

The Visual Studio Profilers• Same good old profilers• Can run as stand-alone from the command-line

Sampling• CPU-bound apps, very low overhead• Full program stacks (including all system DLLs)

Instrumentation• I/O-bound apps, CPU-bound apps, higher overhead• More detailed timing data, limited stacks (just my code)

Allocations• Details on who allocated and what• Managed code only

Concurrency Visualizer• Analyze the application’s

concurrency characteristics– CPU utilization– Thread blocking and migration– Resource contention

• Downloadable as a Visual Studio Extension

http://bit.ly/2a5kbay

DEMOThe good old profilers

DEBUGGING ASYNC CODE

Parallel Watch• Simultaneously display the value an

expression holds on multiple threads

Parallel Tasks• Tasks can be grouped/ungrouped• Hierarchical view of parent-child relationships

Simple Flat view

Group by status

Parent Child view

Parallel Stacks• Visualizes multiple call stacks (works for tasks

and threads)

Synchronized

DEMODebugging Async Code

Resources• Visual Studio blogs

– https://blogs.msdn.microsoft.com/visualstudio– https://blogs.msdn.microsoft.com/visualstudioalm

• Suggestions and vote– http://visualstudio.uservoice.com

• Articles– http://bit.ly/29mIJfu (async debug)– http://bit.ly/29tuj08 (concurrency visualizer)– http://bit.ly/1IZOds9 (diagnostic tools)

• Videos– http://bit.ly/1MGWMuB – http://bit.ly/1Le96gs

• My Info– idof@sela.co.il // @idoflatow // http://www.idoflatow.net/downloads

Thanks!Questions?

Recommended