Hi everyone,
I am currently debugging a very nasty problem on the C6474. The symptom seen most often is that I get an exception when core zero (the only core running) tries to execute code from the heap.
I suspect that the stack pointer has been corrupted and that when a function has returned, it has loaded B3 from the wrong address on the stack, and then jumped to B3.
(I suspect this because the SP is pointing to a stack location that contains the address seen in B3 and the Exception Return Pointer. Whilst two words away, there is a perfectly good return address.)
I would like to use Trace to help understand where the code was running prior to the exception, but currently can't figure out how to configure it. I have a parallel post on the CCS forum asking for help setting up trace on the C6474 with CCSv4 and a Spectrum Digital USB XDS510. Due to the time difference between the UK and the US, this is taking a long time to sort out. If anyone else has any input to that post I would be very grateful.
In the mean time I have decided to try and catch the SP being corrupted. What I would like to do is add a C statement at the top of a number of functions to save the stack pointer value to a variable, and add a test at the end of the same functions that checks it is still the same just before exit.
I am not yet confident to do this in assembler; I am worried that I would corrupt registers if I added my own assembler to do this.
Hence I would like to know if anyone can tell me how to read the stack pointer in C such that I can write it to a variable, and later use it in an if statement to test itagainst that variable. Perhaps you know of a function call, a macro, or some in-line assembler.
Any ideas?
Paul