debugging msp430

Started by Juergen August 31, 2006

I try to debug function parameters inside a function.
I am going nuts doing this. I don't know why I didn't notice problems
before, but this is what I do. I have a function call

myresult_t DoSomething(portSHORT command, portSHORT* status);

I call this with
portSHORT command = 0x0000;
portSHORT status = 0xCCCC;
(with portSHORT being 16bit wide)

DoSomething(command, &status);

Inside the function (anywhere in the function actually, not only in the
first line) I neither seem to be able to get the real value of the
address the pointer status is pointing to, nor the value the variable
the pointer is pointing to holds (*status)

"x/2b status" should give me the address along with the content, but
it's not.
If I call "x/2b &status" OUTSIDE before I call the function it shows:
0x1602 <xHeap+1010): 0xCC 0xCC
inside the function it "x/2b status" shows
0x11 <__data_start>: 0x00 0x00

When I try "p/x *status" it shows
$5 = 0x0
not giving me any address and I can tell from the value that it's
wrong, because I set the variable to 0xCCCC before I called the

I tried to make sense of all this using "disassemble" and stepping
through the assembler code with "stepi" but it looks like everything is
If I set the value of *pcData=0x3333 this is really written to the
variable if I return from the function so everything is fine.
But I cannot debug like this obviously :-)
I set optimization to -O0 so there is no optimization.
If I set optimization to -O1 I am running into problems because I then
have even more problems because sometimes my variables are only
available through registers and then I cannot deal with the values any
more, so setting optimization to a higher value is not an option.

So, I am looking for a solution how to be able to debug something like
this with optimization -O0.
Any idea what I do wrong or is it just not possible to display the
value of paramters inside of a function?

Thanks in advance


I am using
cpu: MSP430xF1611
gcc: msp430-gcc 3.3.6
gdb: msp430-gdb 5.1.1
OS: linux
embedded OS: freeRTOS
MSP-FET430UIF for JTAG-Debugging

Juergen wrote:

> myresult_t DoSomething(portSHORT command, portSHORT* status);
The ABI uses registers for at least the first parameter, maybe the first couple of parameters (I forget... it's been a while). What is the _caller_ code generated for: void myfunc(uint16_t a, uint16_t b, uint16_t c) { } void main(void) { myfunc(0x1234,0x5678,0xabcd); }