20
Sep

TRACE32 Trace-Based MC/DC Code Coverage


Welcome to this video Starting from March 2018, the TRACE32 tools can be used to prove Modified Condition and
Decision Coverage based on real-time trace recording, which doesn’t require any instrumentation
of the target code. To prove MC/DC coverage based on trace data,
a comprehensive analysis of all decisions and its corresponding conditions is required. The analysis requires that the structure and the position of all decisions within the source
code is known to the tool. This means that additional information about the source code structure is required. This is currently not part of the debug information generated by the compiler. Lauterbach provides the t32cast command line
tool for this purpose, which analyzes the C or C++ source code. As a result the information
on the decision structure required for MCDC coverage analyis is generated for each source
code file and stored in a so called eca file. Eca files are stored in the same directories
as their corresponding source files by default. Consequently, the build process must be adjusted
in order to allow this information to be generated. The t32cast command line tool is compiler independent and it can be easily integrated into existing build environments. This for instance is a simple makefile example where the eca file are generated In order to clearly identify the outcome of
a condition at object code level in the trace recordig, it is required that each condition
in the source code is represented at object code level by a conditional jump or by a conditional instruction and not by an arithmetic representation of the condition. Thus, it must be ensured
that the compiler generates the object code in such a way that it fits this requirement,
for example by disabling optimizations. We use in this video a TRACE32 Version of
March 2018 with TRACE32 PowerView for PowerPC and a PowerDebugPro together with a PowerTrace-II connected to a Bolero3M board with an MPC5646C processor. Let’s consider the following example code. I will start the program execution by pushing
the Go button. The execution is stopped at the breakpoint set at the end of the RunCoverageDemo function. The trace recording is automatically started with the program execution and stopped when the target is stopped. I will then open the code coverage configuration
window by selecting the TRACE32 menu Cov then Configuration… The MCDC code coverage criteria must be selected using the SourceMetric pulldown menu from the coverage configuration window. By default the eca files needed for the MCDC coverage analysis are automatically loaded when needed. But they can also be loaded in
advance. This can easily be done by pushing the Touch all button from the sYmbol.ECA.List window. As you can see, the eca files, previously generated for the coverage.c and main.c source files using the t32cast tool, have been loaded. TRACE32 uses a code coverage database to collect
valid trace recordings that should be analyzed. Push the ADD button to transfer the current
trace data to this database. The coverage results can be displayed at function level by pushing the ListFunc button from the Coverage configuration window. TRACE32 uses the following tag for the MCDC coverage analysis: stmt + mc/dc (if a function is completely
covered) or imcomplete, if mc/dc coverage is not achived The percentage of achieved MC/DC coverage is additionally displayed for each function. The following function for example achieved 85%. By doing a double click on the function name, a source listing view will be opened and shows more details for the single source code lines. As you can see, the condition at line 304 did not achieve MCDC coverage This function is actually called from the code below. The decision here is ((a || b) && c) with following truth table. To achieve MCDC coverage, the following test vectors are necessary. However, during the first run, we have only executed these three test vectors. This is why the measured code coverage was not sufficient to achieve MCDC coverage for
our decision. Let’s start the program execution again. We stop one more time at the end of the RunCoverageDemo function. The executed code is however a little
bit different from the previous run because of the tic variable. Let’s add the trace data to the coverage data base now using the menu Cov then Add Trace buffer. As you can see the test vector necessary for MCDC coverage have been now executed and we
have a 100% coverage for our function. Are you interested? Find more details on “mc/dc
code coverage” in this document. But of course TRACE32 has more to offer, please
refer to our other videos on this topic. Thanks for watching

Tags: , ,

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *