1. Isolate key elementsJust like the primary school biology class, the study of sunlight on plant growth, the need to keep nutrients, irrigation, growth temperature and so on exactly the same, a sun exposure, a no sun exposure, so as to compare the effect of sunlight on plant production. This is also true for bug lookups, when looking for a function with multiple parameters , fixing other parameters, modifying the input value of a parameter, verifying that the output is correct, and determining which parameter caused the calculation error and determining the bug.
2. Change one Test at a timeSoftware engineers sometimes modify a place in order to fix a problem, but this modification does not solve the problem, and he believes that it will not have an impact, this is a false hypothesis, this change may indeed affect the resolution of the problem, so there is no problem to resolve the changes to recover in time. Otherwise, unexpected errors can occur. Change only one parameter at a time to determine which parameter has an effect! And the first one to complement each other! Hardware is similar, if you change more than one device at the same time, you can not determine exactly which device caused the system problems, but also to replace only one at a time, the test verifies that there is no problem and then replace the next!
3, compared with the normal situationUsing two examples, a successful, a failed, comparison of the oscilloscope's observations, code, debug output, and any other pile tool display results, often easier to find bug! If there are many differences between the two, such as the code changes a lot, you must constantly explain these differences, and constantly reduce the difference between them until only related to the bug. Because you do not know which aspects are related to the bug, you should test everything that can be tested and remove it from the debug log if it proves irrelevant. A lot of data comparison find, this is not very easy to do, neither for beginners, nor for software automation analysis, need a brain full of wisdom, from a large number of comparative data, quickly find the difference. Case: Previous project, design a standalone download programmer, before the company used by the PC on the download software provided by the manufacturer through the serial port to download, but can not meet the installation site upgrade maintenance needs. Through monitoring and control to obtain the communication command code and format, after the program to download the programmer can work, but always perform the download after a period of time, the download failed, so I sent the download serial data and the host computer software sent to the serial port byte comparison, found that the host computer software some packet length will change, A careful comparison of the content found in the communication protocol in order to prevent the contents of the byte and the Communication command code starting byte conflict, the substitution processing, even if the content with two bytes of different content with the command code in the same byte content. Download the programmer with the same operation, the download process no longer error!
4, confirm the last time since the normal change of your placeSometimes, the difference between a normal system and a wrong system is caused by a change, so a very effective way is to find the first version that causes the bug, which needs to be tested continuously until a bug-free version is found, and once it is found, the problem can be limited to the difference between the two versions. If two versions are not drastically modified, bugs are often easier to find. Usually the new design will be problematic, which is the reason we always have to test the new design before the release of the product, some may be incompatible (such as the distribution sequence of the tooling probe, spacing changes), but also more complex, that is, the problem exists for a long time, the knowledge of the place has been changed before exposed Case: In a 32-bit system, such as a 8-bit pointer to a 32-bit pointer cast, if the previous version of the software compiled with 8-bit pointer address 4-byte alignment, then the assignment conversion will not be problematic, the operation is normal; when the software is modified and recompiled, the address of the 8-bit pointer is not 4-byte aligned Then there will be data confusion and even crashes, watchdog reset and other issues. This kind of problem, only compares the code modification place, when does not see the problem, needs to consider the influence of the code modification comprehensively, besides the code logic, the function influence, but also has the compilation influence, the code layout influence and so on.
Hardware and Software debugging nine method: Fifth rule change only one place at a time