I have a basic project running, but tasks are not doing what I want so I would like to use the traceTASK_SWITCHED_IN/OUT macros to output something to a logic analyzer.
So here is my code
void setLogOutput (unsigned long c)
{
int a;
if (c == 0)
a = 0;
}
#define traceTASK_SWITCHED_IN() setLogOutput(pxCurrentTCB->uxTaskNumber)
#define traceTASK_SWITCHED_OUT() setLogOutput(0)
#include "FreeRTOS.h"
Obviously setLogOutput doesn’t do anything right now, and I know it.
But the point is that neighter SWITCHED_IN nor SWITCHED_OUT are ever called or compiled.
Breakpoints in tasks.c are broken.
I cannot understand what I am doing wrong, could anybody please help me?
volatile unsigned int dummy;
void setLogOutput (unsigned long c)
{
dummy++;
}
It is possible that optimiser ignores the code, because it does nothing.
GCC is very clever with this: it sees when a variable is only used in the left-hand size of expressions, and in that case it will never be implemented. ‘volatile’ might help or better: print the variable somewhere.
I’ve been seeing GCC get more and more clever about working around my
ways to keep variables/code from being deleted. There was a time when
global variables were safe, but not now.
I’ve tried debugging with no optimization, but that just blows the code
up where it doesn’t fit. I now run with -Og which seems to be a
reasonable compromise most of the time.
On 06/04/2014 09:56 AM, Hein Tibosch wrote:
GCC is very clever with this: it sees when a variable is only used in
the left-hand size of expressions, and in that case it will never be
implemented. ‘volatile’ might help or better: print the variable
somewhere.
–
Jerry Durand, Durand Interstellar, Inc. www.interstellar.com
tel: +1 408 356-3886, USA toll free: 1 866 356-3886
Skype: jerrydurand