Bug & Debug
If debugging is the process of removing bugs then programming must be the process of putting them in — Edsger W. Dijlstra
BUG
A bug is a general term used to describe any unexpected problem.
It may cause a program to unexpectedly quit or behave in an unintended manner. For example, a small bug may cause a button within a program’s interface not to respond when you click it. A more serious bug may cause the program to hang or crash due to an infinite calculation or memory leak.
Bugs can be syntax or logic errors within the source code of a program.
There are many types of bugs we can see in the programming. Some of them are –
Functional Errors
Compilation Errors
Missing commands
Run time Errors
Communication problems
Logical errors
Calculation issues
Control flow errors
What is the difference between an error and a bug?
An error is a message shown to the user of a program to let them know something went wrong. A bug is a problem in the code that caused the error.
Debug
For solving the problem or bug there is a way is called debugging.
Debugging is the process of detecting and removing of existing and potential errors (also called as ‘bugs’) in a code that can cause it to behave unexpectedly or crash. To prevent incorrect operation debugging is used to find and resolve bugs or defects.
Get Saidur Rahman Akash’s stories in your inbox
Join Medium for free to get updates from this writer.
To debug a program, user has to start with a problem, isolate the source code of the problem, and then fix it. A user of a program must know how to fix the problem as knowledge about problem analysis is expected. Debugging tools (called debuggers) are used to identify coding errors.
Programmers can trace the program execution step-by-step by evaluating the value of variables and stop the execution wherever required to get the value of variables or reset the program variables. Some programming language packages provide a debugger for checking the code for errors while it is being written at run time.
The process of debugging begins as soon as the code is written. Then, it continues in successive stages as code is combined with other units of programming.
Debugging has many benefits such as-
- It reports an error condition immediately. .
- It also provides maximum useful information of data structures and allows easy interpretation.
- Debugging assists to reducing useless and distracting information.
- Through debugging we can avoid complex one-use testing code to save time and energy in software development.
So, here’s some debugging process. By following this process the bug or error can be solved.
1. Identify the Error: A bad identification of an error can lead to wasted developing time. It is usual that production errors reported by users are hard to interpret and sometimes the information we receive is misleading. It is import to identify the actual error.
2. Find the Error Location: After identifying the error correctly, you need to go through the code to find the exact spot where the error is located. In this stage, you need to focus on finding the error instead of understanding it.
3. Analyze the Error: In the third step, you need to use a bottom-up approach from the error location and analyze the code. This helps you in understanding the error. Analyzing a bug has two main goals, such as checking around the error for other errors to be found, and to make sure about the risks of entering any collateral damage in the fix.
4. Prove the Analysis: Once you are done analyzing the original bug, you need to find a few more errors that may appear on the application. This step is about writing automated tests for these areas with the help of a test framework.
5. Cover Lateral Damage: In this stage, you need to create or gather all the unit tests for the code where you are going to make changes. Now, if you run these unit tests, they all should pass.
6. Fix & Validate: The final stage is the fix all the errors and run all the test scripts to check if they all pass.
Debugging Tools
Debugging tool is a computer program used to test and debug other programs. There are a lot of public domain software like gdb and dbx that you can use for debugging
Here is a list of some of the widely used debuggers-
Radare2
WinDbg
Valgrind







