VisualStudio Debugging Tools

VisualStudio Debugging Tools

As we know Visual Studio debugging plays a main role at the time of application development, so developers are always trying to find new tools for debugging. Here are some awesome tools for Visual Studio debugging which I find very helpful at the time of development. So I want to share all these tools among us all.In this article I will cover the following topics:

    • What is the use of Symbols (.pdb) file?
    • What is the use of .Net SourceServer?
    • Threads debugging tool.
    • Thread window
    • Parallel stack windows for thread debugging.
    • Finding Threads.

Let’s starts with Symbol file,

In .NET symbols are auxiliary metadata of our code.

What is auxiliary metadata?

It is a collection of different symbols; and those symbols are used by the Visual studio debugger to fetch all the required data.

This file can be created by CLR when we build the project, once the project is build we can see that file inside projectsolution under bin->debug folder.

There we find different type of file as given bellow:

different type of file

In the above fig I have marked one file that is the symbol file.and file extensions of this file is .pdb.

.pdb stand for Program debug database file.

This file contails all the information about the debugging i.e line number, symbols used for step in , step out and many more. All this information is stored inside in the form of binary data.

The main purpose of pdb file is to store all the information about the debugging process.
This is all aboutpdb file and uses now let’s move to the next;

Source server and its uses

Before going into this topic more deeply let me ask you one question: Is it possible to debug .net framework code using Visual studio?

What are you thinking?

Maybe or maybe not, if we think logically we may answer no because to debug anything we require the source code must be present in localmachines or remote machine,so in the case of .net framework code debug we don’t have such a file in our machines, only we have dll so the answer is no.

But we can!

Yes, this is possible through using Source server feature given in VS.

Source server is basically a server provided by Microsoft , it contains all the symbolic instruction to debug .net frame work code.

The Source server allows us to debug the .net frame work code in VS , using this we can step in to any core method of .net frame work.

How to enable source sever in Visual Studio ?

Step 1: Go to the debug menu and click their option-setting.

option-setting

Step 2: Then it will open new windows where we need to checked “Enable .Net source stepping” and “Enable source server”.

Enable source server

Step 3: After doing this we need to select “Symbols” option and there we need to give the new location inside the symbol file location, this is the main important thing to specify the location because from that location VS read the pdb file for .net framework to debug.

To give a new location follow the below steps:

Step 1:
First select Symbols option then Click on the button arrow mark below to add new location,

select Symbols option

Step 2: Specify the location and then click ok.

Now what is going to happen is that visual studio reads all the .net frame work symbol file from that location.

Note: To work above settings you must connected to the INTERNE , because now your VS connects with the Microsoft .Net framework source server and reads all the symbols from there.

Warning: After doing this setting, when you execute any of your applications VS takes some time depending upon your internet connection type and it loads all the symbol files from server so you need to wait for that.

Once it has loaded all the symbols then we can go step into for .net framework code.

This is all about your .net Framework code debugging process.

Now let’s move Thread debugging tool in Visualstudio:

This is a very useful tool while we are working with multiple threads.

To see all the threads currently executing we have a thread window in debug menu.

Thread window provides lots of information about the thread .

To see all the information about the thread we need to execute any thread program.

For our understanding purposes I created a windows form application and implement the thread as bellow:

Created a simple window form and place a button inside it as below:

window form

Under button click event I write the following code:-

private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 30; i++){
Thread th = new Thread(delegate(){
lock(this)
Thread.Sleep(1000);
});
th.Start();
}}

Then I start my application and click on the button, create thread, and leave the application in running mode and come to Visual Studio and inside Visual Studio I click on the break all option from the debug menu then to see all the thread information I click on thread window as given below:

thread information

Then click thread window:

click thread window

Then we see all the information about thread which have started ;for my apps below is the thread window figure.

thread

Now to see all this thread more clearly we need to move to our next topic i.e, parallel stack window for thread.

The parallel stack window for thread is used to give a more clear picture of thread with Diagram.

To open parallel stack window we need to do the same process. What we do above i.e start our windows from apps then click on the button , next click on break all option then go to window and click on parallel stack windows as given bellow:

parallel stack

Then you get a visualization window for all the threads, whichever is currently running for my example, below is the figure,

class diagram

To finding the specific thread we can use the thread name or thread id from the thread window, also thread window allows us to rename the thread name.

This is all about thread debugging tools which is very useful; for multithreading application, try this feature.

Hope this might be helpful to you.

If anything did not work as described in this article feel free to reply to me.

Your suggestions help me to improve myself.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s