printing register values from exception handler...

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

formatting link

Reply to
vikasvds
Loading thread data ...

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 to
Arlet Ottens

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 to
Rob Gaddi

Unless you don't/can't use JTAG for debugging.

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 to
Arlet Ottens

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.

Nope.

RTFM

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.