|Debugging ROBOTC Exception Reports
|Page 1 of 1|
|Author:||Dick Swan [ Fri Jun 22, 2007 6:20 am ]|
|Post subject:||Debugging ROBOTC Exception Reports|
ROBOTC has a powerful debugging capability in its 'exception' checking capability. An exception usually occurs because of either a programming error or an attempt to use non-existant functionality. For example:
Trying to write to the system 1-msec clock will generate a "read only" exception. [Note: you can write to the four timers to reset them].
Accessing arrays beyond their size will give an "array out of bounds exception".
Stack overflow / underflow exceptinos -- usually from trying to nest too many subroutine calls.
And many more.
When an exception occurs in a program the program will be halted and a not very meaningful display will appear on the NXT LCD screen. If you open the ROBOTC debugger (or already have it open) then it reads the execution state from the NXT and provides a more meaningful display on the PC. You can use the information in the exception report to help isolate the problem area in your code.
Look at the typical exception below.
The report indicates that there was an exception 69 at offset (hex) 006F in task "main". You can use the list of exceptions to determine what 69 means. Use the 'F9' key in ROBOTC to get a listing of your program with assembler opcodes included. Find the code for task "main". Look for the instruction at opcode that is at offset '6F'. This is the instruction after the exception so look for the previous instruction. Now look for the C code that precedes this instruction -- this is the code line that generated the exception.
ROBOTC usually provides meaningful text in the exception report indicating the type of exception. Except, as in the above case, when I forget to add the text string when a new exception is handled. But you can easily determine the meaning of an exceptino on your own. They are all defined in a 'enum' found in the file "OpcodeDefinitions.h" that is part of the RobotC distribution. I have also included a current copy of this enum below:
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group