Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Diving Into Visual Studio 2015: Debugging Improvements (Diagnostic Tool Window)

DZone's Guide to

Diving Into Visual Studio 2015: Debugging Improvements (Diagnostic Tool Window)

In this article, we'll cover the Diagnostic Tools Window feature in Visual Studio 2015. We'll talk about how itcan help you to debug your code and monitor CPU & memory usage too.

· Web Dev Zone
Free Resource

Make the transition to Node.js if you are a Java, PHP, Rails or .NET developer with these resources to help jumpstart your Node.js knowledge plus pick up some development tips.  Brought to you in partnership with IBM.

Introduction

The earlier parts of this series talked about Visual Studio 2015 improvements and enhancements. This article on Visual Studio 2015 will cover another interesting feature of Visual Studio 2015; i.e., Diagnostic Tool Window. We’ll have a glance over the new Diagnostic Window and try to cover the topic with practical examples, thus exploring how this diagnostic tool window has helped in debugging and monitoring.

You can learn more in the previous parts:

Diagnostic Tool Window

The new Diagnostic Tools Window in Visual Studio appears whenever you run the application with debugging.

This Window provides an ample amount of information, which is very helpful when debugging the application. It contains a timeline across the top, that provides a temporal display of the application’s debugging session.

Diagnostic Tool Window
The Diagnostic Tool Window can be launched via Debug-> Show Diagnostic Tools option, as shown in the image, below:


Show Diagnostic Tools option










Under the timeline are three important views.

  • The debugger events view displays break point, output and IntelliTrace events.
    Debugger Events view
  • The Memory view displays the processor or memory usage in bytes.
    Memory view displays
  • The CPU utilization view displays the percent of the CPU usage. CPU utilization

At the bottom of the Diagnostic Tools Window are the tabs with additional details and options. The Yellow arrow at the bottom shows the code being debugged is currently at a breakpoint. 


Diagnostic Tools
This article will cover the different views of Diagnostic Tool Window, one by one. We’ll use the existing code base as a sample to explore the features. Place the breakpoints at two locations, as shown below. The existing Program.cs file that we have been using throughout the prior articles states:

Program
Now run the Application and wait for the execution to pause at a break point. Now, open the Diagnostic tools or press Ctrl+Alt+F2. You get the following view of Diagnostic Tool Window:

run the application
TimeLine

The example of debugging session was 0.19 seconds in length, from the time of the application's start until the current break point and we are looking at about 5.5 seconds of that time, here in the timeline. The black bars here allow you to select a portion of the timeline.

TimeLine
The selected time interval, shown in White, is the area of the timeline that you want to focus on. Drag either Black bar to adjust the selection area. The other sections of this Window adjust based on the location of the Black bars. Since our selected area includes part of a Red line in the break point track, the list also displays the end of that break point line. 


Events
Debugger Events

The debugger events view in the Diagnostic Tools Window displays the events that occurred during the debugging session. This view is broken into the tracks. The break events track shows the events which stopped the execution of the Application, such as breakpoints that were hit, stepping through the code or breaking exceptions. The bars indicate the amount of time the application was running in between the break events. The bars in this track are color coded as Red indicates a break point or breaking exception. Yellow indicates a step through the code and Blue indicates a break on operation. 

Debugger Events
The Blue bar indicates the time from the last break point, until the time that debugging session was paused, using the Break All feature.

Break All feature
Hover over a bar to view the elapsed time. 

The IntelliTrace track shows all other events collected by IntelliTrace, such as ADO.NET calls, file access and so on. It is also color coded, as Black is used for important events, Gray for less important events, and Purple for the custom events.

Process Memory

The Process memory section of the Diagnostic Tools Window helps you to monitor the memory usage of the app while you are debugging. A memory usage tool was introduced in Visual Studio 2013 as a part of the performance and diagnostics hub. In Visual Studio 2015, this tool was merged into the Diagnostic Tools Window and enhanced. With the current memory usage tool, you can take a memory snapshot at any point of time and compare it against another snapshot.

Process Memory
In this sample debugging session, you can see there is one snapshot. 


debugging session
Using the memory usage tool helps you to analyze the cause of memory spikes or leaks. You can also view the heap information through memory usage Window.


Heap information

CPU

The CPU utilization section of the Diagnostic Tools Window helps you to monitor the CPU usage of your Application, by viewing a live CPU graph.

CPU
This graph shows you how many CPU resources are used by the code. Looking at the CPU usage with the debugger events helps you to correlate spikes in CPU with the execution of the code, making it easier to debug CPU-related issues.

You can switch on CPU profiling for more detailed CPU usage statistics.

CPU profiling
You can use the Diagnostic Tools Window that comes to aid in your debugging process, and improves productivity and performance.

Conclusion

In this article, we covered a very useful and critical feature of Visual Studio 2015 called Diagnostic Tools Window. We saw how the Diagnostic Tool Window can help you to debug your code and monitor CPU & memory usage too.

Learn why developers are gravitating towards Node and its ability to retain and leverage the skills of JavaScript developers and the ability to deliver projects faster than other languages can.  Brought to you in partnership with IBM.

Topics:
visual studio ,visual studio 2015 ,debugging

Published at DZone with permission of Akhil Mittal. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}