GST Billing Software

header image


Erachana Line

Debugging is the process of detecting and removing of existing and potential errors (also called as 'bugs') in a software code that can cause it to behave unexpectedly or crash. To prevent incorrect operation of a software or system, debugging is used to find and resolve bugs or defects. When various subsystems or modules are tightly coupled, debugging becomes harder as any change in one module may cause more bugs to appear in another. Sometimes it takes more time to debug a program than to code it.

Start the debugger

Press F5 (Debug > Start Debugging) or click on the Start Debugging button in the Debug Toolbar.

F5 starts the application with the debugger attached to the respective application process.

Set a breakpoint and start the debugger

A red circle appears where you set the breakpoint. A breakpoint indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behaviour of memory, or whether or not a branch of code is getting run.

The yellow arrow represents the statement on which the debugger paused, which also suspends application execution at the same point (this statement has not yet executed). If the application is not yet running, F5 starts the debugger and stops at the first breakpoint. Otherwise, F5 continues running the application to the next breakpoint.

Navigate code in the debugger using step commands

Press F11 (or choose Debug > Step Into ). F11 is the Step Into command and advances the application execution one statement at a time. F11 is a good way to examine the execution flow in the most detail.

Step out

If you want to get the control out of the function but stay in the debugger. You can do this using the Step Out command.

Press Shift + F11 (or Debug > Step Out).

This command resumes application execution (and advances the debugger) until the current function returns.

Set a watch

In the main code editor window, right-click the shapes object and choose Add Watch.

The Watch window opens at the bottom of the code editor. You can use a Watch window to specify a variable (or an expression) that you want to keep an eye on (whose values will be changing in the Runtime).

Now, you have a watch set on the shapes object, and you can see its value change as you move through the debugger. Unlike the other variable windows, the Watch window always shows the variables that you are watching.

Examine the call stack

While paused in the foreach loop, click the Call Stack window, which is by default open in the lower right pane.

Click F11 a few times until you see the debugger pause in the required method in the code editor. Look at the Call Stack window.

The Call Stack window shows the order in which methods and functions are getting called. The top line shows the current function (the Circle.Draw or Circle::Draw method in the application). The second line shows that Circle.Draw was called from the Main method and so on.

By using the Call Stack window, you can view the function or procedure calls that are currently on the stack. The Call Stack window shows the order in which methods and functions are getting called.