Difference between revisions of "SCI/FreeSCI/Kernel hacking/Error handling and debugging"
(Merging of the FreeSCI documentation. Page done.) |
(No difference)
|
Latest revision as of 01:09, 24 January 2009
Error handling and debugging
Error handling and debugging probably are the most important aspects of program writing. FreeSCI provides three macros for printing debug output:
- SCIkwarn(text, ...)
- Print a warning message
- SCIkdebug(text, ...)
- Print a debug message
- CHECK_THIS_KERNEL_FUNCTION
- print the function name and parameters
The difference between SCIkwarn and SCIkdebug is that the latter can be easily removed (by commenting out the #define SCI_KERNEL_DEBUG on or about line 39). In practice this means that SCIkwarn should be used for warning or error messages in cases where it is likely that the vm or the kernel function are doing something wrong; e.g. if the program refers to a non-existant resource file, if a node list command does not come with a pointer to a node list, or if the number of parameters is insufficient. These messages are important and may point to misperceptions of details of the SCI engine. SCIkdebug, on the other hand, is your every-day "flood me with information until I'm blind" debug macro.
Sometimes it may happen that something goes wrong inside the kernel; e.g. a kernel function runs out of memory handles, or an internal variable somehow was set to an invalid value. In this case, kernel_oops(state_t *, char *) should be used. It prints an error message and halts the VM, which none of the macros does.