Instrumentation for Testing and Debugging : Trace (Time Stamp)

Trace (Time Stamp)

Consider the following code:

#ifdef TRACE_TASK
#ifndef TRACE_TASK_STARTED
extern void traceTask();
#define TRACE_TASK_STARTED(t) traceTask((t),’S’)
#endif
TASK (MAIN_LOOP)
{
if ((cgGlobalFlags & ALARM_SET_MAIN_LOOP) == 0){
cgGlobalFlags |= ALARM_SET_MAIN_LOOP;
SetRelAlarm(ALARM_SET_MAIN_LOOP, 10, 10);
};
TRACE_TASK_STARTED(MAIN_LOOP);
do {
:
} while ( (cgGlobalFlags & BITSUPERSTEP_MAIN_LOOP) !=
0);
TRACE_TASK_TERMINATED(MAIN_LOOP);
TerminateTask();
 
 

This is from the traceFunc.c file and can be easily modified to send the output anywhere.

#ifdef TRACE_TASK
void
traceTask(TaskRefType t, char indx)
{
TickType sysTime;
GetCounterValue(SYS_TIMER, &sysTime);
OSPrintf("%c Task ID %d %ld\n", indx, (int) t, (long
int)sysTime);
}
#endif