“Everyone knows that debugging is twice as hard as writing a program in the first place. So if...

17

Transcript of “Everyone knows that debugging is twice as hard as writing a program in the first place. So if...

Page 1: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.
Page 2: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

3-677

Debugger Tips and Tricks for .NET Developers with Microsoft Visual Studio 2015

Andrew HallSenior Program [email protected]

Page 3: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?”

Brian Kernighan, Computer Scientist

“As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.” Sir Maurice Wilkes, Computer Scientist

Page 4: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

4 Slides of 4 new things

Demo (50 minutes)

Bonus Multi-Threading Tips

Agenda

Page 5: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

Diagnostic Tools window

http://blogs.msdn.com/b/visualstudioalm/archive/2015/01/16/diagnostic-tools-debugger-window-in-visual-studio-2015.aspx

Memory and CPU graphs Memory tooling Debugger break event history Output window content* IntelliTrace events*

*Enterprise SKU only

Page 6: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Quickly measure time between breaks• Excludes major debugger related overhead• Time stopped under the debugger (e.g. stopped at a breakpoint)• Symbol loading• Etc.

• Best suited for order of magnitude measurements• Greatest accuracy on CLR 4.6 and Windows 10

PerfTips

http://blogs.msdn.com/b/visualstudioalm/archive/2014/08/18/perftips-performance-information-at-a-glance-while-debugging-with-visual-studio.aspx

Page 7: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Inspect the live visual tree while debugging• Updates in real time• Jump to source

• Live property explorer• See any element’s properties in real time

•Selection by clicking on the app

UI Debugging Tools for XAML

http://blogs.msdn.com/b/visualstudio/archive/2015/02/24/introducing-the-ui-debugging-tools-for-xaml.aspx

Page 9: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Project Properties Launch Options• Start with Stepping,• Return Values• Set Next Statement• Step Into Specific• Run to Cursor• Edit and Continue• Step Out

DEMO #1

Page 10: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Debugger.IsAttached • Debugger.Break()• Visualizers (6)• Peek Definition (Alt + F12)• DebuggerDisplay• DataTips

• Transparency• Pinning• Floating• Comments

• Make Object ID• Add Watch From Watch

DEMO #2

Page 11: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Conditional Breakpoints• Hit Count Breakpoints• Lambda Debugging• Immediate Window• Debug -> Start New Instance• Multiple Project Launch• Restart• TracePoints• Edit Variable Value

DEMO #3

Page 12: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Exception Settings• Call Stack window

• Async• Show Parameter Values• Show External Code

• Full Screen mode• Tasks window

DEMO #4

Page 13: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• See the call stacks of all threads in a single window

Parallel Stacks window

https://msdn.microsoft.com/en-us/library/dd998398.aspx

Page 14: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• See all threads in the process• Switch between threads• Freeze/thaw threads

Threads window

https://msdn.microsoft.com/en-us/library/w15yf86f.aspx

Page 15: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Show threads in source• Run selected threads to cursor• Debug Location Toolbar• Filter breakpoint

Additional Multi-Threaded tips

https://msdn.microsoft.com/en-us/library/ms164746.aspx

Page 16: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

• Diagnostics Blog http://aka.ms/diagnosticsblog

• Other Sessions:• 3-731 Debugging Performance Issues Using Visual Studio 2015 • 3-771 Historical Debugging with IntelliTrace in Visual Studio 2015• 2-627 Strategies for Developing Cross-Platform Applications with Visual

Studio 2015 • 3-714 Building Cross-Platform Mobile Apps in C++ with Visual Studio

2015

Resources

Page 17: “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how.

© 2015 Microsoft Corporation. All rights reserved.