Architecture Analysis
A discussion of the importance of C code analysis.
The problem
Embedded source code represents an enormous investment by a company. Unfortunately, large mature code bases are problematic for several reasons:
- They require substantial human resources to maintain
- New standards or requirements can be difficult to integrate into the existing code
- Large and mature code is complex and interconnected, making it difficult to understand - bringing new engineers up to speed is not trivial
Despite these disadvantages, companies continue struggling to refactor their code and adhere to new requirements while still remaining competitive in a global economy. Large C code bases represent company knowledge and IP that is difficult to access, manage and leverage in new ways.
The Solution
One solution, is to migrate your code to models to take advantage of modern development processes. If you are interested in a this approach, go to our link on Code to Model Conversion. If this is not a viable solution for you, Emmeskay offers another approach that allows you understand your code better and to use that understanding to streamline existing development processes. Emmeskay has developed tools (see IME) and associated services that can allow companies to understand their C code from an architecture perspective. This approach simplifies the development of C code in several ways:
- Graphically rendering the code organization to the engineer making a complex problem tractable
- Analyzing the data-flow, hierarchical organization, and dependencies
- Presenting analysis results to the user in a graphical or textual format.
Use-Cases
Here are several use-cases that illustrate how Emmeskay uses tools that can help your company perform better when working with C code.
Training and Learning
Understanding the c-code may not be easy by just looking at the code. However, IME can help new (and experienced) engineers recognize the overall structure of code quickly. Engineers can inspect the organization of the code. The graphical structure presented to the user can be selected to reveal the properties most interesting:
Code issues
IME provides several visual tools to understand algorithm architecture. These methods layout the C code structure based on a mathematical formula designed to accentuate the organization of the imported code. In one case, the lead engineer uses IME to understand the organization of the project code. Once the code is imported, the engineer opens the throttle module. After a little work, the engineer sees the graph shown here:
Upon inspection, the throttle body module appears to contain code not relevant to the throttle control! Looking closer, the engineers finds that code responsible for controlling lights, wipers, turn-signals, and cabin heater are grouped with throttle. The engineer goes to the C code. After careful inspection, it appears that C functions are defined in a bios header files! This file is then included in many other files. This example shows how a potentially serious issue is highlighted with the graphical analysis, making a potentially tricky code analysis much simpler.
Data-flow analysis
Within IME, engineers can right-click an object defined in the code and find out how it impacts other parts of the code. IME performs and impact analysis of the selected item. It finds the objects influence that object and how the selected object influences other objects. The results are presented graphically or textually. Here is a graphical example of what a user might see:
Exported Data Dictionary analysis
When IME imports C code, it will automatically create a data-dictionary for the user. The data dictionary is tab-separated and can be opened from within Excel. The picture below shows the dictionary opened in Excel. Note, the automatic filters and colored columns are added inside Excel, and are not automatically created by IME. The data dictionary contains listings of all functions, variables, parameters, and constants defined within the C code. It also lists who defines each item, who accesses them, and who changes their values.
Although not a complete solution by itself, the data-dictionary enables engineers to collaborate through a common document that is easily read and viewed in standard software. Excel is a portable, format that allows engineers to access important information while away from the office. Furthermore, because it is an Excel file, it can be sorted and searched to find data of interest.
What Else Is There?
These are only a few simple illustrations of how analysis can aid in C code development. If you find this interesting, please contact us. We would be happy to make a live demonstration of our tools capabilities.