- Static debugging focuses on semantic analysis.
- In a certain program, suppose there are two variables: var1 and var2. The type of var1 is an integer, and the type of var2 is a float. Now, the program assigns the value of var2 to var1; then, there a possibility that it may not get correctly assigned to the variable due to truncation. This type of analysis falls under static debugging.
- Static debugging detects errors before the actual execution.
- Static code analysis may include detection of the following situations:
Dereferencing of variable before assigning a value to it
Truncation of value due to the wrong assignment
Redeclaration of variables
Presence of unreachable code
- Dynamic analysis is carried out during program execution. An interactive debugging system provides programmers with facilities that aid in testing and debugging programs interactively. A dynamic debugging system should provide the following facilities:
- Execution sequencing: It is nothing but observation and control of the flow of program execution. For example, the program may halted after a fixed number of instructions executed.
- Breakpoints: Breakpoints specify the position within a program till which the program gets executed without disturbance. Once the control reaches such a position, it allows the user to verify the contents of variables declared in the program.
- Conditional expressions: A debugger can include statements in a program to ensure that certain conditions reached in the program. These statements, known as assertions, can use to check whether some pre-condition or post-condition has met in the program during execution.
- Tracing monitors step by step the execution of all executable statements present in a program. The other name for this process is “step into”. Another possible variation is “step over” debugging that can execute at the level of procedure or function. This can implemented by adding a breakpoint at the last executable statement in a program.
- Traceback: This gives a user the chance to trace back over the functions, and the traceback utility uses stack data structure. Traceback utility should show the path by which the current state in the program reached.
- Program-display capabilities: While debugging in progress, the program being debugged must made visible on the screen along with the line numbers.
- Multilingual capability: The debugging system must also consider the language in which the debugging done. Generally, different programming languages involve different user environments and applications systems.
- Optimization: Sometimes, to make a program efficient, programmers may use an optimized code. Debugging of such statements can be tricky. However, to simplify the debugging process, a debugger may use an optimizing compiler that deals with the following issues:
Removing invariant expressions from a loop
Merging similar loops
Eliminating unnecessary statements
Removing branch instructions