How can i find out what a local variable in the stack has been overwritten?

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i find out what a local variable in the stack has been overwritten?

163 Views
Contributor I

I am using LPC1778 controller with RTOS. A local variable in a subfunction has been overwritten by a overflow. How can i find out what a local variable in the stack has been overwritten?

Labels (1)
Tags (1)
0 Kudos
3 Replies

17 Views
Senior Contributor I

Sebastian,

depending on what tool you use for debug you can set breakpoints on memory access in Cortex processors. I use Keil, and setting a breakpoint on a overwrite, it looks like this:

pastedImage_1.png

You can also define memory areas etc, its just a matter of syntax. If you know an exact place (address) that is being written in the tasks stackarea, set this address as the breakpoint. The processor will then stop at the exact spot where the write (to the illegal address) occurs.

0 Kudos

17 Views
NXP TechSupport
NXP TechSupport

Hi Sebastian Bläsing

Thank you for your interest in NXP Semiconductor products and 
for the opportunity to serve you.
Actually, I'm not very clear with your question, so whether you can describe the question in details and attaching corresponding codes will be better☺.
I'm looking to forward to your reply.

TIC

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

17 Views
Contributor I

Hi jeremyzhou,

thank you for your reply.

A local variable (in a function) is always stored in the stack, is that correct? The value of this variable I can read out via the JTAG interface via LPCXpresso, for this I use the breakpoints. I found out that the value of a local variable (integer) was overridden by another function / task. Now I want to find out which function / task overwrites this memory area.

I use the FreeRTOS V7.6 Memory Allocation implementation "heap_2".

0 Kudos