Detailed SylixOS debugging method (2) - SylixOS code coverage check

1. SylixOS debugging method introduction

SylixOS implements a powerful debugging stub, which can debug the application online on the device or simulator, and RealEvo-IDE also provides a matching debugging plug-in. Currently, RealEvo-IDE supports both automatic push debugging and the traditional debugging method of manually starting gdbserver. Several debugging methods that are very practical in daily development are not described in detail in the official manual. We create several new app projects to make corresponding demonstrations, mainly including code static analysis, code coverage inspection, performance analysis and A demonstration of a practical case series. This article mainly introduces code coverage inspection and debugging.

2. Detailed explanation of SylixOS debugging steps

The code coverage check is mainly used to prevent redundant code. By creating a "coverage_check_app" to demonstrate the code coverage check, the program listing is shown in program listing 2‑1.

Program listing 2‑1 static_check_app listing

#include <stdio.h>

void test()

{

   printf("Hello SylixOS!\n");

}

 

int main (int argc, char **argv)

{

    printf("Hello SylixOS!\n");

 

    return  (0);

}

 

 

       The demo program used is compiled without error, and can be uploaded successfully. The program compilation result is shown in Figure 2-1. No errors are found during the compilation process, but the code itself has redundancy. Usually, when the amount of code is relatively small, this phenomenon can be reduced by manual inspection, thereby improving the code quality. However, when the amount of code is relatively large and there are many code writers, this situation cannot be avoided, which will affect the project cycle, The quality of the project has a relatively large impact, and it will also increase the workload of the testers. These are not conducive to the improvement of project development and work efficiency.

    

Figure 2-1 Compilation result

In this case, this type of development problem can be solved by the code coverage checking tool that comes with RealEvo-IDE.

After compiling and uploading, open RealEvo-Simulator, open the corresponding architecture platform, and run the demo program, as shown in Figure 2‑2.

Figure 2‑2 Run coverage_check_app

 

Select the project to be debugged, select the "coverage_check_app" project here, right-click the project and select "Properties", click "SylixOS Project", select "Compiler Setting", and check "Enable govc(Code coverage analysis)", as shown in Figure 2‑3 shown.

Figure 2-3 Setting up debugging tools

       Select the project to be debugged, select the "coverage_check_app" project here, right-click the project and select "SylixOS Coverage Analysis", click "Get Coverage Rate File", the operation is shown in Figure 2-4.

Figure 2-4 Operation steps

 

 

 

  The file is successfully grabbed, as shown in Figure 2‑5.

Figure 2-5 Capture successfully

 

If the program is not run, the file cannot be successfully captured, as shown in Figure 2‑6.

Figure 2-6 Failed to fetch

 

After the capture is completed, select the project to be debugged, select the "coverage_check_app" project here, right-click the project and select "SylixOS Coverage Analysis", and click "Show Coverage Rate", as shown in Figure 2‑7.

Figure 2-7 Perform coverage analysis

 

The running result is shown in Figure 2‑8. The code exists in the same phenomenon, which can be optimized by analyzing the code to reduce this situation and improve the code quality.

Figure 2-8 Redundancy Check

 

3. Summary

In SylixOS, you can use a variety of debugging methods for related debugging, and debug the program according to the actual situation. This section mainly introduces the specific debugging methods of code coverage checking. The next section will introduce performance analysis and debugging in detail.

4. References

"SylixOS Application Development Manual"

"RealEvo-IDE User Manual"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325943068&siteId=291194637