[solved] How can I debug ET_Illegal_PC

Technical questions regarding the XTC tools and programming with XMOS.
voodoosound
Active Member
Posts: 63
Joined: Sat Oct 15, 2011 8:53 pm

[solved] How can I debug ET_Illegal_PC

Post by voodoosound »

Hi,

i am trying to debug my application. When I try to start an AVB stream, the listener thread receives an exception.
ET_ILLEGAL_PC

I tried using the debugger, but I cannot narrow down the problem.

Could anyone give me some advice, on how to debug that exception?

Thanks in advance!

Regards,
Ck
Last edited by voodoosound on Tue Jun 04, 2013 4:37 pm, edited 1 time in total.


User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

ET_ILLEGAL_PC means the PC is on a non 16b boundary or out of range (see p. 249) here https://www.xmos.com/download/public/Th ... 79A%29.pdf
Obviously this should never happen with compiled code so something is amiss..

The debugger is your friend here. When you hit the exception and break, you can see the stack frames of calling functions to see how you got to the Illegal PC. For example, the below case shows in the eclipse debugger, an ET_ECALL exception from a deliberate out of bounds array access .. You can see the exact line of source and in which function that caused the problem. You can see the mistake (*11 in the index)..
Screen Shot 2013-05-29 at 16.46.40.png
Can you get to a capture of something similar in your setup? It should then be possible to see where it happened.

Also, it would help to share versions of tools/source, what board you're using etc.
You do not have the required permissions to view the files attached to this post.
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

You'll sometimes get this exception if you have memory corruption. When a function is called the address to return to is stored on the stack. If something comes along and overwrites this value in memory you'll get an illegal pc exception when the function trys to return due to the return address being invalid. Once you know where the exception occours I would look for possible out of bound array accesses in that function and in the functions it calls.

If the function is written in XC, doesn't use #pragma unsafe arrays and only uses arrays that were declared in XC then any out of bounds array access will be caught, either at compile time or at runtime. If any one of these conditions doesn't hold then out of bounds array accesses might not be caught.
voodoosound
Active Member
Posts: 63
Joined: Sat Oct 15, 2011 8:53 pm

Post by voodoosound »

Hi thanks for the advice.
Indeed it was an array which got exceeded...

If I want to connect to an AVB stream, which has more channels, than I set as the size for the listener map, I get the exception.

Works fine now, thank you!