I recently started using OpenOCD to debug some firmware issues and GDB
is reporting bogus stack pointer values. After digging through the code
I found that the stack alignment code in rtos_generic_stack_read() is
causing the problem. 

When the code below is run with an initial pointer of 0x20080468, which
is already aligned, it turns it into 0x20080470. 

/* Align new stack pointer to x byte boundary */
new_stack_ptr =
  (new_stack_ptr & (~((int64_t) stacking->stack_alignment - 1))) +
  ((stacking->stack_growth_direction == -1) ?
  stacking->stack_alignment : 0);

The platform is an Atmel ATSAM3X8E (Cortex M3) which has these stack
settings:

    stack_growth_direction = -1;
    stack_alignment = 8;

Commenting out the code above allow me to get decent looking backtraces
for all the tasks.

        Jon


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to