Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Support of MISRA C++ Analyzer for Reliability of Embedded Systems

Published: 22 January 2025 Publication History

Abstract

Cyber-Physical Systems (CPS) are increasingly used in many complex applications, such as autonomous delivery drones, the automotive CPS design, power grid control systems, and medical robotics. However, existing programming languages lack certain design patterns for CPS designs, including temporal semantics and concurrency models. Future research directions may involve programming language extensions to support CPS designs. However, JSF++, MISRA, and MISRA C++ are providing specifications intended to increase the reliability of safety-critical systems. This article also describes the development of rule checkers based on the MISRA C++ specification using the Clang open-source tool, which allows for the annotation of code and the easy extension of the MISRA C++ specification to other programming languages and systems. This is potentially useful for future CPS language research extensions to work with reliability software specifications using the Clang tool. Experiments were performed using key C++ benchmarks to validate our method in comparison with the well-known Coverity commercial tool. We illustrate key rules related to class, inheritance, template, overloading, and exception handling. Open-source benchmarks that violate the rules detected by our checkers are also illustrated. A random graph generator is further used to generate diamond case with multiple inheritance test data for our software validations. The experimental results demonstrate that our method can provide information that is more detailed than that obtained using Coverity for nine open-source C++ benchmarks. Since the Clang tool is widely used, it will further allow developers to annotate their own extensions.

A Appendix

Listing 21 gives the program generated for Figure 5. The class names correspond to the node numbers in the graph. The node numbers in Figure 5 are converted to characters. The node 0 is converted to A and the node 1 is converted to B, and so on. There are randomly generated variables inside these generated classes, for the generality of the programs. We can see that there are three virtual inheritances inside the program. Two of them are within the diamond structure formatted by D, G, N, and I classes, which correspond to nodes 3, 6, 13, and 8. We generated programs for the graph to be used as the validation test suites for the diamond case.
Listing 21.
Listing 21. C++ programs generated from the graph in Figure 5.
Table 7.
Required
Rule 0-1-3Rule 0-1-4Rule 0-1-5Rule 0-1-7Rule 0-1-10Rule 0-1-11Rule 0-1-12Rule 2-3-1Rule 2-7-1Rule 2-7-2
Rule 2-10-3Rule 2-10-4Rule 2-10-6Rule 2-13-1Rule 2-13-2Rule 2-13-4Rule 2-13-5Rule 3-1-2Rule 3-1-3Rule 3-2-1
Rule 3-3-2Rule 3-9-1Rule 3-9-3Rule 4-5-1Rule 4-5-2Rule 4-5-3Rule 4-10-1Rule 4-10-2Rule 5-0-3Rule 5-0-5
Rule 5-0-6Rule 5-0-7Rule 5-0-8Rule 5-0-9Rule 5-0-10Rule 5-0-11Rule 5-0-12Rule 5-0-13Rule 5-0-14Rule 5-0-15
Rule 5-0-19Rule 5-0-20Rule 5-0-21Rule 5-2-4Rule 5-2-5Rule 5-2-6Rule 5-2-8Rule 5-2-11Rule 5-2-12Rule 5-3-1
Rule 5-3-2Rule 5-3-3Rule 5-3-4Rule 5-14-1Rule 5-18-1Rule 6-2-2Rule 6-2-3Rule 6-3-1Rule 6-4-1Rule 6-4-2
Rule 6-4-3Rule 6-4-4Rule 6-4-5Rule 6-4-6Rule 6-4-7Rule 6-4-8Rule 6-5-2Rule 6-5-3Rule 6-5-4Rule 6-5-6
Rule 6-6-1Rule 6-6-2Rule 6-6-4Rule 6-6-5Rule 7-1-2Rule 7-2-1Rule 7-3-1Rule 7-3-2Rule 7-3-3Rule 7-3-4
Rule 7-3-5Rule 7-3-6Rule 7-4-2Rule 7-4-3Rule 7-5-1Rule 7-5-3Rule 8-0-1Rule 8-3-1Rule 8-4-1Rule 8-4-2
Rule 8-4-3Rule 8-4-4Rule 8-5-1Rule 8-5-2Rule 8-5-3Rule 9-3-1Rule 9-3-2Rule 9-3-3Rule 9-5-1Rule 9-6-2
Rule 9-6-3Rule 9-6-4Rule 10-1-2Rule 10-1-3Rule 10-3-1Rule 10-3-2Rule 10-3-3Rule 11-0-1Rule 12-1-1Rule 12-1-3
Rule 12-8-1Rule 12-8-2Rule 14-5-2Rule 14-5-3Rule 14-6-1Rule 14-6-2Rule 14-7-1Rule 14-7-3Rule 14-8-1Rule 15-0-3
Rule 15-1-1Rule 15-1-2Rule 15-5-3Rule 16-0-1Rule 16-0-2Rule 16-0-3Rule 16-0-4Rule 16-0-5Rule 16-0-7Rule 16-0-8
Rule 16-1-2Rule 16-2-1Rule 16-3-1Rule 17-0-5Rule 18-0-1Rule 18-0-2Rule 18-0-3Rule 18-0-4Rule 18-0-5Rule 18-2-1
Rule 18-4-1Rule 19-3-1Rule 27-0-1       
Advisory
Rule 2-5-1Rule 2-10-5Rule 3-9-2Rule 5-0-2Rule 5-2-3Rule 5-2-9Rule 5-2-10Rule 5-19-1Rule 10-1-1Rule 10-2-1
Rule 12-1-2Rule 14-8-2Rule 15-0-2Rule 15-3-2Rule 16-3-2     
Table 7. Table of 158 Implementation Rules

References

[1]
Ali Almossawi, Kelvin Lim, and Tanmay Sinha. 2006. Analysis tool evaluation: Coverity prevent. Carnegie Mellon University, Pittsburgh, PA, 7–11. Retrieved from https://www.cs.cmu.edu/aldrich/courses/654-sp07/tools/cure-coverity-06.pdf
[2]
Pascal Bertschi and Andreas Deicha. 2018. Safe C++ Guidelines Checkers und Quick Fixes. Ph. D. Dissertation. HSR Hochschule für Technik Rapperswil.
[3]
Po-Yao Chang, Tai-Liang Chen, and Jenq-Kuen Lee. 2021. Enabling the use of C++ 20 unseq execution policy for OpenCL. In Proceedings of the International Workshop on OpenCL. 1–2.
[4]
Peng-Sheng Chen, Yuan-Shin Hwang, Roy Dz-Ching Ju, and Jenq-Kuen Lee. 2004. Interprocedural probabilistic pointer analysis. IEEE Trans. Parallel Distrib. Syst. 15 (Oct. 2004), 893–907. Issue 10.
[5]
Clang 2008. scan-build. Clang, Retrieved from https://clang-analyzer.llvm.org/scan-build.html
[6]
Clang 2020. Android Auto Framework. Clang. Retrieved from https://www.android.com/auto/
[7]
Clang 2020. Clang-Tidy. Clang. Retrieved from https://clang.llvm.org/extra/clang-tidy/
[8]
Clang 2020. GENEVI Framework. Clang. Retrieved from https://www.genivi.org/
[9]
Daniel Cordeiro, Grégory Mounié, Swann Perarnau, Denis Trystram, Jean-Marc Vincent, and Frédéric Wagner. 2010. Random graph generation for scheduling simulations. In Proceedings of the 3rd International ICST Conference on Simulation Tools and Techniques (SIMUTools’10). ICST, 10.
[10]
Chris Cox. 2018. CppPerformanceBenchmarks-Release5. Retrieved from https://gitlab.com/chriscox/CppPerformanceBenchmarks
[11]
H. Carter Edwards, Christian R. Trott, and Daniel Sunderland. 2014. Kokkos: Enabling manycore performance portability through polymorphic memory access patterns. J. Parallel Distrib. Comput. 74, 12 (2014), 3202–3216.
[12]
Google 2016. Google Test. Google. Retrieved from https://github.com/google/googletest
[13]
Google 2017. Google Logging Library. Google. Retrieved from https://github.com/google/glog
[14]
Hervé Guihot. 2012. RenderScript. In Pro Android Apps Performance Optimization. Springer, 231–263.
[15]
Ming-Yu Hung, Peng-Sheng Chen, Yuan-Shin Hwang, Roy Dz-Ching Ju, and Jenq-Kuen Lee. 2012. Support of probabilistic pointer analysis in the SSA Form. IEEE Trans. Parallel Distrib. Syst. 23 (Dec. 2012), 23661–2379. Issue 12.
[16]
Daniel Kästner, Christoph Cullmann, Gernot Gebhard, Sebastian Hahn, Thomas Karos, Laurent Mauborgne, Stephan Wilhelm, and Christian Ferdinand. 2020. Safety-critical software development in C++. In Proceedings of the International Conference on Computer Safety, Reliability, and Security. Springer, 98–110.
[17]
Ullrich Koethe. 2017. VIGRA Computer Vision Library. Retrieved from https://github.com/zeromq/libzmq
[18]
Ted Kremenek. 2008. Finding software bugs with the clang static analyzer. Apple Inc.
[19]
Chris Lattner. 2008. LLVM and clang: Next generation compiler technology. In Proceedings of the BSD Conference, Vol. 5.
[20]
Jenq Kuen Lee and Dennis Gannon. 1991. Object oriented parallel programming: Experiments and results. In Proceedings of the ACM/IEEE Conference on Supercomputing (Supercomputing’91). IEEE, 273–282.
[21]
Cheng-Yen Lin, Chung-Wen Huang, Chi-Bang Kuan, Shi-Yu Huang, and Jenq-Kuen Lee. 2015. The design and experiments of A SID-based power-aware simulator for embedded multicore systems. ACM Trans. Design Autom. Electr. Syst. 20, 2 (2015), 1–27.
[22]
Yu-Te Lin and Jenq-Kuen Lee. 2016. Vector data flow analysis for SIMD optimizations on OpenCL programs. Concurr. Comput.: Pract. Exp. 28, 5 (2016), 1629–1654.
[23]
Yang Liu, Yu Peng, Bailing Wang, Sirui Yao, and Zihe Liu. 2017. Review on cyber-physical systems. IEEE/CAA J. Autom. Sinica 4, 1 (2017), 27–40.
[24]
MISRA 2020. MISRA C:2012 Amendment 2. MISRA. Retrieved from https://www.misra.org.uk/Publications/tabid/57/Default.aspx
[25]
Jason Sanders and Edward Kandrot. 2010. CUDA by Example: An Introduction to General-purpose GPU Programming. Addison-Wesley Professional.
[26]
Sass. 2018. LibSass—Sass Compiler Written in C++. Sass. Retrieved from https://github.com/sass/libsass
[27]
Wen-Li Shih, Yi-Ping You, Chung-Wen Huang, and Jenq Kuen Lee. 2014. Compiler optimization for reducing leakage power in multithread bsp programs. ACM Trans. Design Autom. Electr. Syst. 20, 1 (2014), 1–34.
[28]
Sourcey 2018. LibSourcey. Sourcey. Retrieved from https://github.com/sourcey/libsourcey
[29]
Bjarne Stroustrup, K. Carroll, and L. Aero. 2006. C++ in safety-critical applications: The JSF++ coding standard. https://www.phaedsys.com/principals/programmingresearch/prdata/SSE-Session-4_Stroustrup-Carroll.pdf
[30]
Yulei Sui and Jingling Xue. 2016. SVF: Interprocedural static value-flow analysis in LLVM. In Proceedings of the 25th International Conference on Compiler Construction (CC’16). ACM, 265–266.
[31]
Y. Sui, D. Ye, and J. Xue. 2014. Detecting memory leaks statically with full-sparse value-flow analysis. IEEE Trans. Softw. Eng. 40, 2 (Feb. 2014), 107–122.
[32]
Chris Tapp. 2008. An introduction to MISRA C++. SAE Int. J. Passeng. Cars—Electron. Electr. Syst. 1 (Apr. 2008), 265–268. DOI:
[33]
The FLTK Team 2019. Fast Light Toolkit. The FLTK Team. Retrieved from https://github.com/fltk/fltk
[34]
Shao-Chung Wang, Lin-Ya Yu, Li-An Her, Hwang Yuan-Shin, and Jenq-Kuen Lee. December 2021. Pointer-based divergence analysis for OpenCL 2.0 programs. ACM Trans. Parallel Comput. 8, 20 (Dec. 2021), 1–23. Issue 4.
[35]
Wu Yinghao. 2013. Cplusplus_Thread_Lib. Retrieved from https://github.com/wyh267/Cplusplus_Thread_Lib
[36]
ZeroMQ 2019. ZeroMQ Lightweight Messaging Kernel. ZeroMQ. Retrieved from https://github.com/zeromq/libzmq
[37]
Yang Zhao, Jie Liu, and Edward A. Lee. 2007. A programming model for time-synchronized distributed real-time systems. In Proceedings of the 13th IEEE Real Time and Embedded Technology and Applications Symposium (RTAS’07). 259–268.

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Cyber-Physical Systems
ACM Transactions on Cyber-Physical Systems  Volume 9, Issue 1
January 2025
311 pages
EISSN:2378-9638
DOI:10.1145/3703016
  • Editor:
  • Chenyang Lu
Issue’s Table of Contents

Publisher

Association for Computing Machinery

New York, NY, United States

Journal Family

Publication History

Published: 22 January 2025
Online AM: 31 July 2023
Accepted: 20 July 2023
Revised: 05 July 2023
Received: 15 January 2023
Published in TCPS Volume 9, Issue 1

Check for updates

Author Tags

  1. MISRA C++
  2. static analysis
  3. compiler for security
  4. embedded system design

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 854
    Total Downloads
  • Downloads (Last 12 months)501
  • Downloads (Last 6 weeks)41
Reflects downloads up to 07 Mar 2025

Other Metrics

Citations

View Options

Login options

Full Access

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Full Text

View this article in Full Text.

Full Text

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media