Function arguments getting corrupted during debug

Discussion created by windam on Aug 13, 2008
Latest reply on Sep 3, 2008 by windam
Hi Everyone,

I'm debugging on a DSP56858 with CW 8.2.  My application includes an rtos.
I've noticed that function arguments become corrupted sometimes.  For example, I set 2 breakpts in the code below and hit Run.  
CW stops at breakpt #1.  I see that arg1=0 and arg2=3.  
I stepover myfunc().  
CW stops at breakpt #2.  arg1=6 and arg2=788.
Stepover at the assert indicates that arg1 and arg2 are out of range.  arg1 should be 0 and arg2 should be 3.

void caller(char arg1, char arg2)
   myfunc(arg1, arg2);   // <--- set breakpt #1 here, arg1=0 and arg2=3.
   // stepover

void myfunc(char arg1, char arg2)
   ASSERT (arg1 < 5);   // <--- set breakpt #2.  arg1=6 and arg2=788.
   ASSERT (arg2 < 10);  // stepover causes assert to report the error condition

I viewed the code in disassembly and noticed that arg1 and arg2 are placed in the Y0 and Y1 registers.  Before mfunc() is called, Y0 and Y1 are correct.  When the code executes to breakpt #2, Y0 and Y1 are 6 and 788 respectively.  So it looks like Y0 and Y1 got overwritten.  Single-stepping is disassembly did not show that Y0 and Y1 were corrupted.  Furthermore, if I ran the code without breakpts, the asserts did not report any errors with arg1 and arg2, so it seems like it is behaving as expected.  I suspect that the rtos is somehow interfering with the debugger since the code was ported from a project that does not use the rtos.
However, I could be wrong, and perhaps I need to configure the debugger differently.

Anyway, if anyone has experienced something similar and knows of a work-around/fix, please let me know.