Hi,
I am currently using XDS560Pro tracer and TCI6638K2K device.
I used the tracer to analyze the results of the PC trace tools such as Function Profiler and Code Coverage.
I created the following example source code to investigate the accuracy of the tracer.
As a summary for the source code:
- bounded_func() is called 20000 times
- called_control_func() is called to see the calling times
- sprintf_func() is called to use the sprintf function (CPU consumes more cycles than other functions).
- non_called_func() isn't called it is just a test function for code coverage results.
- limitless_func() is called to increment a variable.
You can evaluate the code.
#include <stdint.h>
#include <string.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <stdio.h>
unsigned long cnt_20000 = 0;
unsigned long cnt_test_fxn2 = 0;
unsigned long cnt_sprintf_called = 0;
unsigned long cnt_limitless = 0;
void bounded_func() {
cnt_20000+=1;
}
void called_control_func() {
unsigned long i;
cnt_test_fxn2++;
for (i=0; i<20000; i++) {
if (i % 2) {
cnt_test_fxn2--;
}
else {
cnt_test_fxn2++;
}
}
}
void sprintf_func() {
unsigned char tmp_buff[128] = {0};
unsigned long i;
cnt_sprintf_called++;
for (i=0; i<100; i++) {
sprintf(&tmp_buff[0], "Test Message for test_fxn3, i: %u", i);
}
}
void non_called_func() {
unsigned long cnt_non_called =101;
}
void limitless_func() {
cnt_limitless+=1;
}
main() {
int idx=0;
while (TRUE) {
if (idx<20000){
bounded_func();
}
called_control_func();
sprintf_func();
limitless_func();
idx+=1;
}
return 0;
}
For the test procedure, I followed the below instructions:
- Restart the device
- Connect the device when it starts
- Load Program (.out file that is created by the given source code)
- Tools>Harware Trace Analyzer>PC Tools and create the PC Tools with fig.1 options.
- Run the device
- Stop it after a short time. (%1 fulled of tracer fig. 2)
Figure 1 Options of PC Trace
Figure 2 Overall records and percentage of the ProTracer memory
The test procedure and the main function begin simultaneously.
The following results have occurred:
1* Figure 3 shows that bounded_func() variable (cnt_20000) is counted up to 20000 which means that bounded_funct() should have been called 20000 times. However, as you can see in Fig 4. It is called just 35 times.
2* sprintf function is called 100 times in the sprintf_func(), so the calling times should have been a linear correlation. However, as you can see in Fig 4. sprintf_func() is called 7812 times whereas sprintf() is called 9221 times.
3* There is no record for Cache Event Profiler and Stall Cycle Profiler (fig 5)
Figure 3 Expressions of the functions
Figure 4 Function Profiler View
Figure 5 Cache Event Profiler View
Why the above results are occurred whereas different ones expected?
There are 38 588 428 records (fig 2) and 21 900 135 cycles, so can i calculate the trace duration as the following equation?
Trace Duration = Cumulative cycle / CPU frequency(1.4GHz) : 21 900 135/ 1 400 000 000 = 15.6429 mS
For my real program which is much more complicated and big CCS is shut down immediately after the trace job is completed, how could i fix the problem?
Code Coverage isn't working for the real program what can i do?
Thanks, Enes