gcc / gdb related issue

nobody wrote on Tuesday, January 09, 2007:


Maybe my question is not so FreeRTOS specific but I ran into it while trying out FreeRTOS.

Im using:
yagarto toolchain/eplipse/openocd
target board is based on SAM7A1

The problem is that debugger is not able to show variables correctly. I used the same "naked" attribute as serial port demo for FreeRTOS:

void vUART_ISR( void ) __attribute__ ((naked));

void vUART_ISR( void )

    portBASE_TYPE xStatus;
    portBASE_TYPE a;
    portBASE_TYPE xST, xMask, xDummy;   
    portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByRx = pdFALSE;

    xST= USART1->SR;  <---------------I inserted brakepoint here
    xMask= USART1->IMR;
           xStatus= xST & xMask;

I checked the assembly output of the compiler. Variables are inserted below the sp as C compiler is used to do (as I understood it so far) and interrupt mask registers and everything seems reasonable. But eclipse debugger (as well as insight) shows totally different values and does not change the value as program reads status/mask registers. Same thing for xTaskWokenBy…, despite assembly output initialises these values and inserts below the sp, debugger has different opinion about the values… This is rather annoying while debugging and I guess everything that does not work correctly can cause a lot of trouble…

My C and linker flags are the following:
DEBUG=-ggdb (also tried -g)

CFLAGS=-Wall -D $(RUN_MODE) -D SAM7A1           
        $(DEBUG) -mcpu=arm7tdmi        
        -Wcast-align $(OPTIM) -fomit-frame-pointer

LINKER_FLAGS=-Xlinker -ortosdemo.elf -Xlinker -M -Xlinker -Map=rtosdemo.map -Wl,–cref,-L…/lib,-lSAM7A1

Thank you in advance!

imajeff wrote on Wednesday, January 10, 2007:

One case where I don’t see the right variables is if I compile with ‘-fomit-frame-pointer’ but the debugger doesn’t support it. Of course the solution would be a debugger that supports it There’s good reason why __attribute__((naked)) is required by FreeRTOS, otherwise removing it would probably make the debugger work.

The bottom line is that FreeRTOS is by design, dificult to debug all the way through. I use other methods of debugging those parts (i.e. add code to output trace information).