Debugging a Machine-level Program
The process of debugging is performed to find and remove the bugs from the program or software. In this process, errors will be identified in the execution, machine codes, and program logic. Here the fault in a program is identified with the help of step-by-step information related to the execution of code.
Debugging a Machine code
Building a circuit with the help of a schematic diagram and translation of assembly language into machine code both are the same things. With the help of debugging, we are able to determine the following things:
There are some common sources of error, which are described as follows:
There are basically two parts in which debugging process is divided, which are described as follows:
This debugging is the same as visual inspection of a circuit board. In this debugging, we just take a paper and pencil and try to find the bug in the machine code and flowchart. It is very difficult to catch some code bugs with the help of static debugging. Here we just try to understand the structure and code logic of the program so that we can find the bugs and remove them.
In the elaborated circumstances, the bugs randomly pop up. The bugs mostly pop up in the case of reusing and expanding the code. When a bug manifests itself, we try to reproduce the issue with the help of walking through the test case and trying a debug session. Sometimes our luck is very good, and we just easily reproduce the problem. Suppose we want to determine a certain combination so that we can trigger the domain effect due to that the bugs reveal themselves. In this case, the process can take hours or even days of effort. With the help of static debugging, we are able to find out the problem areas more quickly and proactively.
In this debugging, we observe the data of register or output after the execution of each instruction with the help of a single-step technique or after the execution of a group of instructions with the help of the breakpoint technique. The tools and techniques of single-board microprocessor commonly used the dynamic debugging. These tools and techniques are described as follows:
1. Single Step:
In this technique, we can only execute a single instruction at a time. Here we basically observe the output of each instruction. With the help of hardwired logic circuit, this technique is built. We will observe the data of memory location and register only when we press the key of a single-step run. Due to this key, we will be able to spot the following things:
In case of the large loop, this type of debugging is very time-consuming and tiring. So we can check the effectiveness of a loop by decreasing the number of iteration in place of ruing the loop n times. For the short program, the very useful technique is the single-step technique.
The software routine and breakpoint facility are similar to each other. Because of the breakpoint, we are able to execute a program in sections. With the help of RST instruction, the breakpoints can be set. After pressing the execute key, the program will be executed till the breakpoint. The expected result can be examined with the help of registers. Suppose we isolate the segment of a program with errors with the help of a breakpoint facility. After that, we can use the single-step facility to debug that segment. It can be used to check the following things:
The dynamic breakpoints are user-specific. When our program is reached at an exception class or particular statement, at that time, the breakpoint will be triggered. When the user logs off, then the breakpoint will be automatically deleted. We are able to set a total 30 dynamic breakpoints without changing the source code. This breakpoint can be created, deleted, or deactivated at the runtime. If there is a case in which the program is locked by some other user, we can even set the dynamic breakpoint for that program.
3. Register Examine:
With the help of a register examine key, we are able to examine the content of a microprocessor register. We can use this technique in conjunction with a breakdown facility or single-step facility.