View unanswered posts | View active topics It is currently Wed Aug 20, 2014 1:27 am






Reply to topic  [ 1 post ] 
Debugging ROBOTC Exception Reports 
Author Message
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 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.

Code:
RobotC Exception Violation Report
Byte Code Interpreteter Exception:
Program Slot 0, Task ID: main[0]
Error at PC: BAD-LOC + 0x11554
Task PC: Task offset 006F
Task State: 'Exception'
Exception Type: 'Unknown(69)'


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:

Code:
///////////////////////////////////////////////////////////////////////////////////////////////
//
//                              Exception Types
//
//////////////////////////////////////////////////////////////////////////////////////////////

typedef enum
{
  exceptionNone                       = 0,
  exceptionSensorOutOfRange           = 1,
  exceptionMotorOutOfRange            = 2,
  exceptionTimerOutOfRange            = 3,
  exceptionEventOutOfRange            = 4,
  exceptionVariableOutOfRange         = 5,
  exceptionOutOfRange                 = 6,
  exceptionArrayOutOfRange            = 7,

  exceptionViewVariableOutofRange     = 8,

  exceptionStackOverflow              = 9,
  exceptionStackUnderflow             = 10,

  exceptionInvalidOpcode              = 11,

  exceptionReadOnlyParm               = 12,

  exceptionPCOutOfRange               = 13,

  exceptionUnused                     = 14,

  exceptionInvalidSubroutine          = 15,
  exceptionInvalidSubroutineReturn    = 16,

  exceptionAssertFailure              = 17,
  exceptionParmOutOfRangeRead         = 18,
  exceptionSystemParmOutOfRange       = 19,
  exceptionValueOutOfRange            = 20,
  exceptionUartParmOutOfRange         = 21,
  exceptionSoundParmOutOfRange        = 22,
  exceptionTaskOutOfRange             = 23,
  exceptionInvalidLengthLongMessage   = 24,

  exceptionInvalidBreakpoint          = 25,
  exceptionWordReadOfLongParm         = 26,
  exceptionFloatNotSupported          = 27,
  exceptionLongNotSupported           = 28,
  exceptionBreakpoint                 = 29,
  exceptionToManyBreakpoint           = 30,
  //unused,
  //unused,
  //unused,
  //unused,
  //unused,
  //unused,
  exceptionIllegalFloatOperand        = 37,
  //unused 38
  exceptionInternalError              = 39,
  exceptionParmOutOfRangeWrite        = 40,  // Bad Opcode Source
  exceptionInvalidPConBranch          = 41,
  exceptionInvalidPConSubReturn       = 42,
  exceptionInvalidInternalQueues1     = 44,
  exceptionInvalidInternalQueues2     = 45,
  exceptionInvalidInternalQueues3     = 46,
  exceptionInvalidInternalQueues4     = 47,
  exceptionInvalidInternalQueues5     = 48,
  exceptionInvalidInternalQueues6     = 49,
  exceptionInvalidInternalQueues7     = 50,
  exceptionInvalidInternalQueues8     = 51,
  exceptionInvalidInternalQueues9     = 52,
  exceptionInvalidInternalQueues10    = 53,
  exceptionInvalidInternalQueues11    = 54,
  exceptionInvalidInternalQueues12    = 55,
  exceptionInvalidInternalQueues13    = 56,
  exceptionInvalidInternalQueues14    = 57,
  exceptionInvalidInternalQueues15    = 58,
  exceptionInvalidEventListMap1       = 58,
  exceptionInvalidEventListMap2       = 59,
  exceptionInvalidEventListMap3       = 60,
  exceptionInvalidEventListMap4       = 61,
  exceptionInvalidEventListMap5       = 62,
  exceptionInternalAsmGlueError       = 63,
  exceptionDatalogIndexError          = 64,
  exceptionDatalogRawNotImplemented   = 65,
  exceptionDatalogOverflow            = 66,
  exceptionInvalidDatalogSourceType   = 67,
  exceptionRealAddressOutOfRange      = 68,
  exceptionCannotUpdateSlaveSync      = 69,

  exceptionUnknown                    = opEnumType 255
} TVMException;

[/list][/list]


Fri Jun 22, 2007 6:20 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.