Reply by Vladimir Vassilevsky●May 13, 20112011-05-13
vikasvds wrote:
> Hi,
>
> I am using ECOS on ARM946.
>
> The problem is - i don't have any idea on how to retrieve register values
> of user, supervisor and other modes while processor is in exception mode.
> Please give me some idea on how to retrieve the values of registers of
> other modes.
Exceptions are priviledged modes. So you can switch between modes and
the associated banked registers by writing to CPSR. Set it to the user
mode at the very last.
> I guess the stack area i can get from map file and i can print values in
> range to get stack
Nope.
> please correct me if i am wrong or if there is any
> better approach.
>
> Please help me on the problem.
RTFM
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
Reply by Arlet Ottens●May 13, 20112011-05-13
On 05/13/2011 06:06 PM, Rob Gaddi wrote:
>> I have registered exception handlers for undefined instruction, data
>> abort
>> and pre-fetch abort, but i am unable to think of routine which can be
>> useful for debugging in case of exception.
>>
>> I can think of printing register values of other modes to UART.
>> Printing registers of other modes can help in finding cause of exceptions
>> using program counter stack pointers, CPSR and SPSR etc.
>> Other think stack can also be printed to get some clue of cause.
>>
>> The problem is - i don't have any idea on how to retrieve register values
>> of user, supervisor and other modes while processor is in exception mode.
>> Please give me some idea on how to retrieve the values of registers of
>> other modes.
>>
>> I guess the stack area i can get from map file and i can print values in
>> range to get stack please correct me if i am wrong or if there is any
>> better approach.
>>
>
> That means that your application should expect to never see those
> exceptions, which means that if you hit them, something's wrong with
> your code. Which means you should still be in the "I have a JTAG pod
> hooked up" stage of things. Why not just an infinite loop, and if you
> find yourself in one of them then you go spelunking to figure out how
> you got there?
Unless you don't/can't use JTAG for debugging.
> Then in shipping code, any of those events should be cause for a
> watchdog reset.
Depends on the users. I've had code in alpha/beta stages where the
exceptions were caught, and a memory map, including the register dump
and stacks could be sent back to the developers as an e-mail attachment.
It's very valuable for those 1-in-a-million bugs that are hard to
reproduce in the lab.
Reply by Rob Gaddi●May 13, 20112011-05-13
On 5/13/2011 4:55 AM, vikasvds wrote:
> Hi,
>
> I am using ECOS on ARM946.
>
> I have registered exception handlers for undefined instruction, data abort
> and pre-fetch abort, but i am unable to think of routine which can be
> useful for debugging in case of exception.
>
> I can think of printing register values of other modes to UART.
> Printing registers of other modes can help in finding cause of exceptions
> using program counter stack pointers, CPSR and SPSR etc.
> Other think stack can also be printed to get some clue of cause.
>
> The problem is - i don't have any idea on how to retrieve register values
> of user, supervisor and other modes while processor is in exception mode.
> Please give me some idea on how to retrieve the values of registers of
> other modes.
>
> I guess the stack area i can get from map file and i can print values in
> range to get stack please correct me if i am wrong or if there is any
> better approach.
>
> Please help me on the problem.
>
> Thanks
> Vikas
>
> ---------------------------------------
> Posted through http://www.EmbeddedRelated.com
That means that your application should expect to never see those
exceptions, which means that if you hit them, something's wrong with
your code. Which means you should still be in the "I have a JTAG pod
hooked up" stage of things. Why not just an infinite loop, and if you
find yourself in one of them then you go spelunking to figure out how
you got there?
Then in shipping code, any of those events should be cause for a
watchdog reset.
--
Rob Gaddi, Highland Technology
Email address is currently out of order
Reply by Arlet Ottens●May 13, 20112011-05-13
On 05/13/2011 01:55 PM, vikasvds wrote:
> I am using ECOS on ARM946.
>
> I have registered exception handlers for undefined instruction, data abort
> and pre-fetch abort, but i am unable to think of routine which can be
> useful for debugging in case of exception.
>
> I can think of printing register values of other modes to UART.
> Printing registers of other modes can help in finding cause of exceptions
> using program counter stack pointers, CPSR and SPSR etc.
> Other think stack can also be printed to get some clue of cause.
>
> The problem is - i don't have any idea on how to retrieve register values
> of user, supervisor and other modes while processor is in exception mode.
> Please give me some idea on how to retrieve the values of registers of
> other modes.
You'll need to switch to each mode, and then write the registers to RAM
somewhere.
To switch mode, write the mode to the CPSR register, e.g.
msr cpsr_c, #0xd1 // switches to FIQ mode
When you're in FIQ mode, write register r8-r14 somewhere, and then
switch to other mode.
Check the ARM Architecture Reference Manual for all the modes, and
register banks.
To retrieve registers of user mode, use a special instruction:
stmia r0, {r13-r14}^ // note the '^' at the end
After writing all the registers to RAM, switch back to SVC mode, and
print all of them.
Reply by vikasvds●May 13, 20112011-05-13
Hi,
I am using ECOS on ARM946.
I have registered exception handlers for undefined instruction, data abort
and pre-fetch abort, but i am unable to think of routine which can be
useful for debugging in case of exception.
I can think of printing register values of other modes to UART.
Printing registers of other modes can help in finding cause of exceptions
using program counter stack pointers, CPSR and SPSR etc.
Other think stack can also be printed to get some clue of cause.
The problem is - i don't have any idea on how to retrieve register values
of user, supervisor and other modes while processor is in exception mode.
Please give me some idea on how to retrieve the values of registers of
other modes.
I guess the stack area i can get from map file and i can print values in
range to get stack please correct me if i am wrong or if there is any
better approach.
Please help me on the problem.
Thanks
Vikas
---------------------------------------
Posted through http://www.EmbeddedRelated.com